|
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?count=tree' ); |
|
21
|
|
|
$content = $client->getResponse()->getContent(); |
|
22
|
|
|
|
|
23
|
|
|
$this->assertStringStartsWith( '{"', $content ); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
public function testFilterSearch() |
|
28
|
|
|
{ |
|
29
|
|
|
$client = static::createClient(); |
|
30
|
|
|
$crawler = $client->request( 'GET', '/unittest/de/EUR/shop/' ); |
|
31
|
|
|
|
|
32
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-filter-search' )->count() ); |
|
33
|
|
|
|
|
34
|
|
|
$form = $crawler->filter( '.catalog-filter-search button' )->form(); |
|
35
|
|
|
$form['f_search'] = 'Cafe'; |
|
36
|
|
|
$crawler = $client->submit( $form ); |
|
37
|
|
|
|
|
38
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-list-items .product a:contains("Cafe Noire Cappuccino")' )->count() ); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
public function testFilterTree() |
|
43
|
|
|
{ |
|
44
|
|
|
$client = static::createClient(); |
|
45
|
|
|
$crawler = $client->request( 'GET', '/unittest/de/EUR/shop/' ); |
|
46
|
|
|
|
|
47
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-filter-tree' )->count() ); |
|
48
|
|
|
|
|
49
|
|
|
$link = $crawler->filter( '.catalog-filter-tree .coffee a.cat-link' )->link(); |
|
50
|
|
|
$crawler = $client->click( $link ); |
|
51
|
|
|
|
|
52
|
|
|
$this->assertEquals( 3, $crawler->filter( '.catalog-stage-breadcrumb li' )->count() ); |
|
53
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-list-items .product a:contains("Cafe Noire Expresso")' )->count() ); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
public function testFilterAttribute() |
|
58
|
|
|
{ |
|
59
|
|
|
$client = static::createClient(); |
|
60
|
|
|
$crawler = $client->request( 'GET', '/unittest/de/EUR/shop/' ); |
|
61
|
|
|
|
|
62
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-filter-attribute' )->count() ); |
|
63
|
|
|
|
|
64
|
|
|
$nodes = $crawler->filter( '.catalog-filter-attribute .attr-size span:contains("XS")' ); |
|
65
|
|
|
$id = $nodes->closest( '.attr-item' )->attr( 'data-id' ); |
|
66
|
|
|
|
|
67
|
|
|
$form = $crawler->filter( '.catalog-filter .btn-primary' )->form(); |
|
68
|
|
|
$values = $form->getPhpValues(); |
|
69
|
|
|
$values['f_attrid'] = array( $id ); |
|
70
|
|
|
$crawler = $client->request( $form->getMethod(), $form->getUri(), $values, $form->getPhpFiles() ); |
|
71
|
|
|
|
|
72
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-list-items .product a:contains("Cafe Noire Expresso")' )->count() ); |
|
73
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-list-items .product a:contains("Cafe Noire Cappuccino")' )->count() ); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
|
|
77
|
|
|
public function testHome() |
|
78
|
|
|
{ |
|
79
|
|
|
$client = static::createClient(); |
|
80
|
|
|
$client->request( 'GET', '/unittest/de/EUR/' ); |
|
81
|
|
|
$content = $client->getResponse()->getContent(); |
|
82
|
|
|
|
|
83
|
|
|
$this->assertStringContainsString( 'aimeos catalog-home', $content ); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
|
|
87
|
|
|
public function testStageBreadcrumb() |
|
88
|
|
|
{ |
|
89
|
|
|
$client = static::createClient(); |
|
90
|
|
|
$crawler = $client->request( 'GET', '/unittest/de/EUR/shop/' ); |
|
91
|
|
|
|
|
92
|
|
|
$link = $crawler->filter( '.catalog-list-items .product a:contains("Cafe Noire Expresso")' )->link(); |
|
93
|
|
|
$crawler = $client->click( $link ); |
|
94
|
|
|
|
|
95
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-stage-breadcrumb li' )->count() ); |
|
96
|
|
|
|
|
97
|
|
|
$link = $crawler->filter( '.catalog-stage-breadcrumb a' )->link(); |
|
98
|
|
|
$crawler = $client->click( $link ); |
|
|
|
|
|
|
99
|
|
|
|
|
100
|
|
|
// breadcrumb works differently in current versions |
|
101
|
|
|
// $this->assertEquals( 1, $crawler->filter( '.catalog-list' )->count() ); |
|
102
|
|
|
// $this->assertEquals( 1, $crawler->filter( '.catalog-list-items .product a:contains("Cafe Noire Expresso")' )->count() ); |
|
103
|
|
|
// $this->assertEquals( 1, $crawler->filter( '.catalog-list-items .product a:contains("Cafe Noire Cappuccino")' )->count() ); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
|
|
107
|
|
|
public function testStageNavigator() |
|
108
|
|
|
{ |
|
109
|
|
|
$client = static::createClient(); |
|
110
|
|
|
$crawler = $client->request( 'GET', '/unittest/de/EUR/shop/' ); |
|
111
|
|
|
|
|
112
|
|
|
$link = $crawler->filter( '.catalog-list .pagination .option-name' )->link(); |
|
113
|
|
|
$crawler = $client->click( $link ); |
|
114
|
|
|
|
|
115
|
|
|
$link = $crawler->filter( '.catalog-list-items .product a:contains("Cafe Noire Cappuccino")' )->link(); |
|
116
|
|
|
$crawler = $client->click( $link ); |
|
117
|
|
|
|
|
118
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-detail' )->count() ); |
|
119
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-detail:contains("Cafe Noire Cappuccino")' )->count() ); |
|
120
|
|
|
|
|
121
|
|
|
$link = $crawler->filter( '.catalog-detail-navigator a.next' )->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 Expresso")' )->count() ); |
|
126
|
|
|
|
|
127
|
|
|
$link = $crawler->filter( '.catalog-detail-navigator a.prev' )->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 Cappuccino")' )->count() ); |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
|
|
135
|
|
|
public function testListSortationName() |
|
136
|
|
|
{ |
|
137
|
|
|
$client = static::createClient(); |
|
138
|
|
|
$crawler = $client->request( 'GET', '/unittest/de/EUR/shop/' ); |
|
139
|
|
|
|
|
140
|
|
|
$link = $crawler->filter( '.catalog-list .pagination .option-name' )->link(); |
|
141
|
|
|
$crawler = $client->click( $link ); |
|
142
|
|
|
|
|
143
|
|
|
$products = $crawler->filter( '.catalog-list-items .product' ); |
|
144
|
|
|
$this->assertEquals( 1, $products->eq( 0 )->filter( 'h2:contains("Cafe Noire Cappuccino")' )->count() ); |
|
145
|
|
|
$this->assertEquals( 1, $products->eq( 1 )->filter( 'h2:contains("Cafe Noire Expresso")' )->count() ); |
|
146
|
|
|
$this->assertEquals( 1, $products->eq( 2 )->filter( 'h2:contains("MNOP/16 disc")' )->count() ); |
|
147
|
|
|
$this->assertEquals( 1, $products->eq( 3 )->filter( 'h2:contains("Unittest: Bundle")' )->count() ); |
|
148
|
|
|
|
|
149
|
|
|
$link = $crawler->filter( '.catalog-list .pagination .option-name' )->link(); |
|
150
|
|
|
$crawler = $client->click( $link ); |
|
151
|
|
|
|
|
152
|
|
|
$products = $crawler->filter( '.catalog-list-items .product' ); |
|
153
|
|
|
$count = $products->count(); |
|
154
|
|
|
|
|
155
|
|
|
$this->assertGreaterThan( 3, $count ); |
|
156
|
|
|
$this->assertEquals( 1, $products->eq( $count - 4 )->filter( 'h2:contains("Unittest: Bundle")' )->count() ); |
|
157
|
|
|
$this->assertEquals( 1, $products->eq( $count - 3 )->filter( 'h2:contains("MNOP/16 disc")' )->count() ); |
|
158
|
|
|
$this->assertEquals( 1, $products->eq( $count - 2 )->filter( 'h2:contains("Cafe Noire Expresso")' )->count() ); |
|
159
|
|
|
$this->assertEquals( 1, $products->eq( $count - 1 )->filter( 'h2:contains("Cafe Noire Cappuccino")' )->count() ); |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
|
|
163
|
|
|
public function testListSortationPrice() |
|
164
|
|
|
{ |
|
165
|
|
|
$client = static::createClient(); |
|
166
|
|
|
$crawler = $client->request( 'GET', '/unittest/de/EUR/shop/' ); |
|
167
|
|
|
|
|
168
|
|
|
$link = $crawler->filter( '.catalog-list .pagination .option-price' )->link(); |
|
169
|
|
|
$crawler = $client->click( $link ); |
|
170
|
|
|
|
|
171
|
|
|
$products = $crawler->filter( '.catalog-list-items .product' ); |
|
172
|
|
|
$count = $products->count(); |
|
173
|
|
|
|
|
174
|
|
|
$this->assertGreaterThan( 2, $count ); |
|
175
|
|
|
$this->assertEquals( 1, $products->eq( $count - 2 )->filter( '.value:contains("600,00 €")' )->count() ); |
|
176
|
|
|
$this->assertEquals( 1, $products->eq( $count - 1 )->filter( '.value:contains("600,00 €")' )->count() ); |
|
177
|
|
|
|
|
178
|
|
|
$link = $crawler->filter( '.catalog-list .pagination .option-price' )->link(); |
|
179
|
|
|
$crawler = $client->click( $link ); |
|
180
|
|
|
|
|
181
|
|
|
$products = $crawler->filter( '.catalog-list-items .product' ); |
|
182
|
|
|
$this->assertEquals( 1, $products->eq( 0 )->filter( '.value:contains("600,00 €")' )->count() ); |
|
183
|
|
|
$this->assertEquals( 1, $products->eq( 1 )->filter( '.value:contains("600,00 €")' )->count() ); |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
|
|
187
|
|
|
public function testDetailPinned() |
|
188
|
|
|
{ |
|
189
|
|
|
$client = static::createClient(); |
|
190
|
|
|
$crawler = $client->request( 'GET', '/unittest/de/EUR/shop/' ); |
|
191
|
|
|
|
|
192
|
|
|
$link = $crawler->filter( '.catalog-list-items .product a:contains("Cafe Noire Expresso")' )->link(); |
|
193
|
|
|
$crawler = $client->click( $link ); |
|
194
|
|
|
|
|
195
|
|
|
$form = $crawler->filter( '.catalog-detail .actions-pin' )->form(); |
|
196
|
|
|
$crawler = $client->submit( $form ); |
|
197
|
|
|
|
|
198
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-session-pinned .pinned-item' )->count() ); |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
|
|
202
|
|
|
public function testDetailLastSeen() |
|
203
|
|
|
{ |
|
204
|
|
|
$client = static::createClient(); |
|
205
|
|
|
$crawler = $client->request( 'GET', '/unittest/de/EUR/shop/' ); |
|
206
|
|
|
|
|
207
|
|
|
$link = $crawler->filter( '.catalog-list-items .product a:contains("Cafe Noire Expresso")' )->link(); |
|
208
|
|
|
$crawler = $client->click( $link ); |
|
|
|
|
|
|
209
|
|
|
|
|
210
|
|
|
$crawler = $client->request( 'GET', '/unittest/de/EUR/shop/' ); |
|
211
|
|
|
|
|
212
|
|
|
$this->assertEquals( 1, $crawler->filter( '.catalog-session-seen .seen-item' )->count() ); |
|
213
|
|
|
} |
|
214
|
|
|
|
|
215
|
|
|
|
|
216
|
|
|
public function testSuggest() |
|
217
|
|
|
{ |
|
218
|
|
|
$client = static::createClient(); |
|
219
|
|
|
$client->request( 'GET', '/unittest/de/EUR/shop/suggest', array( 'f_search' => 'Cafe' ) ); |
|
220
|
|
|
$content = $client->getResponse()->getContent(); |
|
221
|
|
|
|
|
222
|
|
|
$this->assertStringStartsWith( '[{', $content ); |
|
223
|
|
|
} |
|
224
|
|
|
|
|
225
|
|
|
|
|
226
|
|
|
public function testStock() |
|
227
|
|
|
{ |
|
228
|
|
|
$client = static::createClient(); |
|
229
|
|
|
$client->request( 'GET', '/unittest/de/EUR/shop/stock' ); |
|
230
|
|
|
$content = $client->getResponse()->getContent(); |
|
231
|
|
|
|
|
232
|
|
|
$this->assertStringContainsString( '.aimeos .product .stock', $content ); |
|
233
|
|
|
$this->assertStringContainsString( '.aimeos .catalog-detail-basket', $content ); |
|
234
|
|
|
} |
|
235
|
|
|
} |
|
236
|
|
|
|