diff --git a/composer.json b/composer.json index 025b9e4..e632a35 100644 --- a/composer.json +++ b/composer.json @@ -21,8 +21,8 @@ }, "require": { "php": ">=7.0.0", - "illuminate/support": "5.8.*||^6.0", - "laravel/browser-kit-testing": "^5.0" + "illuminate/support": "5.8.*||^6.0||^7.0", + "laravel/browser-kit-testing": "^5.0||^6.0" }, "require-dev": { "orchestra/testbench": "~3.0" diff --git a/src/GeneratorCommand.php b/src/GeneratorCommand.php index 805aa46..b8dced3 100644 --- a/src/GeneratorCommand.php +++ b/src/GeneratorCommand.php @@ -2,15 +2,13 @@ namespace Luthfi\CrudGenerator; -use Illuminate\Support\Str; use Illuminate\Console\Command; +use Illuminate\Container\Container; use Illuminate\Filesystem\Filesystem; -use Illuminate\Console\DetectsApplicationNamespace; +use Illuminate\Support\Str; class GeneratorCommand extends Command { - use DetectsApplicationNamespace; - /** * The injected Filesystem class * @@ -130,4 +128,9 @@ class GeneratorCommand extends Command resource_path('views/'.str_replace('.', '/', config('simple-crud.default_layout_view')).'.blade.php') ); } + + protected function getAppNamespace() + { + return Container::getInstance()->getNamespace(); + } } diff --git a/src/Generators/BaseGenerator.php b/src/Generators/BaseGenerator.php index d129a0d..e532ffd 100644 --- a/src/Generators/BaseGenerator.php +++ b/src/Generators/BaseGenerator.php @@ -2,18 +2,16 @@ namespace Luthfi\CrudGenerator\Generators; +use Illuminate\Container\Container; use Illuminate\Filesystem\Filesystem; -use Luthfi\CrudGenerator\GeneratorCommand; -use Illuminate\Console\DetectsApplicationNamespace; use Luthfi\CrudGenerator\Contracts\Generator as GeneratorContract; +use Luthfi\CrudGenerator\GeneratorCommand; /** * Base Generator Class */ abstract class BaseGenerator implements GeneratorContract { - use DetectsApplicationNamespace; - /** * The injected Filesystem class * @@ -130,4 +128,9 @@ abstract class BaseGenerator implements GeneratorContract { return $this->command->getName() == 'make:crud-api'; } + + protected function getAppNamespace() + { + return Container::getInstance()->getNamespace(); + } } diff --git a/src/stubs/testcases/feature/api.stub b/src/stubs/testcases/feature/api.stub index c32bc5d..ea35101 100644 --- a/src/stubs/testcases/feature/api.stub +++ b/src/stubs/testcases/feature/api.stub @@ -70,7 +70,7 @@ class ManageMasterTest extends TestCase ); $this->seeStatusCode(422); - $this->seeJsonSubset(['errors' => ['name' => []]]); + $this->seeJsonStructure(['errors' => ['name']]); } /** @test */ @@ -87,7 +87,7 @@ class ManageMasterTest extends TestCase ); $this->seeStatusCode(422); - $this->seeJsonSubset(['errors' => ['name' => []]]); + $this->seeJsonStructure(['errors' => ['name']]); } /** @test */ @@ -104,7 +104,7 @@ class ManageMasterTest extends TestCase ); $this->seeStatusCode(422); - $this->seeJsonSubset(['errors' => ['description' => []]]); + $this->seeJsonStructure(['errors' => ['description']]); } /** @test */ @@ -169,7 +169,7 @@ class ManageMasterTest extends TestCase ); $this->seeStatusCode(422); - $this->seeJsonSubset(['errors' => ['name' => []]]); + $this->seeJsonStructure(['errors' => ['name']]); } /** @test */ @@ -187,7 +187,7 @@ class ManageMasterTest extends TestCase ); $this->seeStatusCode(422); - $this->seeJsonSubset(['errors' => ['name' => []]]); + $this->seeJsonStructure(['errors' => ['name']]); } /** @test */ @@ -205,7 +205,7 @@ class ManageMasterTest extends TestCase ); $this->seeStatusCode(422); - $this->seeJsonSubset(['errors' => ['description' => []]]); + $this->seeJsonStructure(['errors' => ['description']]); } /** @test */ diff --git a/tests/Generators/Api/ApiFeatureTestGeneratorTest.php b/tests/Generators/Api/ApiFeatureTestGeneratorTest.php index 7696f7b..a93c1fe 100644 --- a/tests/Generators/Api/ApiFeatureTestGeneratorTest.php +++ b/tests/Generators/Api/ApiFeatureTestGeneratorTest.php @@ -84,7 +84,7 @@ class Manage{$this->model_name}Test extends TestCase ); \$this->seeStatusCode(422); - \$this->seeJsonSubset(['errors' => ['name' => []]]); + \$this->seeJsonStructure(['errors' => ['name']]); } /** @test */ @@ -101,7 +101,7 @@ class Manage{$this->model_name}Test extends TestCase ); \$this->seeStatusCode(422); - \$this->seeJsonSubset(['errors' => ['name' => []]]); + \$this->seeJsonStructure(['errors' => ['name']]); } /** @test */ @@ -118,7 +118,7 @@ class Manage{$this->model_name}Test extends TestCase ); \$this->seeStatusCode(422); - \$this->seeJsonSubset(['errors' => ['description' => []]]); + \$this->seeJsonStructure(['errors' => ['description']]); } /** @test */ @@ -183,7 +183,7 @@ class Manage{$this->model_name}Test extends TestCase ); \$this->seeStatusCode(422); - \$this->seeJsonSubset(['errors' => ['name' => []]]); + \$this->seeJsonStructure(['errors' => ['name']]); } /** @test */ @@ -201,7 +201,7 @@ class Manage{$this->model_name}Test extends TestCase ); \$this->seeStatusCode(422); - \$this->seeJsonSubset(['errors' => ['name' => []]]); + \$this->seeJsonStructure(['errors' => ['name']]); } /** @test */ @@ -219,7 +219,7 @@ class Manage{$this->model_name}Test extends TestCase ); \$this->seeStatusCode(422); - \$this->seeJsonSubset(['errors' => ['description' => []]]); + \$this->seeJsonStructure(['errors' => ['description']]); } /** @test */ @@ -329,7 +329,7 @@ class Manage{$this->model_name}Test extends TestCase ); \$this->seeStatusCode(422); - \$this->seeJsonSubset(['errors' => ['name' => []]]); + \$this->seeJsonStructure(['errors' => ['name']]); } /** @test */ @@ -346,7 +346,7 @@ class Manage{$this->model_name}Test extends TestCase ); \$this->seeStatusCode(422); - \$this->seeJsonSubset(['errors' => ['name' => []]]); + \$this->seeJsonStructure(['errors' => ['name']]); } /** @test */ @@ -363,7 +363,7 @@ class Manage{$this->model_name}Test extends TestCase ); \$this->seeStatusCode(422); - \$this->seeJsonSubset(['errors' => ['description' => []]]); + \$this->seeJsonStructure(['errors' => ['description']]); } /** @test */ @@ -428,7 +428,7 @@ class Manage{$this->model_name}Test extends TestCase ); \$this->seeStatusCode(422); - \$this->seeJsonSubset(['errors' => ['name' => []]]); + \$this->seeJsonStructure(['errors' => ['name']]); } /** @test */ @@ -446,7 +446,7 @@ class Manage{$this->model_name}Test extends TestCase ); \$this->seeStatusCode(422); - \$this->seeJsonSubset(['errors' => ['name' => []]]); + \$this->seeJsonStructure(['errors' => ['name']]); } /** @test */ @@ -464,7 +464,7 @@ class Manage{$this->model_name}Test extends TestCase ); \$this->seeStatusCode(422); - \$this->seeJsonSubset(['errors' => ['description' => []]]); + \$this->seeJsonStructure(['errors' => ['description']]); } /** @test */