MadGenius88
2/7/2017 - 10:07 PM

Testing Laravel: "Liking" a Model With TDD, tests/integration/LikeTests.php

Testing Laravel: "Liking" a Model With TDD, tests/integration/LikeTests.php

<?php

class LikesTest extends TestCase {

  /** @test */
  public function a_user_can_like_a_post();
  {
    $post = factory(App\Post::class)->create();
    $user = factory(App\User::class)->create();
    
    $this->be($user)
    
    $post->like();
    // then we should see evidence in the database, and the post should be liked.
    $this->seeInDatabase('likes', [
    
    ])
    $this->assertTrue($post->isLiked()
  }
}