From 054998254c3aea5b48583423bc8b4b71a1bb98a0 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Sun, 24 Sep 2017 11:31:13 +0800 Subject: [PATCH] Add a model test --- src/stubs/test-unit.stub | 10 +++++++++- tests/Generators/ModelTestGeneratorTest.php | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/stubs/test-unit.stub b/src/stubs/test-unit.stub index 92acc25..073c62c 100644 --- a/src/stubs/test-unit.stub +++ b/src/stubs/test-unit.stub @@ -2,10 +2,18 @@ namespace Tests\Unit\Models; -use Tests\TestCase; +use App\Master; use Illuminate\Foundation\Testing\DatabaseMigrations; +use Tests\TestCase; class MasterTest extends TestCase { use DatabaseMigrations; + + /** @test */ + public function it_has_name_attribute() + { + $item = factory(Master::class)->create(['name' => 'Master 1 name']); + $this->assertEquals('Master 1 name', $item->name); + } } diff --git a/tests/Generators/ModelTestGeneratorTest.php b/tests/Generators/ModelTestGeneratorTest.php index a2bf07d..91476d4 100644 --- a/tests/Generators/ModelTestGeneratorTest.php +++ b/tests/Generators/ModelTestGeneratorTest.php @@ -16,12 +16,20 @@ class ModelTestGeneratorTest extends TestCase namespace Tests\Unit\Models; -use Tests\TestCase; +use App\Item; use Illuminate\Foundation\Testing\DatabaseMigrations; +use Tests\TestCase; class ItemTest extends TestCase { use DatabaseMigrations; + + /** @test */ + public function it_has_name_attribute() + { + \$item = factory(Item::class)->create(['name' => 'Item 1 name']); + \$this->assertEquals('Item 1 name', \$item->name); + } } "; $this->assertEquals($modelClassContent, file_get_contents(base_path("tests/Unit/Models/{$this->modelName}Test.php")));