NewBornCreateDiscussionWithLinkTest.php 1.42 KB
<?php

namespace FootyRoom\Tests;

class NewBornCreateDiscussionWithLinkTest extends TestCase
{
    use SetsUpFixtures;

    public function testNewBornUserShouldNotBeAllowedToCreateDiscussionWithLinkInContent()
    {
        $faker = \Faker\Factory::create();

        $data = [
            'title' => $faker->sentence(),
            'content' => $faker->paragraph().'http://google.com',
            'category' => 53,
        ];

        $user = factory('FootyRoom\User\User')->make(['user_id' => 1]);
        $response = $this->actingAs($user)->call('POST', '/forum/discussions', $data);
        $this->assertEquals(201, $response->status());

        $user = factory('FootyRoom\User\User')->make(['user_id' => 2]);
        $response = $this->actingAs($user)->call('POST', '/forum/discussions', $data);
        $this->assertEquals(500, $response->status());
        $this->assertContains('New users are not allowed to post links.', $response->getContent());

        $data = [
            'title' => $faker->sentence(),
            'content' => $faker->paragraph().'https://google.com',
            'category' => 53,
        ];

        $user = factory('FootyRoom\User\User')->make(['user_id' => 2]);
        $response = $this->actingAs($user)->call('POST', '/forum/discussions', $data);
        $this->assertEquals(500, $response->status());
        $this->assertContains('New users are not allowed to post links.', $response->getContent());
    }
}