UnnotifyWhenCommentRemovedTest.php 1.34 KB
<?php

namespace FootyRoom\Tests\Integration\Notification;

use FootyRoom\Core\Comment\Author;
use FootyRoom\Core\Comment\Comment;
use FootyRoom\Core\Comment\CommentRemoved;
use FootyRoom\Core\Notification\UnnotifyWhenCommentRemoved;
use FootyRoom\Support\SqlCommentNotifier;
use FootyRoom\Tests\TestCase;

class UnnotifyWhenCommentRemovedTest extends TestCase
{
    public function setUp()
    {
        $this->mockSqlCommentNotifier = $this->getMockBuilder(SqlCommentNotifier::class)
                            ->disableOriginalConstructor()
                            ->setMethods([
                                'unnotify',
                                ])
                            ->getMock();

        $this->unnotifyWhenCommentRemoved = new UnnotifyWhenCommentRemoved($this->mockSqlCommentNotifier);
    }

    public function testUnnotifyWasCalled()
    {
        $postId = 1;
        $author = new Author(41301, 'chanBC');
        $content = 'test content';
        $html = '';

        $comment = new Comment(
            $postId,
            $author,
            $content,
            $html
        );

        $commentRemoved = new CommentRemoved($comment);

        $this->mockSqlCommentNotifier->expects($this->once())
                                    ->method('unnotify');

        $this->unnotifyWhenCommentRemoved->handle($commentRemoved);
    }
}