Browse Source

Change FeatureTest name convention to singular

tags/1.2.0
Nafies Luthfi 7 years ago
parent
commit
5b96a31c83
  1. 4
      src/Generators/FeatureTestGenerator.php
  2. 2
      src/stubs/testcases/feature/api.stub
  3. 2
      src/stubs/testcases/feature/full.stub
  4. 2
      src/stubs/testcases/feature/simple.stub
  5. 6
      tests/CommandOptions/TestsOnlyOptionsTest.php
  6. 10
      tests/CrudApiMakeCommandTest.php
  7. 10
      tests/CrudMakeCommandTest.php
  8. 10
      tests/CrudSimpleMakeCommandTest.php
  9. 12
      tests/Generators/Api/ApiFeatureTestGeneratorTest.php
  10. 12
      tests/Generators/FeatureTestGeneratorTest.php
  11. 12
      tests/Generators/Simple/FeatureTestGeneratorTest.php

4
src/Generators/FeatureTestGenerator.php

@ -23,11 +23,11 @@ class FeatureTestGenerator extends BaseGenerator
$featureTestPath = $this->makeDirectory(base_path($featureTestPath));
$this->generateFile(
"{$featureTestPath}/Manage{$this->modelNames['plural_model_name']}Test.php",
"{$featureTestPath}/Manage{$this->modelNames['model_name']}Test.php",
$this->getContent('testcases/feature/'.$type)
);
$this->command->info('Manage'.$this->modelNames['plural_model_name'].'Test generated.');
$this->command->info('Manage'.$this->modelNames['model_name'].'Test generated.');
}
/**

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

@ -6,7 +6,7 @@ use fullMstr;
use Tests\BrowserKitTest as TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class ManageMastersTest extends TestCase
class ManageMasterTest extends TestCase
{
use DatabaseMigrations;

2
src/stubs/testcases/feature/full.stub

@ -6,7 +6,7 @@ use fullMstr;
use Tests\BrowserKitTest as TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class ManageMastersTest extends TestCase
class ManageMasterTest extends TestCase
{
use DatabaseMigrations;

2
src/stubs/testcases/feature/simple.stub

@ -6,7 +6,7 @@ use fullMstr;
use Tests\BrowserKitTest as TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class ManageMastersTest extends TestCase
class ManageMasterTest extends TestCase
{
use DatabaseMigrations;

6
tests/CommandOptions/TestsOnlyOptionsTest.php

@ -2,8 +2,8 @@
namespace Tests\CommandOptions;
use Illuminate\Contracts\Console\Kernel;
use Tests\TestCase;
use Illuminate\Contracts\Console\Kernel;
class TestOnlyOptionsTest extends TestCase
{
@ -20,7 +20,7 @@ class TestOnlyOptionsTest extends TestCase
$this->assertNotContains("{$this->model_name} model already exists.", $output);
$this->assertFileNotExists(app_path($this->model_name.'.php'));
$this->assertFileNotExists(app_path("Http/Controllers/{$this->plural_model_name}Controller.php"));
$this->assertFileNotExists(app_path("Http/Controllers/{$this->model_name}Controller.php"));
$migrationFilePath = database_path('migrations/'.date('Y_m_d_His').'_create_'.$this->table_name.'_table.php');
$this->assertFileNotExists($migrationFilePath);
@ -37,7 +37,7 @@ class TestOnlyOptionsTest extends TestCase
$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->plural_model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$this->model_name}Test.php"));
$this->assertContains('Test files generated successfully!', $output);
}

10
tests/CrudApiMakeCommandTest.php

@ -29,7 +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/Feature/Api/Manage{$this->plural_model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Api/Manage{$this->model_name}Test.php"));
}
/** @test */
@ -53,7 +53,7 @@ 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->assertFileExists(base_path("tests/Feature/Api/Manage{$this->plural_model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Api/Manage{$this->model_name}Test.php"));
}
/** @test */
@ -79,7 +79,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->assertFileExists(base_path("tests/Feature/Api/ManageProblemsTest.php"));
$this->assertFileExists(base_path("tests/Feature/Api/ManageProblemTest.php"));
$this->removeFileOrDir(app_path('Entities/Projects'));
$this->removeFileOrDir(resource_path('views/problems'));
@ -115,7 +115,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/Feature/Api/Manage{$pluralModelName}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Api/Manage{$modelName}Test.php"));
}
/** @test */
@ -148,6 +148,6 @@ class CrudApiMakeCommandTest extends TestCase
$this->assertFileExists(database_path("factories/{$modelName}Factory.php"));
$this->assertFileExists(base_path("tests/Unit/Models/{$modelName}Test.php"));
$this->assertFileExists(app_path("Policies/{$parentName}/{$modelName}Policy.php"));
$this->assertFileExists(base_path("tests/Feature/Api/Manage{$pluralModelName}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Api/Manage{$modelName}Test.php"));
}
}

10
tests/CrudMakeCommandTest.php

@ -31,7 +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/Feature/Manage{$this->plural_model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$this->model_name}Test.php"));
}
/** @test */
@ -60,7 +60,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/Feature/Manage{$this->plural_model_name}Test.php"));
$this->assertFileNotExists(base_path("tests/Feature/Manage{$this->model_name}Test.php"));
}
/** @test */
@ -88,7 +88,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/Feature/ManageProblemsTest.php"));
$this->assertFileNotExists(base_path("tests/Feature/ManageProblemTest.php"));
$this->removeFileOrDir(app_path('Entities/Projects'));
$this->removeFileOrDir(resource_path('views/problems'));
@ -126,7 +126,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/Feature/Manage{$pluralModelName}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$modelName}Test.php"));
}
/** @test */
@ -161,6 +161,6 @@ class CrudMakeCommandTest extends TestCase
$this->assertFileExists(database_path("factories/{$modelName}Factory.php"));
$this->assertFileExists(base_path("tests/Unit/Models/{$modelName}Test.php"));
$this->assertFileExists(app_path("Policies/{$parentName}/{$modelName}Policy.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$pluralModelName}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$modelName}Test.php"));
}
}

10
tests/CrudSimpleMakeCommandTest.php

@ -29,7 +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/Feature/Manage{$this->plural_model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$this->model_name}Test.php"));
}
/** @test */
@ -56,7 +56,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/Feature/Manage{$this->plural_model_name}Test.php"));
$this->assertFileNotExists(base_path("tests/Feature/Manage{$this->model_name}Test.php"));
}
/** @test */
@ -82,7 +82,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/Feature/ManageProblemsTest.php"));
$this->assertFileNotExists(base_path("tests/Feature/ManageProblemTest.php"));
$this->removeFileOrDir(app_path('Entities/Projects'));
$this->removeFileOrDir(resource_path('views/problems'));
@ -118,7 +118,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/Feature/Manage{$pluralModelName}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$modelName}Test.php"));
}
/** @test */
@ -151,6 +151,6 @@ class CrudSimpleCommandTest extends TestCase
$this->assertFileExists(database_path("factories/{$modelName}Factory.php"));
$this->assertFileExists(base_path("tests/Unit/Models/{$modelName}Test.php"));
$this->assertFileExists(app_path("Policies/{$parentName}/{$modelName}Policy.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$pluralModelName}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$modelName}Test.php"));
}
}

12
tests/Generators/Api/ApiFeatureTestGeneratorTest.php

@ -11,7 +11,7 @@ class ApiFeatureTestGeneratorTest extends TestCase
{
$this->artisan('make:crud-api', ['name' => $this->model_name, '--no-interaction' => true]);
$this->assertFileExists(base_path("tests/Feature/Api/Manage{$this->plural_model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Api/Manage{$this->model_name}Test.php"));
$featureTestClassContent = "<?php
namespace Tests\Feature\Api;
@ -20,7 +20,7 @@ use {$this->full_model_name};
use Tests\BrowserKitTest as TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class Manage{$this->plural_model_name}Test extends TestCase
class Manage{$this->model_name}Test extends TestCase
{
use DatabaseMigrations;
@ -124,7 +124,7 @@ class Manage{$this->plural_model_name}Test extends TestCase
}
}
";
$this->assertEquals($featureTestClassContent, file_get_contents(base_path("tests/Feature/Api/Manage{$this->plural_model_name}Test.php")));
$this->assertEquals($featureTestClassContent, file_get_contents(base_path("tests/Feature/Api/Manage{$this->model_name}Test.php")));
}
/** @test */
@ -135,7 +135,7 @@ class Manage{$this->plural_model_name}Test extends TestCase
$this->artisan('make:crud-api', ['name' => $this->model_name, '--no-interaction' => true]);
$this->assertFileExists(base_path("tests/Feature/Api/Manage{$this->plural_model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Api/Manage{$this->model_name}Test.php"));
$featureTestClassContent = "<?php
namespace Tests\Feature\Api;
@ -144,7 +144,7 @@ use {$this->full_model_name};
use Tests\TestCase as TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class Manage{$this->plural_model_name}Test extends TestCase
class Manage{$this->model_name}Test extends TestCase
{
use DatabaseMigrations;
@ -248,6 +248,6 @@ class Manage{$this->plural_model_name}Test extends TestCase
}
}
";
$this->assertEquals($featureTestClassContent, file_get_contents(base_path("tests/Feature/Api/Manage{$this->plural_model_name}Test.php")));
$this->assertEquals($featureTestClassContent, file_get_contents(base_path("tests/Feature/Api/Manage{$this->model_name}Test.php")));
}
}

