1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Aimeos\ShopBundle\Tests\Controller; |
4
|
|
|
|
5
|
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; |
6
|
|
|
|
7
|
|
|
|
8
|
|
|
class CheckoutControllerTest extends WebTestCase |
9
|
|
|
{ |
10
|
|
|
public function testStandardNavbar() |
11
|
|
|
{ |
12
|
|
|
$client = static::createClient(array(), array( |
13
|
|
|
'PHP_AUTH_USER' => 'UTC001', |
14
|
|
|
'PHP_AUTH_PW' => 'unittest', |
15
|
|
|
) ); |
16
|
|
|
|
17
|
|
|
$crawler = $client->request( 'GET', '/unittest/de/EUR/list' ); |
18
|
|
|
|
19
|
|
|
$link = $crawler->filter( '.catalog-list-items .product a:contains("Unittest: Bundle")' )->link(); |
20
|
|
|
$crawler = $client->click( $link ); |
21
|
|
|
|
22
|
|
|
$form = $crawler->filter( '.catalog-detail .addbasket .btn-action' )->form(); |
23
|
|
|
$crawler = $client->submit( $form ); |
24
|
|
|
|
25
|
|
|
$link = $crawler->filter( '.basket-standard .btn-action' )->link(); |
26
|
|
|
$crawler = $client->click( $link ); |
27
|
|
|
|
28
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .current:contains("Adresse")' )->count() ); |
29
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .basket a' )->count() ); |
30
|
|
|
$this->assertEquals( 0, $crawler->filter( '.checkout-standard .steps .address a' )->count() ); |
31
|
|
|
$this->assertEquals( 0, $crawler->filter( '.checkout-standard .steps .delivery a' )->count() ); |
32
|
|
|
$this->assertEquals( 0, $crawler->filter( '.checkout-standard .steps .payment a' )->count() ); |
33
|
|
|
$this->assertEquals( 0, $crawler->filter( '.checkout-standard .steps .summary a' )->count() ); |
34
|
|
|
|
35
|
|
|
|
36
|
|
|
$form = $crawler->filter( '.checkout-standard form' )->form(); |
37
|
|
|
$form['ca_billingoption']->select( $crawler->filter( '.checkout-standard-address .item-address input' )->attr( 'value' ) ); |
38
|
|
|
$crawler = $client->submit( $form ); |
39
|
|
|
|
40
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .basket a' )->count() ); |
41
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .address a' )->count() ); |
42
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .current:contains("Versand")' )->count() ); |
43
|
|
|
$this->assertEquals( 0, $crawler->filter( '.checkout-standard .steps .delivery a' )->count() ); |
44
|
|
|
$this->assertEquals( 0, $crawler->filter( '.checkout-standard .steps .payment a' )->count() ); |
45
|
|
|
$this->assertEquals( 0, $crawler->filter( '.checkout-standard .steps .summary a' )->count() ); |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
$form = $crawler->filter( '.checkout-standard form' )->form(); |
49
|
|
|
$form['c_deliveryoption']->select( $crawler->filter( '.checkout-standard-delivery .item-service input' )->attr( 'value' ) ); |
50
|
|
|
$crawler = $client->submit( $form ); |
51
|
|
|
|
52
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .basket a' )->count() ); |
53
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .address a' )->count() ); |
54
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .delivery a' )->count() ); |
55
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .current:contains("Zahlung")' )->count() ); |
56
|
|
|
$this->assertEquals( 0, $crawler->filter( '.checkout-standard .steps .payment a' )->count() ); |
57
|
|
|
$this->assertEquals( 0, $crawler->filter( '.checkout-standard .steps .summary a' )->count() ); |
58
|
|
|
|
59
|
|
|
|
60
|
|
|
$form = $crawler->filter( '.checkout-standard form' )->form(); |
61
|
|
|
$form['c_paymentoption']->select( $crawler->filter( '.checkout-standard-payment .item-service input' )->attr( 'value' ) ); |
62
|
|
|
$crawler = $client->submit( $form ); |
63
|
|
|
|
64
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .basket a' )->count() ); |
65
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .address a' )->count() ); |
66
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .delivery a' )->count() ); |
67
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .payment a' )->count() ); |
68
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .current:contains("Übersicht")' )->count() ); |
69
|
|
|
$this->assertEquals( 0, $crawler->filter( '.checkout-standard .steps .summary a' )->count() ); |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
$link = $crawler->filter( '.checkout-standard .steps .basket a' )->link(); |
73
|
|
|
$crawler = $client->click( $link ); |
74
|
|
|
$this->assertEquals( 0, $crawler->filter( '.checkout-standard .steps' )->count() ); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
|
78
|
|
|
public function testStandardNextBack() |
79
|
|
|
{ |
80
|
|
|
$client = static::createClient(array(), array( |
81
|
|
|
'PHP_AUTH_USER' => 'UTC001', |
82
|
|
|
'PHP_AUTH_PW' => 'unittest', |
83
|
|
|
) ); |
84
|
|
|
|
85
|
|
|
$crawler = $this->_goToSummary( $client ); |
86
|
|
|
|
87
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard-summary' )->count() ); |
88
|
|
|
|
89
|
|
|
|
90
|
|
|
$link = $crawler->filter( '.checkout-standard .btn-back' )->link(); |
91
|
|
|
$crawler = $client->click( $link ); |
92
|
|
|
|
93
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard-payment' )->count() ); |
94
|
|
|
|
95
|
|
|
|
96
|
|
|
$link = $crawler->filter( '.checkout-standard .btn-back' )->link(); |
97
|
|
|
$crawler = $client->click( $link ); |
98
|
|
|
|
99
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard-delivery' )->count() ); |
100
|
|
|
|
101
|
|
|
|
102
|
|
|
$link = $crawler->filter( '.checkout-standard .btn-back' )->link(); |
103
|
|
|
$crawler = $client->click( $link ); |
104
|
|
|
|
105
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard-address' )->count() ); |
106
|
|
|
|
107
|
|
|
|
108
|
|
|
$form = $crawler->filter( '.checkout-standard .btn-action' )->form(); |
109
|
|
|
$crawler = $client->submit( $form ); |
110
|
|
|
|
111
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard-delivery' )->count() ); |
112
|
|
|
|
113
|
|
|
|
114
|
|
|
$form = $crawler->filter( '.checkout-standard .btn-action' )->form(); |
115
|
|
|
$crawler = $client->submit( $form ); |
116
|
|
|
|
117
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard-payment' )->count() ); |
118
|
|
|
|
119
|
|
|
|
120
|
|
|
$form = $crawler->filter( '.checkout-standard .btn-action' )->form(); |
121
|
|
|
$crawler = $client->submit( $form ); |
122
|
|
|
|
123
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard-summary' )->count() ); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
|
127
|
|
|
public function testStandardAddressPayment() |
128
|
|
|
{ |
129
|
|
|
$client = static::createClient(array(), array( |
130
|
|
|
'PHP_AUTH_USER' => 'UTC001', |
131
|
|
|
'PHP_AUTH_PW' => 'unittest', |
132
|
|
|
) ); |
133
|
|
|
|
134
|
|
|
$crawler = $this->_goToSummary( $client ); |
135
|
|
|
|
136
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard-summary' )->count() ); |
137
|
|
|
|
138
|
|
|
|
139
|
|
|
$link = $crawler->filter( '.checkout-standard .common-summary-address .payment .modify' )->link(); |
140
|
|
|
$crawler = $client->click( $link ); |
141
|
|
|
|
142
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard-address' )->count() ); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
|
146
|
|
|
public function testStandardAddressDelivery() |
147
|
|
|
{ |
148
|
|
|
$client = static::createClient(array(), array( |
149
|
|
|
'PHP_AUTH_USER' => 'UTC001', |
150
|
|
|
'PHP_AUTH_PW' => 'unittest', |
151
|
|
|
) ); |
152
|
|
|
|
153
|
|
|
$crawler = $this->_goToSummary( $client ); |
154
|
|
|
|
155
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard-summary' )->count() ); |
156
|
|
|
|
157
|
|
|
|
158
|
|
|
$link = $crawler->filter( '.checkout-standard .common-summary-address .delivery .modify' )->link(); |
159
|
|
|
$crawler = $client->click( $link ); |
160
|
|
|
|
161
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard-address' )->count() ); |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
|
165
|
|
|
public function testStandardDelivery() |
166
|
|
|
{ |
167
|
|
|
$client = static::createClient(array(), array( |
168
|
|
|
'PHP_AUTH_USER' => 'UTC001', |
169
|
|
|
'PHP_AUTH_PW' => 'unittest', |
170
|
|
|
) ); |
171
|
|
|
|
172
|
|
|
$crawler = $this->_goToSummary( $client ); |
173
|
|
|
|
174
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard-summary' )->count() ); |
175
|
|
|
|
176
|
|
|
|
177
|
|
|
$link = $crawler->filter( '.checkout-standard .common-summary-service .delivery .modify' )->link(); |
178
|
|
|
$crawler = $client->click( $link ); |
179
|
|
|
|
180
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard-delivery' )->count() ); |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
|
184
|
|
|
public function testStandardPayment() |
185
|
|
|
{ |
186
|
|
|
$client = static::createClient(array(), array( |
187
|
|
|
'PHP_AUTH_USER' => 'UTC001', |
188
|
|
|
'PHP_AUTH_PW' => 'unittest', |
189
|
|
|
) ); |
190
|
|
|
|
191
|
|
|
$crawler = $this->_goToSummary( $client ); |
192
|
|
|
|
193
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard-summary' )->count() ); |
194
|
|
|
|
195
|
|
|
|
196
|
|
|
$link = $crawler->filter( '.checkout-standard .common-summary-service .payment .modify' )->link(); |
197
|
|
|
$crawler = $client->click( $link ); |
198
|
|
|
|
199
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard-payment' )->count() ); |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
|
203
|
|
|
public function testStandardBasket() |
204
|
|
|
{ |
205
|
|
|
$client = static::createClient(array(), array( |
206
|
|
|
'PHP_AUTH_USER' => 'UTC001', |
207
|
|
|
'PHP_AUTH_PW' => 'unittest', |
208
|
|
|
) ); |
209
|
|
|
|
210
|
|
|
$crawler = $this->_goToSummary( $client ); |
211
|
|
|
|
212
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard-summary' )->count() ); |
213
|
|
|
|
214
|
|
|
|
215
|
|
|
$link = $crawler->filter( '.checkout-standard .common-summary-detail .modify' )->link(); |
216
|
|
|
$crawler = $client->click( $link ); |
217
|
|
|
|
218
|
|
|
$this->assertEquals( 1, $crawler->filter( '.basket-standard' )->count() ); |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
|
222
|
|
|
public function testStandardOrder() |
223
|
|
|
{ |
224
|
|
|
$client = static::createClient(array(), array( |
225
|
|
|
'PHP_AUTH_USER' => 'UTC001', |
226
|
|
|
'PHP_AUTH_PW' => 'unittest', |
227
|
|
|
) ); |
228
|
|
|
|
229
|
|
|
$crawler = $client->request( 'GET', '/unittest/de/EUR/list' ); |
230
|
|
|
|
231
|
|
|
$link = $crawler->filter( '.catalog-list-items .product a:contains("Unittest: Bundle")' )->link(); |
232
|
|
|
$crawler = $client->click( $link ); |
233
|
|
|
|
234
|
|
|
$form = $crawler->filter( '.catalog-detail .addbasket .btn-action' )->form(); |
235
|
|
|
$crawler = $client->submit( $form ); |
236
|
|
|
|
237
|
|
|
$link = $crawler->filter( '.basket-standard .btn-action' )->link(); |
238
|
|
|
$crawler = $client->click( $link ); |
239
|
|
|
|
240
|
|
|
$form = $crawler->filter( '.checkout-standard form' )->form(); |
241
|
|
|
$form['ca_billingoption']->select( $crawler->filter( '.checkout-standard-address .item-address input' )->attr( 'value' ) ); |
242
|
|
|
$crawler = $client->submit( $form ); |
243
|
|
|
|
244
|
|
|
$form = $crawler->filter( '.checkout-standard form' )->form(); |
245
|
|
|
$form['c_deliveryoption']->select( $crawler->filter( '.checkout-standard-delivery .item-service input' )->attr( 'value' ) ); |
246
|
|
|
$crawler = $client->submit( $form ); |
247
|
|
|
|
248
|
|
|
$form = $crawler->filter( '.checkout-standard form' )->form(); |
249
|
|
|
$payId = $crawler->filter( '.checkout-standard-payment .item-service' )->eq( 1 )->filter( 'input' )->attr( 'value' ); |
250
|
|
|
$form['c_paymentoption']->select( $payId ); |
251
|
|
|
$form['c_payment[' . $payId . '][directdebit.accountowner]'] = 'test user'; |
252
|
|
|
$form['c_payment[' . $payId . '][directdebit.accountno]'] = '12345'; |
253
|
|
|
$form['c_payment[' . $payId . '][directdebit.bankcode]'] = '67890'; |
254
|
|
|
$form['c_payment[' . $payId . '][directdebit.bankname]'] = 'test bank'; |
255
|
|
|
$crawler = $client->submit( $form ); |
|
|
|
|
256
|
|
|
|
257
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-standard-summary' )->count() ); |
258
|
|
|
|
259
|
|
|
|
260
|
|
|
// Test if T&C are not accepted |
261
|
|
|
$form = $crawler->filter( '.checkout-standard .btn-action' )->form(); |
262
|
|
|
$crawler = $client->submit( $form ); |
263
|
|
|
|
264
|
|
|
$form = $crawler->filter( '.checkout-standard .btn-action' )->form(); |
265
|
|
|
$form['cs_option_terms_value']->tick(); |
266
|
|
|
$crawler = $client->submit( $form ); |
267
|
|
|
|
268
|
|
|
$form = $crawler->filter( '.checkout-standard .btn-action' )->form(); |
269
|
|
|
$crawler = $client->submit( $form ); |
270
|
|
|
|
271
|
|
|
$this->assertEquals( 1, $crawler->filter( '.checkout-confirm' )->count() ); |
272
|
|
|
} |
273
|
|
|
|
274
|
|
|
|
275
|
|
|
public function testUpdate() |
276
|
|
|
{ |
277
|
|
|
$client = static::createClient(); |
278
|
|
|
|
279
|
|
|
$client->request( 'GET', '/unittest/de/EUR/update' ); |
280
|
|
|
|
281
|
|
|
$this->assertEquals( 200, $client->getResponse()->getStatusCode() ); |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
|
285
|
|
|
public function testConfirmComponent() |
286
|
|
|
{ |
287
|
|
|
$mock = $this->getMockBuilder( 'Aimeos\ShopBundle\Controller\CheckoutController' ) |
288
|
|
|
->setMethods( array( 'getOutput' ) ) |
289
|
|
|
->disableOriginalConstructor() |
290
|
|
|
->getMock(); |
291
|
|
|
|
292
|
|
|
$mock->expects( $this->once() )->method( 'getOutput' )->will( $this->returnValue( 'test' ) ); |
293
|
|
|
|
294
|
|
|
$this->assertEquals( 'test', $mock->confirmComponentAction() ); |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
|
298
|
|
|
public function testStandardComponent() |
299
|
|
|
{ |
300
|
|
|
$mock = $this->getMockBuilder( 'Aimeos\ShopBundle\Controller\CheckoutController' ) |
301
|
|
|
->setMethods( array( 'getOutput' ) ) |
302
|
|
|
->disableOriginalConstructor() |
303
|
|
|
->getMock(); |
304
|
|
|
|
305
|
|
|
$mock->expects( $this->once() )->method( 'getOutput' )->will( $this->returnValue( 'test' ) ); |
306
|
|
|
|
307
|
|
|
$this->assertEquals( 'test', $mock->standardComponentAction() ); |
308
|
|
|
} |
309
|
|
|
|
310
|
|
|
|
311
|
|
|
public function testUpdateComponent() |
312
|
|
|
{ |
313
|
|
|
$mock = $this->getMockBuilder( 'Aimeos\ShopBundle\Controller\CheckoutController' ) |
314
|
|
|
->setMethods( array( 'getOutput' ) ) |
315
|
|
|
->disableOriginalConstructor() |
316
|
|
|
->getMock(); |
317
|
|
|
|
318
|
|
|
$mock->expects( $this->once() )->method( 'getOutput' )->will( $this->returnValue( 'test' ) ); |
319
|
|
|
|
320
|
|
|
$this->assertEquals( 'test', $mock->updateComponentAction() ); |
321
|
|
|
} |
322
|
|
|
|
323
|
|
|
|
324
|
|
|
/** |
325
|
|
|
* Moves forward to the summary page |
326
|
|
|
* |
327
|
|
|
* @param \Symfony\Bundle\FrameworkBundle\Client $client HTTP test client |
328
|
|
|
* @return \Symfony\Component\DomCrawler\Crawler Crawler HTTP crawler |
329
|
|
|
*/ |
330
|
|
|
protected function _goToSummary( $client ) |
331
|
|
|
{ |
332
|
|
|
$crawler = $client->request( 'GET', '/unittest/de/EUR/list' ); |
333
|
|
|
|
334
|
|
|
$link = $crawler->filter( '.catalog-list-items .product a:contains("Unittest: Bundle")' )->link(); |
335
|
|
|
$crawler = $client->click( $link ); |
336
|
|
|
|
337
|
|
|
$form = $crawler->filter( '.catalog-detail .addbasket .btn-action' )->form(); |
338
|
|
|
$crawler = $client->submit( $form ); |
339
|
|
|
|
340
|
|
|
$link = $crawler->filter( '.basket-standard .btn-action' )->link(); |
341
|
|
|
$crawler = $client->click( $link ); |
342
|
|
|
|
343
|
|
|
$form = $crawler->filter( '.checkout-standard form' )->form(); |
344
|
|
|
$form['ca_billingoption']->select( $crawler->filter( '.checkout-standard-address .item-address input' )->attr( 'value' ) ); |
345
|
|
|
$crawler = $client->submit( $form ); |
346
|
|
|
|
347
|
|
|
$form = $crawler->filter( '.checkout-standard form' )->form(); |
348
|
|
|
$form['c_deliveryoption']->select( $crawler->filter( '.checkout-standard-delivery .item-service input' )->attr( 'value' ) ); |
349
|
|
|
$crawler = $client->submit( $form ); |
350
|
|
|
|
351
|
|
|
$form = $crawler->filter( '.checkout-standard form' )->form(); |
352
|
|
|
$form['c_paymentoption']->select( $crawler->filter( '.checkout-standard-payment .item-service input' )->attr( 'value' ) ); |
353
|
|
|
$crawler = $client->submit( $form ); |
354
|
|
|
|
355
|
|
|
return $crawler; |
356
|
|
|
} |
357
|
|
|
} |
358
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: