Completed
Push — master ( d5d314...f81167 )
by Aimeos
01:21
created

CatalogControllerTest::treeAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
4
namespace Aimeos\Shop\Tests\Unit\Controller;
5
6
7
class CatalogControllerTest extends \Neos\Flow\Tests\UnitTestCase
8
{
9
	private $object;
10
	private $response;
11
	private $view;
12
13
14
	public function setUp()
15
	{
16
		$this->object = $this->getMockBuilder( '\Aimeos\Shop\Controller\CatalogController' )
17
			->setMethods( array( 'getOutput', 'getSections' ) )
18
			->disableOriginalConstructor()
19
			->getMock();
20
21
		$this->view = $this->getMockBuilder( '\Neos\Flow\Mvc\View\JsonView' )
22
			->disableOriginalConstructor()
23
			->getMock();
24
25
		$this->response = $this->getMockBuilder( '\Neos\Flow\Http\Response' )
26
			->disableOriginalConstructor()
27
			->getMock();
28
29
		$this->inject( $this->object, 'view', $this->view );
30
		$this->inject( $this->object, 'response', $this->response );
31
	}
32
33
34
	/**
35
	 * @test
36
	 */
37
	public function countAction()
38
	{
39
		$expected = array( 'aibody' => 'body', 'aiheader' => 'header' );
40
41
		$this->object->expects( $this->once() )->method( 'getSections' )
42
			->will( $this->returnValue( $expected ) );
43
44
		$this->view->expects( $this->once() )->method( 'assignMultiple' )
45
			->with( $this->equalTo( $expected ) );
46
47
		$this->response->expects( $this->exactly( 2 ) )->method( 'setHeader' );
48
49
		$this->object->countAction();
50
	}
51
52
53
	/**
54
	 * @test
55
	 */
56
	public function detailAction()
57
	{
58
		$expected = array( 'aibody' => 'body', 'aiheader' => 'header' );
59
60
		$this->object->expects( $this->once() )->method( 'getSections' )
61
			->will( $this->returnValue( $expected ) );
62
63
		$this->view->expects( $this->once() )->method( 'assignMultiple' )
64
			->with( $this->equalTo( $expected ) );
65
66
		$this->object->detailAction();
67
	}
68
69
70
	/**
71
	 * @test
72
	 */
73
	public function listAction()
74
	{
75
		$expected = array( 'aibody' => 'body', 'aiheader' => 'header' );
76
77
		$this->object->expects( $this->once() )->method( 'getSections' )
78
			->will( $this->returnValue( $expected ) );
79
80
		$this->view->expects( $this->once() )->method( 'assignMultiple' )
81
			->with( $this->equalTo( $expected ) );
82
83
		$this->object->listAction();
84
	}
85
86
87
	/**
88
	 * @test
89
	 */
90
	public function stockAction()
91
	{
92
		$expected = array( 'aibody' => 'body', 'aiheader' => 'header' );
93
94
		$this->object->expects( $this->once() )->method( 'getSections' )
95
			->will( $this->returnValue( $expected ) );
96
97
		$this->view->expects( $this->once() )->method( 'assignMultiple' )
98
			->with( $this->equalTo( $expected ) );
99
100
		$this->response->expects( $this->exactly( 2 ) )->method( 'setHeader' );
101
102
		$this->object->stockAction();
103
	}
104
105
106
	/**
107
	 * @test
108
	 */
109
	public function suggestAction()
110
	{
111
		$expected = array( 'aibody' => 'body', 'aiheader' => 'header' );
112
113
		$this->object->expects( $this->once() )->method( 'getSections' )
114
			->will( $this->returnValue( $expected ) );
115
116
		$this->view->expects( $this->once() )->method( 'assignMultiple' )
117
			->with( $this->equalTo( $expected ) );
118
119
		$this->response->expects( $this->once() )->method( 'setHeader' );
120
121
		$this->object->suggestAction();
122
	}
123
124
125
	/**
126
	 * @test
127
	 */
128
	public function treeAction()
129
	{
130
		$expected = array( 'aibody' => 'body', 'aiheader' => 'header' );
131
132
		$this->object->expects( $this->once() )->method( 'getSections' )
133
			->will( $this->returnValue( $expected ) );
134
135
		$this->view->expects( $this->once() )->method( 'assignMultiple' )
136
			->with( $this->equalTo( $expected ) );
137
138
		$this->object->treeAction();
139
	}
140
141
142
	/**
143
	 * @test
144
	 */
145
	public function countComponentAction()
146
	{
147
		$this->object->expects( $this->once() )->method( 'getOutput' )
148
			->will( $this->returnValue( 'body' ) );
149
150
		$this->view->expects( $this->once() )->method( 'assign' )
151
			->with( $this->equalTo( 'output' ), $this->equalTo( 'body' ) );
152
153
		$this->response->expects( $this->exactly( 2 ) )->method( 'setHeader' );
154
155
		$this->object->countComponentAction();
156
	}
157
158
159
	/**
160
	 * @test
161
	 */
162
	public function detailComponentAction()
163
	{
164
		$this->object->expects( $this->once() )->method( 'getOutput' )
165
			->will( $this->returnValue( 'body' ) );
166
167
		$this->view->expects( $this->once() )->method( 'assign' )
168
			->with( $this->equalTo( 'output' ), $this->equalTo( 'body' ) );
169
170
		$this->object->detailComponentAction();
171
	}
172
173
174
	/**
175
	 * @test
176
	 */
177
	public function filterComponentAction()
178
	{
179
		$this->object->expects( $this->once() )->method( 'getOutput' )
180
			->will( $this->returnValue( 'body' ) );
181
182
		$this->view->expects( $this->once() )->method( 'assign' )
183
			->with( $this->equalTo( 'output' ), $this->equalTo( 'body' ) );
184
185
		$this->object->filterComponentAction();
186
	}
187
188
189
	/**
190
	 * @test
191
	 */
192
	public function listComponentAction()
193
	{
194
		$this->object->expects( $this->once() )->method( 'getOutput' )
195
			->will( $this->returnValue( 'body' ) );
196
197
		$this->view->expects( $this->once() )->method( 'assign' )
198
			->with( $this->equalTo( 'output' ), $this->equalTo( 'body' ) );
199
200
		$this->object->listComponentAction();
201
	}
202
203
204
	/**
205
	 * @test
206
	 */
207
	public function sessionComponentAction()
208
	{
209
		$this->object->expects( $this->once() )->method( 'getOutput' )
210
			->will( $this->returnValue( 'body' ) );
211
212
		$this->view->expects( $this->once() )->method( 'assign' )
213
			->with( $this->equalTo( 'output' ), $this->equalTo( 'body' ) );
214
215
		$this->object->sessionComponentAction();
216
	}
217
218
219
	/**
220
	 * @test
221
	 */
222
	public function stageComponentAction()
223
	{
224
		$this->object->expects( $this->once() )->method( 'getOutput' )
225
			->will( $this->returnValue( 'body' ) );
226
227
		$this->view->expects( $this->once() )->method( 'assign' )
228
			->with( $this->equalTo( 'output' ), $this->equalTo( 'body' ) );
229
230
		$this->object->stageComponentAction();
231
	}
232
233
234
	/**
235
	 * @test
236
	 */
237
	public function stockComponentAction()
238
	{
239
		$this->object->expects( $this->once() )->method( 'getOutput' )
240
			->will( $this->returnValue( 'body' ) );
241
242
		$this->view->expects( $this->once() )->method( 'assign' )
243
			->with( $this->equalTo( 'output' ), $this->equalTo( 'body' ) );
244
245
		$this->response->expects( $this->exactly( 2 ) )->method( 'setHeader' );
246
247
		$this->object->stockComponentAction();
248
	}
249
250
251
	/**
252
	 * @test
253
	 */
254
	public function suggestComponentAction()
255
	{
256
		$this->object->expects( $this->once() )->method( 'getOutput' )
257
			->will( $this->returnValue( 'body' ) );
258
259
		$this->view->expects( $this->once() )->method( 'assign' )
260
			->with( $this->equalTo( 'output' ), $this->equalTo( 'body' ) );
261
262
		$this->response->expects( $this->once() )->method( 'setHeader' );
263
264
		$this->object->suggestComponentAction();
265
	}
266
}