Browse Source

Merge pull request #21 from nafiesl/laravel-7-support

Add Laravel 7 support
tags/1.4.0^0 1.4.0
Nafies Luthfi 6 years ago
committed by GitHub
parent
commit
f7579a24c7
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      composer.json
  2. 11
      src/GeneratorCommand.php
  3. 11
      src/Generators/BaseGenerator.php
  4. 12
      src/stubs/testcases/feature/api.stub
  5. 24
      tests/Generators/Api/ApiFeatureTestGeneratorTest.php

4
composer.json

@ -21,8 +21,8 @@
}, },
"require": { "require": {
"php": ">=7.0.0", "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": { "require-dev": {
"orchestra/testbench": "~3.0" "orchestra/testbench": "~3.0"

11
src/GeneratorCommand.php

@ -2,15 +2,13 @@
namespace Luthfi\CrudGenerator; namespace Luthfi\CrudGenerator;
use Illuminate\Support\Str;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Container\Container;
use Illuminate\Filesystem\Filesystem; use Illuminate\Filesystem\Filesystem;
use Illuminate\Console\DetectsApplicationNamespace;
use Illuminate\Support\Str;
class GeneratorCommand extends Command class GeneratorCommand extends Command
{ {
use DetectsApplicationNamespace;
/** /**
* The injected Filesystem class * 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') resource_path('views/'.str_replace('.', '/', config('simple-crud.default_layout_view')).'.blade.php')
); );
} }
protected function getAppNamespace()
{
return Container::getInstance()->getNamespace();
}
} }

11
src/Generators/BaseGenerator.php

@ -2,18 +2,16 @@
namespace Luthfi\CrudGenerator\Generators; namespace Luthfi\CrudGenerator\Generators;
use Illuminate\Container\Container;
use Illuminate\Filesystem\Filesystem; use Illuminate\Filesystem\Filesystem;
use Luthfi\CrudGenerator\GeneratorCommand;
use Illuminate\Console\DetectsApplicationNamespace;
use Luthfi\CrudGenerator\Contracts\Generator as GeneratorContract; use Luthfi\CrudGenerator\Contracts\Generator as GeneratorContract;
use Luthfi\CrudGenerator\GeneratorCommand;
/** /**
* Base Generator Class * Base Generator Class
*/ */
abstract class BaseGenerator implements GeneratorContract abstract class BaseGenerator implements GeneratorContract
{ {
use DetectsApplicationNamespace;
/** /**
* The injected Filesystem class * The injected Filesystem class
* *
@ -130,4 +128,9 @@ abstract class BaseGenerator implements GeneratorContract
{ {
return $this->command->getName() == 'make:crud-api'; return $this->command->getName() == 'make:crud-api';
} }
protected function getAppNamespace()
{
return Container::getInstance()->getNamespace();
}
} }

12
src/stubs/testcases/feature/api.stub

@ -70,7 +70,7 @@ class ManageMasterTest extends TestCase
); );
$this->seeStatusCode(422); $this->seeStatusCode(422);
$this->seeJsonSubset(['errors' => ['name' => []]]);
$this->seeJsonStructure(['errors' => ['name']]);
} }
/** @test */ /** @test */
@ -87,7 +87,7 @@ class ManageMasterTest extends TestCase
); );
$this->seeStatusCode(422); $this->seeStatusCode(422);
$this->seeJsonSubset(['errors' => ['name' => []]]);
$this->seeJsonStructure(['errors' => ['name']]);
} }
/** @test */ /** @test */
@ -104,7 +104,7 @@ class ManageMasterTest extends TestCase
); );
$this->seeStatusCode(422); $this->seeStatusCode(422);
$this->seeJsonSubset(['errors' => ['description' => []]]);
$this->seeJsonStructure(['errors' => ['description']]);
} }
/** @test */ /** @test */
@ -169,7 +169,7 @@ class ManageMasterTest extends TestCase
); );
$this->seeStatusCode(422); $this->seeStatusCode(422);
$this->seeJsonSubset(['errors' => ['name' => []]]);
$this->seeJsonStructure(['errors' => ['name']]);
} }
/** @test */ /** @test */
@ -187,7 +187,7 @@ class ManageMasterTest extends TestCase
); );
$this->seeStatusCode(422); $this->seeStatusCode(422);
$this->seeJsonSubset(['errors' => ['name' => []]]);
$this->seeJsonStructure(['errors' => ['name']]);
} }
/** @test */ /** @test */
@ -205,7 +205,7 @@ class ManageMasterTest extends TestCase
); );
$this->seeStatusCode(422); $this->seeStatusCode(422);
$this->seeJsonSubset(['errors' => ['description' => []]]);
$this->seeJsonStructure(['errors' => ['description']]);
} }
/** @test */ /** @test */

24
tests/Generators/Api/ApiFeatureTestGeneratorTest.php

@ -84,7 +84,7 @@ class Manage{$this->model_name}Test extends TestCase
); );
\$this->seeStatusCode(422); \$this->seeStatusCode(422);
\$this->seeJsonSubset(['errors' => ['name' => []]]);
\$this->seeJsonStructure(['errors' => ['name']]);
} }
/** @test */ /** @test */
@ -101,7 +101,7 @@ class Manage{$this->model_name}Test extends TestCase
); );
\$this->seeStatusCode(422); \$this->seeStatusCode(422);
\$this->seeJsonSubset(['errors' => ['name' => []]]);
\$this->seeJsonStructure(['errors' => ['name']]);
} }
/** @test */ /** @test */
@ -118,7 +118,7 @@ class Manage{$this->model_name}Test extends TestCase
); );
\$this->seeStatusCode(422); \$this->seeStatusCode(422);
\$this->seeJsonSubset(['errors' => ['description' => []]]);
\$this->seeJsonStructure(['errors' => ['description']]);
} }
/** @test */ /** @test */
@ -183,7 +183,7 @@ class Manage{$this->model_name}Test extends TestCase
); );
\$this->seeStatusCode(422); \$this->seeStatusCode(422);
\$this->seeJsonSubset(['errors' => ['name' => []]]);
\$this->seeJsonStructure(['errors' => ['name']]);
} }
/** @test */ /** @test */
@ -201,7 +201,7 @@ class Manage{$this->model_name}Test extends TestCase
); );
\$this->seeStatusCode(422); \$this->seeStatusCode(422);
\$this->seeJsonSubset(['errors' => ['name' => []]]);
\$this->seeJsonStructure(['errors' => ['name']]);
} }
/** @test */ /** @test */
@ -219,7 +219,7 @@ class Manage{$this->model_name}Test extends TestCase
); );
\$this->seeStatusCode(422); \$this->seeStatusCode(422);
\$this->seeJsonSubset(['errors' => ['description' => []]]);
\$this->seeJsonStructure(['errors' => ['description']]);
} }
/** @test */ /** @test */
@ -329,7 +329,7 @@ class Manage{$this->model_name}Test extends TestCase
); );
\$this->seeStatusCode(422); \$this->seeStatusCode(422);
\$this->seeJsonSubset(['errors' => ['name' => []]]);
\$this->seeJsonStructure(['errors' => ['name']]);
} }
/** @test */ /** @test */
@ -346,7 +346,7 @@ class Manage{$this->model_name}Test extends TestCase
); );
\$this->seeStatusCode(422); \$this->seeStatusCode(422);
\$this->seeJsonSubset(['errors' => ['name' => []]]);
\$this->seeJsonStructure(['errors' => ['name']]);
} }
/** @test */ /** @test */
@ -363,7 +363,7 @@ class Manage{$this->model_name}Test extends TestCase
); );
\$this->seeStatusCode(422); \$this->seeStatusCode(422);
\$this->seeJsonSubset(['errors' => ['description' => []]]);
\$this->seeJsonStructure(['errors' => ['description']]);
} }
/** @test */ /** @test */
@ -428,7 +428,7 @@ class Manage{$this->model_name}Test extends TestCase
); );
\$this->seeStatusCode(422); \$this->seeStatusCode(422);
\$this->seeJsonSubset(['errors' => ['name' => []]]);
\$this->seeJsonStructure(['errors' => ['name']]);
} }
/** @test */ /** @test */
@ -446,7 +446,7 @@ class Manage{$this->model_name}Test extends TestCase
); );
\$this->seeStatusCode(422); \$this->seeStatusCode(422);
\$this->seeJsonSubset(['errors' => ['name' => []]]);
\$this->seeJsonStructure(['errors' => ['name']]);
} }
/** @test */ /** @test */
@ -464,7 +464,7 @@ class Manage{$this->model_name}Test extends TestCase
); );
\$this->seeStatusCode(422); \$this->seeStatusCode(422);
\$this->seeJsonSubset(['errors' => ['description' => []]]);
\$this->seeJsonStructure(['errors' => ['description']]);
} }
/** @test */ /** @test */

Loading…
Cancel
Save