8 changed files with 105 additions and 54 deletions
-
30app/User.php
-
0artisan
-
20database/factories/ModelFactory.php
-
15database/migrations/2014_10_12_000000_create_users_table.php
-
2phpunit.xml
-
23tests/Feature/ExampleTest.php
-
20tests/Unit/ExampleTest.php
-
49tests/Unit/PersonRelationsTest.php
@ -1,23 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace Tests\Feature; |
|||
|
|||
use Tests\TestCase; |
|||
use Illuminate\Foundation\Testing\WithoutMiddleware; |
|||
use Illuminate\Foundation\Testing\DatabaseMigrations; |
|||
use Illuminate\Foundation\Testing\DatabaseTransactions; |
|||
|
|||
class ExampleTest extends TestCase |
|||
{ |
|||
/** |
|||
* A basic test example. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function testBasicTest() |
|||
{ |
|||
$response = $this->get('/'); |
|||
|
|||
$response->assertStatus(200); |
|||
} |
|||
} |
|||
@ -1,20 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace Tests\Unit; |
|||
|
|||
use Tests\TestCase; |
|||
use Illuminate\Foundation\Testing\DatabaseMigrations; |
|||
use Illuminate\Foundation\Testing\DatabaseTransactions; |
|||
|
|||
class ExampleTest extends TestCase |
|||
{ |
|||
/** |
|||
* A basic test example. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function testBasicTest() |
|||
{ |
|||
$this->assertTrue(true); |
|||
} |
|||
} |
|||
@ -0,0 +1,49 @@ |
|||
<?php |
|||
|
|||
namespace Tests\Unit; |
|||
|
|||
use App\User; |
|||
use Illuminate\Foundation\Testing\DatabaseMigrations; |
|||
use Tests\TestCase; |
|||
|
|||
class PersonRelationsTest extends TestCase |
|||
{ |
|||
use DatabaseMigrations; |
|||
|
|||
/** @test */ |
|||
public function create_user_model_with_factory() |
|||
{ |
|||
$person = factory(User::class)->create(); |
|||
|
|||
$this->assertDatabaseHas('users', [ |
|||
'nickname' => $person->nickname, |
|||
'gender_id' => $person->gender_id, |
|||
]); |
|||
} |
|||
|
|||
/** @test */ |
|||
public function person_can_have_a_father() |
|||
{ |
|||
$person = factory(User::class)->create(); |
|||
$father = factory(User::class)->states('male')->create(); |
|||
$person->setFather($father); |
|||
|
|||
$this->assertDatabaseHas('users', [ |
|||
'id' => $person->id, |
|||
'father_id' => $father->id, |
|||
]); |
|||
} |
|||
|
|||
/** @test */ |
|||
public function person_can_have_a_mother() |
|||
{ |
|||
$person = factory(User::class)->create(); |
|||
$mother = factory(User::class)->states('female')->create(); |
|||
$person->setMother($mother); |
|||
|
|||
$this->assertDatabaseHas('users', [ |
|||
'id' => $person->id, |
|||
'mother_id' => $mother->id, |
|||
]); |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue