NoSpoilerSetTest.php 1.04 KB
<?php

namespace FootyRoom\Tests;

use FootyRoom\Support\MongoClient;

class NoSpoilerSetTest extends TestCase
{
    use SetsUpFixtures;

    public function setup()
    {
        parent::setup();

        $this->mongoDb = $this->app->make(MongoClient::class)->footyroom;
    }

    public function testSuccessNoSpoilerSetShouldSeeDataInDatabase()
    {
        $user = factory('FootyRoom\User\User')->make(['user_id' => 1]);

        $response = $this->actingAs($user)->json('POST', '/profile/settings/no-spoilers', ['enabled' => true]);
        $this->assertEquals(200, $response->status());

        $dbUser = $this->mongoDb->selectCollection('users')->findOne(['userId' => 1]);
        $this->assertEquals(true, $dbUser->noSpoilers);

        $response = $this->actingAs($user)->json('POST', '/profile/settings/no-spoilers', ['enabled' => false]);
        $this->assertEquals(200, $response->status());

        $dbUser = $this->mongoDb->selectCollection('users')->findOne(['userId' => 1]);
        $this->assertEquals(false, $dbUser->noSpoilers);
    }
}