Browse Source

Fixed unit test generator

tags/0.1.0
Nafies Luthfi 8 years ago
parent
commit
0922923b35
  1. 14
      src/CrudMake.php
  2. 1
      src/stubs/unit-test.stub
  3. 3
      tests/CrudMakeCommandTest.php

14
src/CrudMake.php

@ -137,7 +137,8 @@ class CrudMake extends Command
public function getUnitTestContent()
{
return $this->files->get(__DIR__.'/stubs/unit-test.stub');
$stub = $this->files->get(__DIR__.'/stubs/unit-test.stub');
return $this->replaceUnitTestDummyStrings($stub)->replaceClass($stub);
}
protected function makeDirectory($path)
@ -171,6 +172,17 @@ class CrudMake extends Command
return $this;
}
protected function replaceUnitTestDummyStrings(&$stub)
{
$stub = str_replace(
['DummyClass'],
[$this->modelName.'Test'],
$stub
);
return $this;
}
protected function replaceClass($stub)
{
$class = str_plural($this->modelName);

1
src/stubs/unit-test.stub

@ -4,7 +4,6 @@ namespace DummyNamespace;
use Tests\TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class DummyClass extends TestCase
{

3
tests/CrudMakeCommandTest.php

@ -187,9 +187,8 @@ namespace DummyNamespace;
use Tests\TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class DummyClass extends TestCase
class ItemTest extends TestCase
{
/**
* A basic test example.

Loading…
Cancel
Save