Browse Source

Improve test cases

Add generated policy test existance check
tags/1.3.2
Nafies Luthfi 7 years ago
parent
commit
8defe920c8
  1. 7
      tests/CrudApiMakeCommandTest.php
  2. 5
      tests/CrudMakeCommandTest.php
  3. 5
      tests/CrudSimpleMakeCommandTest.php

7
tests/CrudApiMakeCommandTest.php

@ -29,6 +29,7 @@ class CrudApiMakeCommandTest extends TestCase
$this->assertFileExists(app_path("Policies/{$this->model_name}Policy.php"));
$this->assertFileExists(database_path("factories/{$this->model_name}Factory.php"));
$this->assertFileExists(base_path("tests/Unit/Models/{$this->model_name}Test.php"));
$this->assertFileExists(base_path("tests/Unit/Policies/{$this->model_name}PolicyTest.php"));
$this->assertFileExists(base_path("tests/Feature/Api/Manage{$this->model_name}Test.php"));
}
@ -53,11 +54,12 @@ class CrudApiMakeCommandTest extends TestCase
$this->assertFileNotExists(app_path("Policies/{$this->model_name}Policy.php"));
$this->assertFileNotExists(database_path("factories/{$this->model_name}Factory.php"));
$this->assertFileNotExists(base_path("tests/Unit/Models/{$this->model_name}Test.php"));
$this->assertFileNotExists(base_path("tests/Unit/Policies/{$this->model_name}PolicyTest.php"));
$this->assertFileExists(base_path("tests/Feature/Api/Manage{$this->model_name}Test.php"));
}
/** @test */
public function it_cannot_generate_crud_files_if_namespaced_model_exists()
public function it_not_generate_api_crud_files_if_namespaced_model_exists()
{
$this->artisan('make:model', ['name' => 'Entities/Projects/Problem', '--no-interaction' => true]);
$this->artisan('make:crud-api', ['name' => 'Entities/Projects/Problem', '--no-interaction' => true]);
@ -79,6 +81,7 @@ class CrudApiMakeCommandTest extends TestCase
$this->assertFileNotExists(app_path("Policies/ProblemPolicy.php"));
$this->assertFileNotExists(database_path("factories/ProblemFactory.php"));
$this->assertFileNotExists(base_path("tests/Unit/Models/ProblemTest.php"));
$this->assertFileNotExists(base_path("tests/Unit/Policies/ProblemPolicyTest.php"));
$this->assertFileExists(base_path("tests/Feature/Api/ManageProblemTest.php"));
$this->removeFileOrDir(app_path('Entities/Projects'));
@ -115,6 +118,7 @@ class CrudApiMakeCommandTest extends TestCase
$this->assertFileExists(app_path("Policies/{$modelName}Policy.php"));
$this->assertFileExists(database_path("factories/{$modelName}Factory.php"));
$this->assertFileExists(base_path("tests/Unit/Models/{$modelName}Test.php"));
$this->assertFileExists(base_path("tests/Unit/Policies/{$modelName}PolicyTest.php"));
$this->assertFileExists(base_path("tests/Feature/Api/Manage{$modelName}Test.php"));
}
@ -147,6 +151,7 @@ class CrudApiMakeCommandTest extends TestCase
$this->assertFileExists(database_path("factories/{$modelName}Factory.php"));
$this->assertFileExists(base_path("tests/Unit/Models/{$modelName}Test.php"));
$this->assertFileExists(base_path("tests/Unit/Policies/{$modelName}PolicyTest.php"));
$this->assertFileExists(app_path("Policies/{$parentName}/{$modelName}Policy.php"));
$this->assertFileExists(base_path("tests/Feature/Api/Manage{$modelName}Test.php"));
}

5
tests/CrudMakeCommandTest.php

