Browse Source

Add model custom stub for model creation and fix invalid BaseTestCase

tags/0.1.0
Nafies Luthfi 8 years ago
parent
commit
0be486ebe9
  1. 8
      src/CrudMake.php
  2. 10
      src/stubs/model.stub
  3. 2
      src/stubs/test-browserkit-base-class.stub
  4. 2
      src/stubs/test-feature.stub
  5. 4
      tests/Generators/FeatureTestGeneratorTest.php
  6. 2
      tests/Generators/ModelGeneratorTest.php

8
src/CrudMake.php

@ -67,7 +67,7 @@ class CrudMake extends Command
public function generateModel()
{
$this->callSilent('make:model', ['name' => $this->modelName]);;
$this->files->put(app_path($this->modelName.'.php'), $this->getModelContent());
$this->info($this->modelName.' model generated.');
}
@ -160,6 +160,12 @@ class CrudMake extends Command
return $this->replaceStubString($stub);
}
public function getModelContent()
{
$stub = $this->files->get(__DIR__.'/stubs/model.stub');
return $this->replaceStubString($stub);
}
private function getMigrationContent()
{
$stub = $this->files->get(__DIR__.'/stubs/migration-create.stub');

10
src/stubs/model.stub

@ -0,0 +1,10 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Master extends Model
{
protected $fillable = ['name', 'description'];
}

2
src/stubs/test-browserkit-base-class.stub

@ -5,7 +5,7 @@ namespace Tests;
use App\User;
use Laravel\BrowserKitTesting\TestCase as BaseTestCase;
abstract class BrowserKitTestCase extends BaseTestCase
abstract class BrowserKitTest extends BaseTestCase
{
use CreatesApplication;

2
src/stubs/test-feature.stub

@ -3,7 +3,7 @@
namespace Tests\Feature;
use App\Master;
use Tests\BrowserKitTestCase as TestCase;
use Tests\BrowserKitTest as TestCase;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Illuminate\Foundation\Testing\DatabaseMigrations;

4
tests/Generators/FeatureTestGeneratorTest.php

@ -19,7 +19,7 @@ namespace Tests;
use App\User;
use Laravel\BrowserKitTesting\TestCase as BaseTestCase;
abstract class BrowserKitTestCase extends BaseTestCase
abstract class BrowserKitTest extends BaseTestCase
{
use CreatesApplication;
@ -48,7 +48,7 @@ abstract class BrowserKitTestCase extends BaseTestCase
namespace Tests\Feature;
use App\Item;
use Tests\BrowserKitTestCase as TestCase;
use Tests\BrowserKitTest as TestCase;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Illuminate\Foundation\Testing\DatabaseMigrations;

2
tests/Generators/ModelGeneratorTest.php

@ -21,7 +21,7 @@ use Illuminate\Database\Eloquent\Model;
class Item extends Model
{
//
protected \$fillable = ['name', 'description'];
}
";
$this->assertEquals($modelClassContent, file_get_contents($modelPath));

Loading…
Cancel
Save