Browse Source

Fix it detects namespaced model existance

tags/0.1.0
Nafies Luthfi 8 years ago
parent
commit
a00f91359f
  1. 2
      src/CrudMake.php
  2. 27
      tests/CrudMakeCommandTest.php

2
src/CrudMake.php

@ -163,6 +163,6 @@ class CrudMake extends Command
*/
public function modelExists()
{
return $this->files->exists(app_path($this->modelNames['model_name'].'.php'));
return $this->files->exists(app_path($this->modelNames['model_path'].'/'.$this->modelNames['model_name'].'.php'));
}
}

27
tests/CrudMakeCommandTest.php

@ -54,6 +54,33 @@ class CrudMakeCommandTest extends TestCase
}
/** @test */
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->assertRegExp("/Problem model already exists./", app(Kernel::class)->output());
$this->assertFileExists(app_path('Entities/Projects/Problem.php'));
$this->assertFileNotExists(app_path("Http/Controllers/ProblemsController.php"));
$migrationFilePath = database_path('migrations/'.date('Y_m_d_His').'_create_problems_table.php');
$this->assertFileNotExists($migrationFilePath);
$this->assertFileNotExists(resource_path("views/problems/index.blade.php"));
$this->assertFileNotExists(resource_path("views/problems/forms.blade.php"));
$this->assertFileNotExists(resource_path("lang/en/problem.php"));
$this->assertFileNotExists(database_path("factories/ProblemFactory.php"));
$this->assertFileNotExists(app_path("Policies/ProblemPolicy.php"));
$this->assertFileNotExists(base_path("tests/Feature/ManageProblemsTest.php"));
$this->assertFileNotExists(base_path("tests/Unit/Models/ProblemTest.php"));
$this->removeFileOrDir(app_path('Entities/Projects'));
$this->removeFileOrDir(resource_path('views/problems'));
$this->removeFileOrDir(resource_path("lang/en/problem.php"));
}
/** @test */
public function it_can_generate_crud_files_for_namespaced_model()
{
$inputName = 'Entities/References/Category';

Loading…
Cancel
Save