From e8b6d95ab8ea75d710ed2593675b1f90bb10f495 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Sun, 11 Feb 2018 13:16:08 +0800 Subject: [PATCH] Update proper tests assertion after generated form view changes --- tests/CrudMakeCommandTest.php | 16 +++++++++++++--- tests/CrudSimpleMakeCommandTest.php | 6 +++--- ...GeneratorTest.php => FullControllerGeneratorTest.php} | 2 +- ...neratorTest.php => SimpleControllerGeneratorTest.php} | 2 +- tests/TestCase.php | 2 ++ 5 files changed, 20 insertions(+), 8 deletions(-) rename tests/Generators/{ControllerGeneratorTest.php => FullControllerGeneratorTest.php} (99%) rename tests/Generators/Simple/{ControllerGeneratorTest.php => SimpleControllerGeneratorTest.php} (99%) diff --git a/tests/CrudMakeCommandTest.php b/tests/CrudMakeCommandTest.php index 777070d..8199af6 100644 --- a/tests/CrudMakeCommandTest.php +++ b/tests/CrudMakeCommandTest.php @@ -20,7 +20,9 @@ class CrudMakeCommandTest extends TestCase $this->assertFileExists($migrationFilePath); $this->assertFileExists(resource_path("views/{$this->table_name}/index.blade.php")); - $this->assertFileExists(resource_path("views/{$this->table_name}/forms.blade.php")); + $this->assertFileExists(resource_path("views/{$this->table_name}/create.blade.php")); + $this->assertFileExists(resource_path("views/{$this->table_name}/edit.blade.php")); + $this->assertFileNotExists(resource_path("views/{$this->table_name}/forms.blade.php")); $localeConfig = config('app.locale'); $this->assertFileExists(resource_path("lang/{$localeConfig}/{$this->lang_name}.php")); @@ -47,6 +49,8 @@ class CrudMakeCommandTest extends TestCase $this->assertFileNotExists($migrationFilePath); $this->assertFileNotExists(resource_path("views/{$this->table_name}/index.blade.php")); + $this->assertFileNotExists(resource_path("views/{$this->table_name}/create.blade.php")); + $this->assertFileNotExists(resource_path("views/{$this->table_name}/edit.blade.php")); $this->assertFileNotExists(resource_path("views/{$this->table_name}/forms.blade.php")); $localeConfig = config('app.locale'); @@ -74,6 +78,8 @@ class CrudMakeCommandTest extends TestCase $this->assertFileNotExists($migrationFilePath); $this->assertFileNotExists(resource_path("views/problems/index.blade.php")); + $this->assertFileNotExists(resource_path("views/problems/create.blade.php")); + $this->assertFileNotExists(resource_path("views/problems/edit.blade.php")); $this->assertFileNotExists(resource_path("views/problems/forms.blade.php")); $localeConfig = config('app.locale'); @@ -110,7 +116,9 @@ class CrudMakeCommandTest extends TestCase $this->assertFileExists($migrationFilePath); $this->assertFileExists(resource_path("views/{$tableName}/index.blade.php")); - $this->assertFileExists(resource_path("views/{$tableName}/forms.blade.php")); + $this->assertFileExists(resource_path("views/{$tableName}/create.blade.php")); + $this->assertFileExists(resource_path("views/{$tableName}/edit.blade.php")); + $this->assertFileNotExists(resource_path("views/{$tableName}/forms.blade.php")); $localeConfig = config('app.locale'); $this->assertFileExists(resource_path("lang/{$localeConfig}/{$langName}.php")); @@ -143,7 +151,9 @@ class CrudMakeCommandTest extends TestCase $this->assertFileExists($migrationFilePath); $this->assertFileExists(resource_path("views/{$tableName}/index.blade.php")); - $this->assertFileExists(resource_path("views/{$tableName}/forms.blade.php")); + $this->assertFileExists(resource_path("views/{$tableName}/create.blade.php")); + $this->assertFileExists(resource_path("views/{$tableName}/edit.blade.php")); + $this->assertFileNotExists(resource_path("views/{$tableName}/forms.blade.php")); $localeConfig = config('app.locale'); $this->assertFileExists(resource_path("lang/{$localeConfig}/{$langName}.php")); diff --git a/tests/CrudSimpleMakeCommandTest.php b/tests/CrudSimpleMakeCommandTest.php index 1c69903..ee73b18 100644 --- a/tests/CrudSimpleMakeCommandTest.php +++ b/tests/CrudSimpleMakeCommandTest.php @@ -63,7 +63,7 @@ class CrudSimpleCommandTest extends TestCase public function it_cannot_generate_crud_files_if_namespaced_model_exists() { $this->artisan('make:model', ['name' => 'Entities/Projects/Problem', '--no-interaction' => true]); - $this->artisan('make:crud', ['name' => 'Entities/Projects/Problem', '--no-interaction' => true]); + $this->artisan('make:crud-simple', ['name' => 'Entities/Projects/Problem', '--no-interaction' => true]); $this->assertContains("Problem model already exists.", app(Kernel::class)->output()); @@ -99,7 +99,7 @@ class CrudSimpleCommandTest extends TestCase $langName = 'category'; $modelPath = 'Entities/References'; - $this->artisan('make:crud', ['name' => $inputName, '--no-interaction' => true]); + $this->artisan('make:crud-simple', ['name' => $inputName, '--no-interaction' => true]); $this->assertNotContains("{$modelName} model already exists.", app(Kernel::class)->output()); @@ -132,7 +132,7 @@ class CrudSimpleCommandTest extends TestCase $langName = 'category'; $modelPath = 'Entities/References'; - $this->artisan('make:crud', ['name' => $inputName, '--parent' => $parentName, '--no-interaction' => true]); + $this->artisan('make:crud-simple', ['name' => $inputName, '--parent' => $parentName, '--no-interaction' => true]); $this->assertNotContains("{$modelName} model already exists.", app(Kernel::class)->output()); diff --git a/tests/Generators/ControllerGeneratorTest.php b/tests/Generators/FullControllerGeneratorTest.php similarity index 99% rename from tests/Generators/ControllerGeneratorTest.php rename to tests/Generators/FullControllerGeneratorTest.php index eaefe94..e3280e2 100644 --- a/tests/Generators/ControllerGeneratorTest.php +++ b/tests/Generators/FullControllerGeneratorTest.php @@ -4,7 +4,7 @@ namespace Tests\Generators; use Tests\TestCase; -class ControllerGeneratorTest extends TestCase +class FullControllerGeneratorTest extends TestCase { /** @test */ public function it_creates_correct_controller_class_content() diff --git a/tests/Generators/Simple/ControllerGeneratorTest.php b/tests/Generators/Simple/SimpleControllerGeneratorTest.php similarity index 99% rename from tests/Generators/Simple/ControllerGeneratorTest.php rename to tests/Generators/Simple/SimpleControllerGeneratorTest.php index 71b74d9..ad92ff9 100644 --- a/tests/Generators/Simple/ControllerGeneratorTest.php +++ b/tests/Generators/Simple/SimpleControllerGeneratorTest.php @@ -4,7 +4,7 @@ namespace Tests\Generators\Simple; use Tests\TestCase; -class ControllerGeneratorTest extends TestCase +class SimpleControllerGeneratorTest extends TestCase { /** @test */ public function it_creates_correct_controller_class_content() diff --git a/tests/TestCase.php b/tests/TestCase.php index b7edb69..1972e6c 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -41,6 +41,7 @@ abstract class TestCase extends BaseTestCase $this->removeFileOrDir(app_path('Http')); $this->removeFileOrDir(database_path('migrations')); $this->removeFileOrDir(database_path('factories')); + $this->removeFileOrDir(resource_path('views/categories')); $this->removeFileOrDir(resource_path('views/'.$this->table_name)); $defaultLayoutsFile = config('simple-crud.default_layout_view'); @@ -54,6 +55,7 @@ abstract class TestCase extends BaseTestCase $locale = config('app.locale'); $this->removeFileOrDir(resource_path("lang/{$locale}/app.php")); $this->removeFileOrDir(resource_path("lang/{$locale}/{$this->lang_name}.php")); + $this->removeFileOrDir(resource_path("lang/{$locale}/category.php")); $this->removeFileOrDir(base_path('routes')); $this->removeFileOrDir(app_path('Policies'));