ViewForumTest.php 1.5 KB
<?php

namespace FootyRoom\Tests;

class ViewForumTest extends TestCase
{
    use SetsUpFixtures;

    public function testGuessUserCanVisitForumAndSeeLoginButton()
    {
        $response = $this->call('GET', '/forum');
        $this->assertEquals(200, $response->status());
        $this->assertContains('Log In', $response->getContent());
        $this->assertContains('to start discussion', $response->getContent());
        $this->assertNotContains('New Discussion', $response->getContent());
        $this->assertNotContains('With Me', $response->getContent());
        $this->assertNotContains('My Threads', $response->getContent());
    }

    public function testLoggedInUserCanVisitForumAndSeeNewDiscussionButton()
    {
        $user = factory('FootyRoom\User\User')->make();
        $response = $this->actingAs($user)->call('GET', '/forum');
        $this->assertEquals(200, $response->status());
        $this->assertNotContains('Log In', $response->getContent());
        $this->assertNotContains('to start discussion', $response->getContent());
        $this->assertContains('New Discussion', $response->getContent());
        $this->assertContains('With Me', $response->getContent());
        $this->assertContains('My Threads', $response->getContent());
    }

    public function testUserSeeExistingDiscussionPost()
    {
        $response = $this->call('GET', '/forum');
        $this->assertEquals(200, $response->status());
        $this->assertContains('my discussion title', $response->getContent());
    }
}