UserIncrementPostCountWhenForumPostPostedTest.php 1.22 KB
<?php

namespace FootyRoom\Tests\Integration\User;

use FootyRoom\Core\ForumPost\ForumPostPosted;
use FootyRoom\Core\ForumPost\ForumPost;
use FootyRoom\Core\User\IncrementPostCountWhenForumPostPosted;
use FootyRoom\Repositories\UserRepository;
use FootyRoom\Tests\TestCase;

class UserIncrementPostCountWhenForumPostPostedTest extends TestCase
{
    public function setup()
    {
        $this->mockUserRepository = $this->getMockBuilder(UserRepository::class)
                            ->disableOriginalConstructor()
                            ->getMock();

        $this->incrementPostCountWhenForumPostPosted = new IncrementPostCountWhenForumPostPosted(
            $this->mockUserRepository
        );
    }

    public function testIncrementPostCountWasCalled()
    {
        $title = 'title';
        $newCategoryId = 61;
        $userId = 41301;

        $forumPost = new ForumPost(
            $title,
            $newCategoryId,
            $userId
        );

        $forumPostPosted = new ForumPostPosted($forumPost);

        $this->mockUserRepository->expects($this->once())
                                 ->method('incrementPostCount');

        $this->incrementPostCountWhenForumPostPosted->handle($forumPostPosted);
    }
}