SubscribeToPostWhenCommentPostedInForumTest.php
2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
namespace FootyRoom\Tests\Integration\Subscription;
use FootyRoom\Core\Comment\Author;
use FootyRoom\Core\Comment\Comment;
use FootyRoom\Core\ForumPost\ForumPost;
use FootyRoom\Core\ForumPost\ForumPostCommentPosted;
use FootyRoom\Core\Subscription\SubscribeToPostWhenCommentPostedInForum;
use FootyRoom\Queries\Subscription\SubscriptionQueryHandler;
use FootyRoom\Repositories\SubscriptionRepository;
use FootyRoom\Tests\TestCase;
class SubscribeToPostWhenCommentPostedInForumTest extends TestCase
{
public function setup()
{
$this->mockSubscriptionRepository = $this->getMockBuilder(SubscriptionRepository::class)
->disableOriginalConstructor()
->getMock();
$this->mockSubscriptionQueryHandler = $this->getMockBuilder(SubscriptionQueryHandler::class)
->disableOriginalConstructor()
->getMock();
$this->subscribeToPostWhenCommentPostedInForum = new SubscribeToPostWhenCommentPostedInForum(
$this->mockSubscriptionRepository,
$this->mockSubscriptionQueryHandler
);
}
public function testCreateSubscriptionWillNotBeCalledIfAlreadyHaveSubscription()
{
$discussionId = 'forumPost:1';
$author = new Author(41301, 'chanBC');
$content = 'test content';
$html = '';
$comment = new Comment(
$discussionId,
$author,
$content,
$html
);
$title = 'title';
$categoryId = 61;
$userId = 41301;
$post = new ForumPost(
$title,
$categoryId,
$userId
);
$commentPosted = new ForumPostCommentPosted($comment, $post);
$this->mockSubscriptionQueryHandler->method('findOne')
->will($this->returnValue(true));
$this->mockSubscriptionRepository->expects($this->never())
->method('create');
$this->subscribeToPostWhenCommentPostedInForum->handle($commentPosted);
}
}