Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. <?php
  2. namespace Tests\Unit;
  3.  
  4. use App\Phone;
  5. use App\User;
  6. use Illuminate\Foundation\Testing\RefreshDatabase;
  7. use Illuminate\Foundation\Testing\WithFaker;
  8. use Illuminate\Support\Facades\Schema;
  9. use Tests\TestCase;
  10.  
  11. class UserTest extends TestCase
  12. {
  13. use RefreshDatabase, WithFaker;
  14.  
  15. /** @test */
  16. public function a_user_has_a_phone()
  17. {
  18. $user = factory(User::class)->create();
  19. $phone = factory(Phone::class)->create(['user_id' => $user->id]);
  20.  
  21. // Method 1:
  22. $this->assertInstanceOf(Phone::class, $user->phone);
  23.  
  24. // Method 2:
  25. $this->assertEquals(1, $user->phone->count());
  26. }
  27. }
  28.  
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement