Browse Source

Adopt laravel 8.x model factory directory structure

pull/40/head
Nafies Luthfi 5 years ago
parent
commit
5b3884162a
  1. 6
      src/Generators/ModelFactoryGenerator.php
  2. 4
      tests/CrudApiMakeCommandTest.php
  3. 4
      tests/CrudMakeCommandTest.php
  4. 4
      tests/CrudSimpleMakeCommandTest.php

6
src/Generators/ModelFactoryGenerator.php

@ -12,7 +12,11 @@ class ModelFactoryGenerator extends BaseGenerator
*/
public function generate(string $type = 'full')
{
$modelFactoryPath = $this->makeDirectory(database_path('factories'));
$modelFactoryPath = database_path('factories');
if ($this->modelNames['model_path'] != 'Models') {
$modelFactoryPath .= '/'.$this->modelNames['model_path'];
}
$modelFactoryPath = $this->makeDirectory($modelFactoryPath);
$modelFactoryClassPath = $modelFactoryPath.'/'.$this->modelNames['model_name'].'Factory.php';
if ($this->files->exists($modelFactoryClassPath)) {

4
tests/CrudApiMakeCommandTest.php

@ -115,7 +115,7 @@ class CrudApiMakeCommandTest extends TestCase
$this->assertFileExists(resource_path("lang/{$localeConfig}/{$langName}.php"));
$this->assertFileExists(app_path("Policies/{$modelName}Policy.php"));
$this->assertFileExists(database_path("factories/{$modelName}Factory.php"));
$this->assertFileExists(database_path("factories/{$inputName}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"));
@ -148,7 +148,7 @@ class CrudApiMakeCommandTest extends TestCase
$localeConfig = config('app.locale');
$this->assertFileExists(resource_path("lang/{$localeConfig}/{$langName}.php"));
$this->assertFileExists(database_path("factories/{$modelName}Factory.php"));
$this->assertFileExists(database_path("factories/{$inputName}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"));

4
tests/CrudMakeCommandTest.php

@ -128,7 +128,7 @@ class CrudMakeCommandTest extends TestCase
$this->assertFileExists(resource_path("lang/{$localeConfig}/{$langName}.php"));
$this->assertFileExists(app_path("Policies/{$modelName}Policy.php"));
$this->assertFileExists(database_path("factories/{$modelName}Factory.php"));
$this->assertFileExists(database_path("factories/{$inputName}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"));
@ -163,7 +163,7 @@ class CrudMakeCommandTest extends TestCase
$localeConfig = config('app.locale');
$this->assertFileExists(resource_path("lang/{$localeConfig}/{$langName}.php"));
$this->assertFileExists(database_path("factories/{$modelName}Factory.php"));
$this->assertFileExists(database_path("factories/{$inputName}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"));

4
tests/CrudSimpleMakeCommandTest.php

@ -121,7 +121,7 @@ class CrudSimpleMakeCommandTest extends TestCase
$this->assertFileExists(resource_path("lang/{$localeConfig}/{$langName}.php"));
$this->assertFileExists(app_path("Policies/{$modelName}Policy.php"));
$this->assertFileExists(database_path("factories/{$modelName}Factory.php"));
$this->assertFileExists(database_path("factories/{$inputName}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"));
@ -154,7 +154,7 @@ class CrudSimpleMakeCommandTest extends TestCase
$localeConfig = config('app.locale');
$this->assertFileExists(resource_path("lang/{$localeConfig}/{$langName}.php"));
$this->assertFileExists(database_path("factories/{$modelName}Factory.php"));
$this->assertFileExists(database_path("factories/{$inputName}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"));

Loading…
Cancel
Save