@ -31,6 +31,7 @@ class CrudMakeCommandTest extends TestCase
$this->assertFileExists(app_path("Policies/{$this->model_name}Policy.php"));
$this->assertFileExists(database_path("factories/{$this->model_name}Factory.php"));
$this->assertFileExists(base_path("tests/Unit/Models/{$this->model_name}Test.php"));
$this->assertFileExists(base_path("tests/Unit/Policies/{$this->model_name}PolicyTest.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$this->model_name}Test.php"));
}
@ -60,6 +61,7 @@ class CrudMakeCommandTest extends TestCase
$this->assertFileNotExists(app_path("Policies/{$this->model_name}Policy.php"));
$this->assertFileNotExists(database_path("factories/{$this->model_name}Factory.php"));
$this->assertFileNotExists(base_path("tests/Unit/Models/{$this->model_name}Test.php"));
$this->assertFileNotExists(base_path("tests/Unit/Policies/{$this->model_name}PolicyTest.php"));
$this->assertFileNotExists(base_path("tests/Feature/Manage{$this->model_name}Test.php"));
}
@ -88,6 +90,7 @@ class CrudMakeCommandTest extends TestCase
$this->assertFileNotExists(app_path("Policies/ProblemPolicy.php"));
$this->assertFileNotExists(database_path("factories/ProblemFactory.php"));
$this->assertFileNotExists(base_path("tests/Unit/Models/ProblemTest.php"));
$this->assertFileNotExists(base_path("tests/Unit/Policies/ProblemPolicyTest.php"));
$this->assertFileNotExists(base_path("tests/Feature/ManageProblemTest.php"));
$this->removeFileOrDir(app_path('Entities/Projects'));
@ -126,6 +129,7 @@ class CrudMakeCommandTest extends TestCase
$this->assertFileExists(app_path("Policies/{$modelName}Policy.php"));
$this->assertFileExists(database_path("factories/{$modelName}Factory.php"));
$this->assertFileExists(base_path("tests/Unit/Models/{$modelName}Test.php"));
$this->assertFileExists(base_path("tests/Unit/Policies/{$modelName}PolicyTest.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$modelName}Test.php"));
}
@ -160,6 +164,7 @@ class CrudMakeCommandTest extends TestCase
$this->assertFileExists(database_path("factories/{$modelName}Factory.php"));
$this->assertFileExists(base_path("tests/Unit/Models/{$modelName}Test.php"));
$this->assertFileExists(base_path("tests/Unit/Policies/{$modelName}PolicyTest.php"));
$this->assertFileExists(app_path("Policies/{$parentName}/{$modelName}Policy.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$modelName}Test.php"));
}

5
tests/CrudSimpleMakeCommandTest.php

@ -29,6 +29,7 @@ class CrudSimpleCommandTest extends TestCase
$this->assertFileExists(app_path("Policies/{$this->model_name}Policy.php"));
$this->assertFileExists(database_path("factories/{$this->model_name}Factory.php"));
$this->assertFileExists(base_path("tests/Unit/Models/{$this->model_name}Test.php"));
$this->assertFileExists(base_path("tests/Unit/Policies/{$this->model_name}PolicyTest.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$this->model_name}Test.php"));
}
@ -56,6 +57,7 @@ class CrudSimpleCommandTest extends TestCase
$this->assertFileNotExists(app_path("Policies/{$this->model_name}Policy.php"));
$this->assertFileNotExists(database_path("factories/{$this->model_name}Factory.php"));
$this->assertFileNotExists(base_path("tests/Unit/Models/{$this->model_name}Test.php"));
$this->assertFileNotExists(base_path("tests/Unit/Policies/{$this->model_name}PolicyTest.php"));
$this->assertFileNotExists(base_path("tests/Feature/Manage{$this->model_name}Test.php"));
}
@ -82,6 +84,7 @@ class CrudSimpleCommandTest extends TestCase
$this->assertFileNotExists(app_path("Policies/ProblemPolicy.php"));
$this->assertFileNotExists(database_path("factories/ProblemFactory.php"));
$this->assertFileNotExists(base_path("tests/Unit/Models/ProblemTest.php"));
$this->assertFileNotExists(base_path("tests/Unit/Policies/ProblemPolicyTest.php"));
$this->assertFileNotExists(base_path("tests/Feature/ManageProblemTest.php"));
$this->removeFileOrDir(app_path('Entities/Projects'));
@ -118,6 +121,7 @@ class CrudSimpleCommandTest extends TestCase
$this->assertFileExists(app_path("Policies/{$modelName}Policy.php"));
$this->assertFileExists(database_path("factories/{$modelName}Factory.php"));
$this->assertFileExists(base_path("tests/Unit/Models/{$modelName}Test.php"));
$this->assertFileExists(base_path("tests/Unit/Policies/{$modelName}PolicyTest.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$modelName}Test.php"));
}
@ -150,6 +154,7 @@ class CrudSimpleCommandTest extends TestCase
$this->assertFileExists(database_path("factories/{$modelName}Factory.php"));
$this->assertFileExists(base_path("tests/Unit/Models/{$modelName}Test.php"));
$this->assertFileExists(base_path("tests/Unit/Policies/{$modelName}PolicyTest.php"));
$this->assertFileExists(app_path("Policies/{$parentName}/{$modelName}Policy.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$modelName}Test.php"));
}

Loading…
Cancel
Save