-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Mior Muhammad Zaki <[email protected]>
- Loading branch information
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
namespace Orchestra\Canvas\Core\Tests\Concerns; | ||
|
||
use Illuminate\Contracts\Support\Arrayable; | ||
use Orchestra\Canvas\Core\Concerns\UsesGeneratorOverrides; | ||
use Orchestra\Canvas\Core\PresetManager; | ||
use Orchestra\Canvas\Core\Presets\Preset; | ||
use Orchestra\Testbench\TestCase; | ||
|
||
class UsesGeneratorOverridesTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function it_can_get_qualify_model_class() | ||
{ | ||
$filesystem = $this->app['files']; | ||
|
||
$filesystem->ensureDirectoryExists(base_path('app/Models')); | ||
|
||
$stub = new UsesGeneratorOverridesTestStub(); | ||
|
||
$this->assertSame([ | ||
'user-model' => 'App\Models\User', | ||
'welcome-view' => $this->app->joinPaths(base_path('resources'.DIRECTORY_SEPARATOR.'views'.DIRECTORY_SEPARATOR.'welcome.blade.php')), | ||
], $stub->toArray()); | ||
} | ||
} | ||
|
||
class UsesGeneratorOverridesTestStub implements Arrayable | ||
{ | ||
use UsesGeneratorOverrides; | ||
|
||
/** | ||
* Get the root namespace for the class. | ||
* | ||
* @return string | ||
*/ | ||
protected function rootNamespace() | ||
{ | ||
return $this->rootNamespaceUsingCanvas(); | ||
} | ||
|
||
/** | ||
* Get the instance as an array. | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
public function toArray() | ||
{ | ||
return [ | ||
'user-model' => $this->qualifyModelUsingCanvas('User'), | ||
'welcome-view' => $this->viewPathUsingCanvas('welcome.blade.php'), | ||
]; | ||
} | ||
|
||
/** | ||
* Resolve the generator preset. | ||
*/ | ||
protected function generatorPreset(): Preset | ||
{ | ||
return app(PresetManager::class)->driver('laravel'); | ||
} | ||
} |