1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Aimeos\ShopBundle\Tests\Controller; |
4
|
|
|
|
5
|
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; |
6
|
|
|
|
7
|
|
|
|
8
|
|
|
class CatalogControllerTest extends WebTestCase |
9
|
|
|
{ |
10
|
|
|
protected function setUp() : void |
11
|
|
|
{ |
12
|
|
|
\Aimeos\MShop::cache( false ); |
13
|
|
|
\Aimeos\Controller\Frontend::cache( false ); |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
|
17
|
|
|
public function testCount() |
18
|
|
|
{ |
19
|
|
|
$client = static::createClient(); |
20
|
|
|
$client->request( 'GET', '/unittest/de/EUR/shop/count' ); |
21
|
|
|
$content = $client->getResponse()->getContent(); |
22
|
|
|
|
23
|
|
|
$this->assertStringContainsString( '".catalog-filter-count li.cat-item"', $content ); |
24
|
|
|
$this->assertStringContainsString( '".catalog-filter-attribute .attribute-lists li.attr-item"', $content ); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
|
28
|
|
|
public function testFilterSearch() |
29
|
|
|
{ |
30
|
|
|
$client = static::createClient(); |
31
|
|
|
$crawler = $client->request( 'GET', '/unittest/de/EUR/shop/' ); |
32
|
|
|
|
33
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-filter-search' )->count() ); |
34
|
|
|
|
35
|
|
|
$form = $crawler->filter( '.catalog-filter-search button' )->form(); |
36
|
|
|
$form['f_search'] = 'Cafe'; |
37
|
|
|
$crawler = $client->submit( $form ); |
38
|
|
|
|
39
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-list-items .product a:contains("Cafe Noire Cappuccino")' )->count() ); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
public function testFilterTree() |
44
|
|
|
{ |
45
|
|
|
$client = static::createClient(); |
46
|
|
|
$crawler = $client->request( 'GET', '/unittest/de/EUR/shop/' ); |
47
|
|
|
|
48
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-filter-tree' )->count() ); |
49
|
|
|
|
50
|
|
|
$link = $crawler->filter( '.catalog-filter-tree a.cat-item' )->link(); |
51
|
|
|
$crawler = $client->click( $link ); |
52
|
|
|
|
53
|
|
|
$link = $crawler->filter( '.catalog-filter-tree .categories a.cat-item' )->link(); |
54
|
|
|
$crawler = $client->click( $link ); |
55
|
|
|
|
56
|
|
|
$link = $crawler->filter( '.catalog-filter-tree .coffee a.cat-item' )->link(); |
57
|
|
|
$crawler = $client->click( $link ); |
58
|
|
|
|
59
|
|
|
$this->assertEquals( 3, $crawler->filter( '.catalog-stage-breadcrumb li' )->count() ); |
60
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-list-items .product a:contains("Cafe Noire Expresso")' )->count() ); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
|
64
|
|
|
public function testFilterAttribute() |
65
|
|
|
{ |
66
|
|
|
$client = static::createClient(); |
67
|
|
|
$crawler = $client->request( 'GET', '/unittest/de/EUR/shop/' ); |
68
|
|
|
|
69
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-filter-attribute' )->count() ); |
70
|
|
|
|
71
|
|
|
$nodes = $crawler->filter( '.catalog-filter-attribute .attr-size span:contains("XS")' ); |
72
|
|
|
$id = $nodes->parents()->filter( '.attr-item' )->attr( 'data-id' ); |
73
|
|
|
|
74
|
|
|
$form = $crawler->filter( '.catalog-filter .btn-primary' )->form(); |
75
|
|
|
$values = $form->getPhpValues(); |
76
|
|
|
$values['f_attrid'] = array( $id ); |
77
|
|
|
$crawler = $client->request( $form->getMethod(), $form->getUri(), $values, $form->getPhpFiles() ); |
78
|
|
|
|
79
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-list-items .product a:contains("Cafe Noire Expresso")' )->count() ); |
80
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-list-items .product a:contains("Cafe Noire Cappuccino")' )->count() ); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
|
84
|
|
|
public function testHome() |
85
|
|
|
{ |
86
|
|
|
$client = static::createClient(); |
87
|
|
|
$client->request( 'GET', '/unittest/de/EUR/' ); |
88
|
|
|
$content = $client->getResponse()->getContent(); |
89
|
|
|
|
90
|
|
|
$this->assertStringContainsString( '"aimeos catalog-home"', $content ); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
|
94
|
|
|
public function testStageBreadcrumb() |
95
|
|
|
{ |
96
|
|
|
$client = static::createClient(); |
97
|
|
|
$crawler = $client->request( 'GET', '/unittest/de/EUR/shop/' ); |
98
|
|
|
|
99
|
|
|
$link = $crawler->filter( '.catalog-list-items .product a:contains("Cafe Noire Expresso")' )->link(); |
100
|
|
|
$crawler = $client->click( $link ); |
101
|
|
|
|
102
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-stage-breadcrumb li' )->count() ); |
103
|
|
|
|
104
|
|
|
$link = $crawler->filter( '.catalog-stage-breadcrumb a' )->link(); |
105
|
|
|
$crawler = $client->click( $link ); |
106
|
|
|
|
107
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-list' )->count() ); |
108
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-list-items .product a:contains("Cafe Noire Expresso")' )->count() ); |
109
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-list-items .product a:contains("Cafe Noire Cappuccino")' )->count() ); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
|
113
|
|
|
public function testStageNavigator() |
114
|
|
|
{ |
115
|
|
|
$client = static::createClient(); |
116
|
|
|
$crawler = $client->request( 'GET', '/unittest/de/EUR/shop/' ); |
117
|
|
|
|
118
|
|
|
$link = $crawler->filter( '.catalog-list .pagination .option-name' )->link(); |
119
|
|
|
$crawler = $client->click( $link ); |
120
|
|
|
|
121
|
|
|
$link = $crawler->filter( '.catalog-list-items .product a:contains("Cafe Noire Cappuccino")' )->link(); |
122
|
|
|
$crawler = $client->click( $link ); |
123
|
|
|
|
124
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-detail' )->count() ); |
125
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-detail:contains("Cafe Noire Cappuccino")' )->count() ); |
126
|
|
|
|
127
|
|
|
$link = $crawler->filter( '.catalog-stage-navigator a.next' )->link(); |
128
|
|
|
$crawler = $client->click( $link ); |
129
|
|
|
|
130
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-detail' )->count() ); |
131
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-detail:contains("Cafe Noire Expresso")' )->count() ); |
132
|
|
|
|
133
|
|
|
$link = $crawler->filter( '.catalog-stage-navigator a.prev' )->link(); |
134
|
|
|
$crawler = $client->click( $link ); |
135
|
|
|
|
136
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-detail' )->count() ); |
137
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-detail:contains("Cafe Noire Cappuccino")' )->count() ); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
|
141
|
|
|
public function testListSortationName() |
142
|
|
|
{ |
143
|
|
|
$client = static::createClient(); |
144
|
|
|
$crawler = $client->request( 'GET', '/unittest/de/EUR/shop/' ); |
145
|
|
|
|
146
|
|
|
$link = $crawler->filter( '.catalog-list .pagination .option-name' )->link(); |
147
|
|
|
$crawler = $client->click( $link ); |
148
|
|
|
|
149
|
|
|
$products = $crawler->filter( '.catalog-list-items .product' ); |
150
|
|
|
$this->assertEquals( 1, $products->eq( 0 )->filter( 'h2:contains("Cafe Noire Cappuccino")' )->count() ); |
151
|
|
|
$this->assertEquals( 1, $products->eq( 1 )->filter( 'h2:contains("Cafe Noire Expresso")' )->count() ); |
152
|
|
|
$this->assertEquals( 1, $products->eq( 2 )->filter( 'h2:contains("MNOP/16 disc")' )->count() ); |
153
|
|
|
$this->assertEquals( 1, $products->eq( 3 )->filter( 'h2:contains("Unittest: Bundle")' )->count() ); |
154
|
|
|
|
155
|
|
|
$link = $crawler->filter( '.catalog-list .pagination .option-name' )->link(); |
156
|
|
|
$crawler = $client->click( $link ); |
157
|
|
|
|
158
|
|
|
$products = $crawler->filter( '.catalog-list-items .product' ); |
159
|
|
|
$count = $products->count(); |
160
|
|
|
|
161
|
|
|
$this->assertGreaterThan( 3, $count ); |
162
|
|
|
$this->assertEquals( 1, $products->eq( $count - 4 )->filter( 'h2:contains("Unittest: Bundle")' )->count() ); |
163
|
|
|
$this->assertEquals( 1, $products->eq( $count - 3 )->filter( 'h2:contains("MNOP/16 disc")' )->count() ); |
164
|
|
|
$this->assertEquals( 1, $products->eq( $count - 2 )->filter( 'h2:contains("Cafe Noire Expresso")' )->count() ); |
165
|
|
|
$this->assertEquals( 1, $products->eq( $count - 1 )->filter( 'h2:contains("Cafe Noire Cappuccino")' )->count() ); |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
|
169
|
|
|
public function testListSortationPrice() |
170
|
|
|
{ |
171
|
|
|
$client = static::createClient(); |
172
|
|
|
$crawler = $client->request( 'GET', '/unittest/de/EUR/shop/' ); |
173
|
|
|
|
174
|
|
|
$link = $crawler->filter( '.catalog-list .pagination .option-price' )->link(); |
175
|
|
|
$crawler = $client->click( $link ); |
176
|
|
|
|
177
|
|
|
$products = $crawler->filter( '.catalog-list-items .product' ); |
178
|
|
|
$count = $products->count(); |
179
|
|
|
|
180
|
|
|
$this->assertGreaterThan( 2, $count ); |
181
|
|
|
$this->assertEquals( 1, $products->eq( $count - 2 )->filter( '.value:contains("600,00 €")' )->count() ); |
182
|
|
|
$this->assertEquals( 1, $products->eq( $count - 1 )->filter( '.value:contains("600,00 €")' )->count() ); |
183
|
|
|
|
184
|
|
|
$link = $crawler->filter( '.catalog-list .pagination .option-price' )->link(); |
185
|
|
|
$crawler = $client->click( $link ); |
186
|
|
|
|
187
|
|
|
$products = $crawler->filter( '.catalog-list-items .product' ); |
188
|
|
|
$this->assertEquals( 1, $products->eq( 0 )->filter( '.value:contains("600,00 €")' )->count() ); |
189
|
|
|
$this->assertEquals( 1, $products->eq( 1 )->filter( '.value:contains("600,00 €")' )->count() ); |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
|
193
|
|
|
public function testDetailPinned() |
194
|
|
|
{ |
195
|
|
|
$client = static::createClient(); |
196
|
|
|
$crawler = $client->request( 'GET', '/unittest/de/EUR/shop/' ); |
197
|
|
|
|
198
|
|
|
$link = $crawler->filter( '.catalog-list-items .product a:contains("Cafe Noire Expresso")' )->link(); |
199
|
|
|
$crawler = $client->click( $link ); |
200
|
|
|
|
201
|
|
|
$link = $crawler->filter( '.catalog-detail a.actions-button-pin' )->link(); |
202
|
|
|
$crawler = $client->click( $link ); |
203
|
|
|
|
204
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-session-pinned .pinned-item' )->count() ); |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
|
208
|
|
|
public function testDetailLastSeen() |
209
|
|
|
{ |
210
|
|
|
$client = static::createClient(); |
211
|
|
|
$crawler = $client->request( 'GET', '/unittest/de/EUR/shop/' ); |
212
|
|
|
|
213
|
|
|
$link = $crawler->filter( '.catalog-list-items .product a:contains("Cafe Noire Expresso")' )->link(); |
214
|
|
|
$crawler = $client->click( $link ); |
215
|
|
|
|
216
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-session-seen .seen-item' )->count() ); |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
|
220
|
|
|
public function testSuggest() |
221
|
|
|
{ |
222
|
|
|
$client = static::createClient(); |
223
|
|
|
$client->request( 'GET', '/unittest/de/EUR/shop/suggest', array( 'f_search' => 'Cafe' ) ); |
224
|
|
|
$content = $client->getResponse()->getContent(); |
225
|
|
|
|
226
|
|
|
$this->assertStringStartsWith( '[{', $content ); |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
|
230
|
|
|
public function testStock() |
231
|
|
|
{ |
232
|
|
|
$client = static::createClient(); |
233
|
|
|
$client->request( 'GET', '/unittest/de/EUR/shop/stock' ); |
234
|
|
|
$content = $client->getResponse()->getContent(); |
235
|
|
|
|
236
|
|
|
$this->assertStringContainsString( '.aimeos .product .stock', $content ); |
237
|
|
|
$this->assertStringContainsString( '.aimeos .catalog-detail-basket', $content ); |
238
|
|
|
} |
239
|
|
|
|
240
|
|
|
|
241
|
|
|
public function testCountComponent() |
242
|
|
|
{ |
243
|
|
|
$client = static::createClient(); |
244
|
|
|
$client->request( 'GET', '/unittest/de/EUR/test/catalogcountcomponent' ); |
245
|
|
|
|
246
|
|
|
$this->assertEquals( 200, $client->getResponse()->getStatusCode() ); |
247
|
|
|
$this->assertStringContainsString( 'catalog-filter-count', $client->getResponse()->getContent() ); |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
|
251
|
|
|
public function testDetailComponent() |
252
|
|
|
{ |
253
|
|
|
$client = static::createClient(); |
254
|
|
|
$client->request( 'GET', '/unittest/de/EUR/test/catalogdetailcomponent' ); |
255
|
|
|
|
256
|
|
|
$this->assertEquals( 200, $client->getResponse()->getStatusCode() ); |
257
|
|
|
$this->assertStringContainsString( '', $client->getResponse()->getContent() ); // if no product ID s available |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
|
261
|
|
|
public function testFilterComponent() |
262
|
|
|
{ |
263
|
|
|
$client = static::createClient(); |
264
|
|
|
$client->request( 'GET', '/unittest/de/EUR/test/catalogfiltercomponent' ); |
265
|
|
|
|
266
|
|
|
$this->assertEquals( 200, $client->getResponse()->getStatusCode() ); |
267
|
|
|
$this->assertStringContainsString( 'aimeos catalog-filter', $client->getResponse()->getContent() ); |
268
|
|
|
} |
269
|
|
|
|
270
|
|
|
|
271
|
|
|
public function testHomeComponent() |
272
|
|
|
{ |
273
|
|
|
$client = static::createClient(); |
274
|
|
|
$client->request( 'GET', '/unittest/de/EUR/test/cataloghomecomponent' ); |
275
|
|
|
|
276
|
|
|
$this->assertEquals( 200, $client->getResponse()->getStatusCode() ); |
277
|
|
|
$this->assertStringContainsString( 'aimeos catalog-home', $client->getResponse()->getContent() ); |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
|
281
|
|
|
public function testListComponent() |
282
|
|
|
{ |
283
|
|
|
$client = static::createClient(); |
284
|
|
|
$client->request( 'GET', '/unittest/de/EUR/test/cataloglistcomponent' ); |
285
|
|
|
|
286
|
|
|
$this->assertEquals( 200, $client->getResponse()->getStatusCode() ); |
287
|
|
|
$this->assertStringContainsString( 'aimeos catalog-list', $client->getResponse()->getContent() ); |
288
|
|
|
} |
289
|
|
|
|
290
|
|
|
|
291
|
|
|
public function testSessionComponent() |
292
|
|
|
{ |
293
|
|
|
$client = static::createClient(); |
294
|
|
|
$client->request( 'GET', '/unittest/de/EUR/test/catalogsessioncomponent' ); |
295
|
|
|
|
296
|
|
|
$this->assertEquals( 200, $client->getResponse()->getStatusCode() ); |
297
|
|
|
$this->assertStringContainsString( 'aimeos catalog-session', $client->getResponse()->getContent() ); |
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
|
301
|
|
|
public function testStageComponent() |
302
|
|
|
{ |
303
|
|
|
$client = static::createClient(); |
304
|
|
|
$client->request( 'GET', '/unittest/de/EUR/test/catalogstagecomponent' ); |
305
|
|
|
|
306
|
|
|
$this->assertEquals( 200, $client->getResponse()->getStatusCode() ); |
307
|
|
|
$this->assertStringContainsString( 'aimeos catalog-stage', $client->getResponse()->getContent() ); |
308
|
|
|
} |
309
|
|
|
|
310
|
|
|
|
311
|
|
|
public function testStockComponent() |
312
|
|
|
{ |
313
|
|
|
$client = static::createClient(); |
314
|
|
|
$client->request( 'GET', '/unittest/de/EUR/test/catalogstockcomponent' ); |
315
|
|
|
|
316
|
|
|
$this->assertEquals( 200, $client->getResponse()->getStatusCode() ); |
317
|
|
|
$this->assertStringContainsString( 'stock-list', $client->getResponse()->getContent() ); |
318
|
|
|
} |
319
|
|
|
} |
320
|
|
|
|