Browse Source

Set proper model names for namespaced model name entry

tags/0.1.0
Nafies Luthfi 8 years ago
parent
commit
c2476026fc
  1. 2
      src/CrudMake.php
  2. 16
      tests/CrudMakeCommandTest.php
  3. 2
      tests/TestCase.php

2
src/CrudMake.php

@ -96,7 +96,7 @@ class CrudMake extends Command
public function getModelName($modelName = null)
{
$modelName = is_null($modelName) ? $this->argument('name') : $modelName;
$model_name = ucfirst($modelName);
$model_name = ucfirst(class_basename($modelName));
$plural_model_name = str_plural($model_name);
return $this->modelNames = [

16
tests/CrudMakeCommandTest.php

@ -40,6 +40,22 @@ class CrudMakeCommandTest extends TestCase
}
/** @test */
public function it_set_proper_model_names_property_for_namespaced_model_name_entry()
{
$crudMaker = app(CrudMake::class);
$this->assertEquals([
'full_model_name' => 'App\Category',
'plural_model_name' => 'Categories',
'model_name' => 'Category',
'table_name' => 'categories',
'lang_name' => 'category',
'collection_model_var_name' => 'categories',
'single_model_var_name' => 'category',
], $crudMaker->getModelName('References/Category'));
}
/** @test */
public function it_can_generate_simple_crud_files()
{
$this->artisan('make:crud', ['name' => $this->model_name, '--no-interaction' => true]);

2
tests/TestCase.php

@ -17,7 +17,7 @@ abstract class TestCase extends BaseTestCase
public function setUp()
{
parent::setUp();
$this->model_name = 'PaymentMethod';
$this->model_name = class_basename('References/Category');
$this->full_model_name = 'App\\'.$this->model_name;
$this->plural_model_name = str_plural($this->model_name);

Loading…
Cancel
Save