12
tests/Generators/FeatureTestGeneratorTest.php

@ -53,7 +53,7 @@ abstract class BrowserKitTest extends BaseTestCase
{
$this->artisan('make:crud', ['name' => $this->model_name, '--no-interaction' => true]);
$this->assertFileExists(base_path("tests/Feature/Manage{$this->plural_model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$this->model_name}Test.php"));
$modelClassContent = "<?php
namespace Tests\Feature;
@ -62,7 +62,7 @@ use {$this->full_model_name};
use Tests\BrowserKitTest as TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class Manage{$this->plural_model_name}Test extends TestCase
class Manage{$this->model_name}Test extends TestCase
{
use DatabaseMigrations;
@ -191,7 +191,7 @@ class Manage{$this->plural_model_name}Test extends TestCase
}
}
";
$this->assertEquals($modelClassContent, file_get_contents(base_path("tests/Feature/Manage{$this->plural_model_name}Test.php")));
$this->assertEquals($modelClassContent, file_get_contents(base_path("tests/Feature/Manage{$this->model_name}Test.php")));
}
/** @test */
@ -250,7 +250,7 @@ abstract class {$baseTestClass} extends BaseTestCase
$this->artisan('make:crud', ['name' => $this->model_name, '--no-interaction' => true]);
$this->assertFileExists(base_path("tests/Feature/Manage{$this->plural_model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$this->model_name}Test.php"));
$modelClassContent = "<?php
namespace Tests\Feature;
@ -259,7 +259,7 @@ use {$this->full_model_name};
use Tests\TestCase as TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class Manage{$this->plural_model_name}Test extends TestCase
class Manage{$this->model_name}Test extends TestCase
{
use DatabaseMigrations;
@ -388,6 +388,6 @@ class Manage{$this->plural_model_name}Test extends TestCase
}
}
";
$this->assertEquals($modelClassContent, file_get_contents(base_path("tests/Feature/Manage{$this->plural_model_name}Test.php")));
$this->assertEquals($modelClassContent, file_get_contents(base_path("tests/Feature/Manage{$this->model_name}Test.php")));
}
}

12
tests/Generators/Simple/FeatureTestGeneratorTest.php

@ -53,7 +53,7 @@ abstract class BrowserKitTest extends BaseTestCase
{
$this->artisan('make:crud-simple', ['name' => $this->model_name, '--no-interaction' => true]);
$this->assertFileExists(base_path("tests/Feature/Manage{$this->plural_model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$this->model_name}Test.php"));
$modelClassContent = "<?php
namespace Tests\Feature;
@ -62,7 +62,7 @@ use {$this->full_model_name};
use Tests\BrowserKitTest as TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class Manage{$this->plural_model_name}Test extends TestCase
class Manage{$this->model_name}Test extends TestCase
{
use DatabaseMigrations;
@ -144,7 +144,7 @@ class Manage{$this->plural_model_name}Test extends TestCase
}
}
";
$this->assertEquals($modelClassContent, file_get_contents(base_path("tests/Feature/Manage{$this->plural_model_name}Test.php")));
$this->assertEquals($modelClassContent, file_get_contents(base_path("tests/Feature/Manage{$this->model_name}Test.php")));
}
/** @test */
@ -203,7 +203,7 @@ abstract class {$baseTestClass} extends BaseTestCase
$this->artisan('make:crud-simple', ['name' => $this->model_name, '--no-interaction' => true]);
$this->assertFileExists(base_path("tests/Feature/Manage{$this->plural_model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$this->model_name}Test.php"));
$modelClassContent = "<?php
namespace Tests\Feature;
@ -212,7 +212,7 @@ use {$this->full_model_name};
use Tests\TestCase as TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class Manage{$this->plural_model_name}Test extends TestCase
class Manage{$this->model_name}Test extends TestCase
{
use DatabaseMigrations;
@ -294,6 +294,6 @@ class Manage{$this->plural_model_name}Test extends TestCase
}
}
";
$this->assertEquals($modelClassContent, file_get_contents(base_path("tests/Feature/Manage{$this->plural_model_name}Test.php")));
$this->assertEquals($modelClassContent, file_get_contents(base_path("tests/Feature/Manage{$this->model_name}Test.php")));
}
}
Loading…
Cancel
Save