Browse Source

Fixed feature test generator

tags/0.1.0
Nafies Luthfi 8 years ago
parent
commit
5e9575851a
  1. 14
      src/CrudMake.php
  2. 4
      src/stubs/test.stub
  3. 6
      tests/CrudMakeCommandTest.php

14
src/CrudMake.php

@ -131,7 +131,8 @@ class CrudMake extends Command
public function getFeatureTestContent()
{
return $this->files->get(__DIR__.'/stubs/test.stub');
$stub = $this->files->get(__DIR__.'/stubs/test.stub');
return $this->replaceFeatureTestDummyStrings($stub)->replaceClass($stub);
}
public function getUnitTestContent()
@ -159,6 +160,17 @@ class CrudMake extends Command
return $this;
}
protected function replaceFeatureTestDummyStrings(&$stub)
{
$stub = str_replace(
['DummyClass'],
['Manage'.$this->pluralModelName.'Test'],
$stub
);
return $this;
}
protected function replaceClass($stub)
{
$class = str_plural($this->modelName);

4
src/stubs/test.stub

@ -1,11 +1,9 @@
<?php
namespace DummyNamespace;
namespace Tests\Feature;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class DummyClass extends TestCase
{

6
tests/CrudMakeCommandTest.php

@ -148,14 +148,12 @@ class ItemsController extends Controller
$this->assertFileExists(base_path('tests/Feature/ManageItemsTest.php'));
$modelClassContent = "<?php
namespace DummyNamespace;
namespace Tests\Feature;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class DummyClass extends TestCase
class ManageItemsTest extends TestCase
{
/**
* A basic test example.

Loading…
Cancel
Save