1 | <?php |
||
24 | class ShowThreadControllerTest extends \PHPUnit_Framework_TestCase |
||
25 | { |
||
26 | /** |
||
27 | * The class under test |
||
28 | * @var ShowThreadController |
||
29 | */ |
||
30 | private $controller; |
||
31 | |||
32 | /** |
||
33 | * @var \PHPUnit_Framework_MockObject_MockObject |
||
34 | */ |
||
35 | private $participantProvider; |
||
36 | |||
37 | /** |
||
38 | * @var \PHPUnit_Framework_MockObject_MockObject |
||
39 | */ |
||
40 | private $templating; |
||
41 | |||
42 | |||
43 | /** |
||
44 | * @var \PHPUnit_Framework_MockObject_MockObject |
||
45 | */ |
||
46 | private $threadProvider; |
||
47 | |||
48 | /** |
||
49 | * @var ParticipantInterface |
||
50 | */ |
||
51 | private $loggedInUser; |
||
52 | |||
53 | /** |
||
54 | * @var \PHPUnit_Framework_MockObject_MockObject |
||
55 | */ |
||
56 | private $thread; |
||
57 | |||
58 | /** |
||
59 | * @var \PHPUnit_Framework_MockObject_MockObject |
||
60 | */ |
||
61 | private $formFactory; |
||
62 | |||
63 | /** |
||
64 | * @var \PHPUnit_Framework_MockObject_MockObject |
||
65 | */ |
||
66 | private $formHandler; |
||
67 | |||
68 | /** |
||
69 | * @var \PHPUnit_Framework_MockObject_MockObject |
||
70 | */ |
||
71 | private $form; |
||
72 | |||
73 | /** |
||
74 | * @var \PHPUnit_Framework_MockObject_MockObject |
||
75 | */ |
||
76 | private $formView; |
||
77 | |||
78 | /** |
||
79 | * @var \PHPUnit_Framework_MockObject_MockObject |
||
80 | */ |
||
81 | private $readStatusManager; |
||
82 | |||
83 | /** |
||
84 | * @var \PHPUnit_Framework_MockObject_MockObject |
||
85 | */ |
||
86 | private $message; |
||
87 | |||
88 | /** |
||
89 | * @var \PHPUnit_Framework_MockObject_MockObject |
||
90 | */ |
||
91 | private $arrayCollection; |
||
92 | |||
93 | /** |
||
94 | * @var \PHPUnit_Framework_MockObject_MockObject |
||
95 | */ |
||
96 | private $router; |
||
97 | |||
98 | |||
99 | public function setUp() |
||
122 | |||
123 | /** |
||
124 | * @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException |
||
125 | * @expectedExceptionMessage Thread not found |
||
126 | */ |
||
127 | public function testShowActionThreadNotFoundThrowsException() |
||
137 | |||
138 | public function testShowActionReturnsResponseWhenFormNotProcessed() |
||
151 | |||
152 | public function testShowActionRedirectsResponseWhenFormProcessed() |
||
153 | { |
||
154 | $this->expectsUser(); |
||
155 | $this->expectsThread(); |
||
156 | $this->expectsFormFactoryCreatesForm(); |
||
157 | $this->expectsFormHandlerProcessesFormAndReturnsTrue(); |
||
158 | $this->router->expects($this->once())->method('generate') |
||
159 | ->with('miliooo_message_thread_view', ['threadId' => 1]) |
||
160 | ->will($this->returnValue('http://test.com')); |
||
161 | |||
162 | $this->controller->showAction(1); |
||
163 | } |
||
164 | |||
165 | protected function expectsFormFactoryCreatesForm() |
||
166 | { |
||
167 | $this->formFactory->expects($this->once()) |
||
168 | ->method('create') |
||
169 | ->with($this->thread, $this->loggedInUser) |
||
170 | ->will($this->returnValue($this->form)); |
||
171 | } |
||
172 | |||
173 | protected function expectsFormHandlerProcessesFormAndReturnsFalse() |
||
179 | |||
180 | protected function expectsFormHandlerProcessesFormAndReturnsTrue() |
||
187 | |||
188 | protected function expectsFormCreatesAView() |
||
189 | { |
||
190 | $this->form->expects($this->once()) |
||
191 | ->method('createView') |
||
192 | ->will($this->returnValue($this->formView)); |
||
193 | } |
||
194 | |||
195 | protected function expectsTemplatingRendersResponse() |
||
201 | |||
202 | protected function setConstructorMocks() |
||
216 | |||
217 | protected function expectsUser() |
||
218 | { |
||
219 | $this->participantProvider->expects($this->once()) |
||
222 | |||
223 | protected function expectsThread() |
||
230 | |||
231 | protected function expectsReadStatusUpdates() |
||
245 | } |
||
246 |