|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the MilioooMessageBundle package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Michiel boeckaert <[email protected]> |
|
7
|
|
|
* This source file is subject to the MIT license that is bundled |
|
8
|
|
|
* with this source code in the file LICENSE. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace Miliooo\Messaging\Tests\Form\FormModelProcessor; |
|
12
|
|
|
|
|
13
|
|
|
use Miliooo\Messaging\Form\FormModelProcessor\NewReplyDefaultProcessor; |
|
14
|
|
|
use Miliooo\Messaging\TestHelpers\ParticipantTestHelper; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Test file for Miliooo\Messaging\Form\FormModelProcessor\NewReplyDefaultProcessor. |
|
18
|
|
|
* |
|
19
|
|
|
* @author Michiel Boeckaert <[email protected]> |
|
20
|
|
|
*/ |
|
21
|
|
|
class NewReplyDefaultProcessorTest extends \PHPUnit_Framework_TestCase |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* The class under test |
|
25
|
|
|
* |
|
26
|
|
|
* @var NewSingleThreadDefaultProcesser |
|
27
|
|
|
*/ |
|
28
|
|
|
private $processor; |
|
29
|
|
|
private $replyBuilder; |
|
30
|
|
|
private $newMessageManager; |
|
31
|
|
|
private $replyMessageModel; |
|
32
|
|
|
|
|
33
|
|
|
public function setUp() |
|
34
|
|
|
{ |
|
35
|
|
|
$this->replyBuilder = $this->getMockBuilder('Miliooo\Messaging\Builder\Message\ReplyBuilder') |
|
36
|
|
|
->disableOriginalConstructor()->getMock(); |
|
37
|
|
|
$this->newMessageManager = $this->getMock('Miliooo\Messaging\Manager\NewMessageManagerInterface'); |
|
38
|
|
|
$this->replyMessageModel = $this->getMock('Miliooo\Messaging\Form\FormModel\ReplyMessageInterface'); |
|
39
|
|
|
$this->processor = new NewReplyDefaultProcessor($this->replyBuilder, $this->newMessageManager); |
|
|
|
|
|
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function testInterface() |
|
43
|
|
|
{ |
|
44
|
|
|
$this->assertInstanceOf('Miliooo\Messaging\Form\FormModelProcessor\NewReplyFormProcessorInterface', $this->processor); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function testProcess() |
|
48
|
|
|
{ |
|
49
|
|
|
$newThread = $this->expectsNewThreadCreated(); |
|
50
|
|
|
$this->expectsNewMessageManagerCall($newThread); |
|
51
|
|
|
$this->processor->process($this->replyMessageModel); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
|
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Expects creation of thread by replybuilder. |
|
58
|
|
|
* |
|
59
|
|
|
* @return ThreadInterface |
|
60
|
|
|
*/ |
|
61
|
|
|
protected function expectsNewThreadCreated() |
|
62
|
|
|
{ |
|
63
|
|
|
$newThread = $this->getMock('Miliooo\Messaging\Model\ThreadInterface'); |
|
64
|
|
|
$this->replyBuilder->expects($this->once())->method('build')->will($this->returnValue($newThread)); |
|
65
|
|
|
|
|
66
|
|
|
return $newThread; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* Expects saveNewReplyCall with right argument. |
|
71
|
|
|
* |
|
72
|
|
|
* @param ThreadInterface $newThread |
|
73
|
|
|
*/ |
|
74
|
|
|
protected function expectsNewMessageManagerCall($newThread) |
|
75
|
|
|
{ |
|
76
|
|
|
$message = $this->getMock('Miliooo\Messaging\Model\MessageInterface'); |
|
77
|
|
|
$newThread->expects($this->once())->method('getLastMessage')->will($this->returnValue($message)); |
|
78
|
|
|
$this->newMessageManager->expects($this->once())->method('saveNewReply')->with($message); |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..