|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2012 |
|
6
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2018 |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Aimeos\Controller\Frontend\Basket; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
class StandardTest extends \PHPUnit\Framework\TestCase |
|
|
|
|
|
|
13
|
|
|
{ |
|
14
|
|
|
private $object; |
|
15
|
|
|
private $context; |
|
16
|
|
|
private $testItem; |
|
17
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
protected function setUp() |
|
20
|
|
|
{ |
|
21
|
|
|
\Aimeos\MShop::cache( true ); |
|
22
|
|
|
|
|
23
|
|
|
$this->context = \TestHelperFrontend::getContext(); |
|
24
|
|
|
|
|
25
|
|
|
$manager = \Aimeos\MShop::create( $this->context, 'product' ); |
|
26
|
|
|
$this->testItem = $manager->findItem( 'U:TESTP', ['attribute', 'media', 'price', 'product', 'text'] ); |
|
27
|
|
|
|
|
28
|
|
|
$this->object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
protected function tearDown() |
|
33
|
|
|
{ |
|
34
|
|
|
\Aimeos\MShop::cache( false ); |
|
35
|
|
|
|
|
36
|
|
|
$this->object->clear(); |
|
37
|
|
|
$this->context->getSession()->set( 'aimeos', [] ); |
|
38
|
|
|
|
|
39
|
|
|
unset( $this->context, $this->object ); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
public function testAdd() |
|
44
|
|
|
{ |
|
45
|
|
|
$result = $this->object->add( ['order.base.comment' => 'test'] ); |
|
46
|
|
|
|
|
47
|
|
|
$this->assertInstanceOf( \Aimeos\Controller\Frontend\Basket\Iface::class, $result ); |
|
48
|
|
|
$this->assertEquals( 'test', $this->object->get()->getComment() ); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
public function testClear() |
|
53
|
|
|
{ |
|
54
|
|
|
$this->object->addProduct( $this->testItem ); |
|
55
|
|
|
|
|
56
|
|
|
$this->assertInstanceOf( \Aimeos\Controller\Frontend\Basket\Iface::class, $this->object->clear() ); |
|
57
|
|
|
$this->assertEquals( 0, count( $this->object->get()->getProducts() ) ); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
public function testGet() |
|
62
|
|
|
{ |
|
63
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $this->object->get() ); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
|
|
67
|
|
|
public function testSave() |
|
68
|
|
|
{ |
|
69
|
|
|
$stub = $this->getMockBuilder( \Aimeos\MShop\Order\Manager\Base\Standard::class ) |
|
70
|
|
|
->setConstructorArgs( [$this->context] ) |
|
71
|
|
|
->setMethods( ['setSession'] ) |
|
72
|
|
|
->getMock(); |
|
73
|
|
|
|
|
74
|
|
|
\Aimeos\MShop::inject( 'order/base', $stub ); |
|
75
|
|
|
|
|
76
|
|
|
$stub->expects( $this->exactly( 2 ) )->method( 'setSession' ); |
|
77
|
|
|
|
|
78
|
|
|
$object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
79
|
|
|
$object->addProduct( $this->testItem ); |
|
80
|
|
|
|
|
81
|
|
|
$this->assertInstanceOf( \Aimeos\Controller\Frontend\Basket\Iface::class, $object->save() ); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
|
|
85
|
|
|
public function testSetType() |
|
86
|
|
|
{ |
|
87
|
|
|
$this->assertInstanceOf( \Aimeos\Controller\Frontend\Basket\Iface::class, $this->object->setType( 'test' ) ); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
|
|
91
|
|
|
public function testStore() |
|
92
|
|
|
{ |
|
93
|
|
|
$stub = $this->getMockBuilder( \Aimeos\MShop\Order\Manager\Base\Standard::class ) |
|
94
|
|
|
->setConstructorArgs( [$this->context] ) |
|
95
|
|
|
->setMethods( ['store'] ) |
|
96
|
|
|
->getMock(); |
|
97
|
|
|
|
|
98
|
|
|
\Aimeos\MShop::inject( 'order/base', $stub ); |
|
99
|
|
|
|
|
100
|
|
|
$stub->expects( $this->once() )->method( 'store' )->will( $this->returnValue( $stub->createItem() ) ); |
|
101
|
|
|
|
|
102
|
|
|
$object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
103
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $object->store() ); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
|
|
107
|
|
|
public function testStoreLimit() |
|
108
|
|
|
{ |
|
109
|
|
|
$this->context->setEditor( 'core:lib/mshoplib' ); |
|
110
|
|
|
$config = $this->context->getConfig(); |
|
111
|
|
|
$config->set( 'controller/frontend/basket/limit-count', 0 ); |
|
112
|
|
|
$config->set( 'controller/frontend/basket/limit-seconds', 86400 * 365 ); |
|
113
|
|
|
|
|
114
|
|
|
$object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
115
|
|
|
|
|
116
|
|
|
$this->setExpectedException( \Aimeos\Controller\Frontend\Basket\Exception::class ); |
|
117
|
|
|
$object->store(); |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
|
|
121
|
|
|
public function testLoad() |
|
122
|
|
|
{ |
|
123
|
|
|
$stub = $this->getMockBuilder( \Aimeos\MShop\Order\Manager\Base\Standard::class ) |
|
124
|
|
|
->setConstructorArgs( [$this->context] ) |
|
125
|
|
|
->setMethods( ['load'] ) |
|
126
|
|
|
->getMock(); |
|
127
|
|
|
|
|
128
|
|
|
\Aimeos\MShop::inject( 'order/base', $stub ); |
|
129
|
|
|
|
|
130
|
|
|
$stub->expects( $this->once() )->method( 'load' ) |
|
131
|
|
|
->will( $this->returnValue( $stub->createItem() ) ); |
|
132
|
|
|
|
|
133
|
|
|
$object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
134
|
|
|
|
|
135
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $object->load( -1 ) ); |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
|
|
139
|
|
|
public function testAddDeleteProduct() |
|
140
|
|
|
{ |
|
141
|
|
|
$basket = $this->object->get(); |
|
142
|
|
|
$manager = \Aimeos\MShop::create( $this->context, 'product' ); |
|
143
|
|
|
$item = $manager->findItem( 'CNC', ['attribute', 'media', 'price', 'product', 'text'] ); |
|
144
|
|
|
|
|
145
|
|
|
$result1 = $this->object->addProduct( $item, 2, [], [], [], 'default', 'unitsupplier' ); |
|
146
|
|
|
$item2 = $this->object->get()->getProduct( 0 ); |
|
147
|
|
|
$result2 = $this->object->deleteProduct( 0 ); |
|
148
|
|
|
|
|
149
|
|
|
$this->assertEquals( 0, count( $basket->getProducts() ) ); |
|
150
|
|
|
$this->assertEquals( 'CNC', $item2->getProductCode() ); |
|
151
|
|
|
$this->assertEquals( 'default', $item2->getStockType() ); |
|
152
|
|
|
$this->assertEquals( 'unitsupplier', $item2->getSupplierCode() ); |
|
153
|
|
|
$this->assertInstanceOf( \Aimeos\Controller\Frontend\Basket\Iface::class, $result1 ); |
|
154
|
|
|
$this->assertInstanceOf( \Aimeos\Controller\Frontend\Basket\Iface::class, $result2 ); |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
|
|
158
|
|
|
public function testAddProductCustomAttribute() |
|
159
|
|
|
{ |
|
160
|
|
|
$attrItem = \Aimeos\MShop::create( $this->context, 'attribute' )->findItem( 'custom', [], 'product', 'date' ); |
|
161
|
|
|
$attrValues = [$attrItem->getId() => '2000-01-01']; |
|
162
|
|
|
|
|
163
|
|
|
$result = $this->object->addProduct( $this->testItem, 1, [], [], $attrValues ); |
|
164
|
|
|
$basket = $this->object->get(); |
|
165
|
|
|
|
|
166
|
|
|
$this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
167
|
|
|
$this->assertEquals( '2000-01-01', $basket->getProduct( 0 )->getAttribute( 'date', 'custom' ) ); |
|
168
|
|
|
$this->assertInstanceOf( \Aimeos\Controller\Frontend\Basket\Iface::class, $result ); |
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
|
|
|
|
172
|
|
|
public function testAddProductCustomPrice() |
|
173
|
|
|
{ |
|
174
|
|
|
$attrItem = \Aimeos\MShop::create( $this->context, 'attribute' )->findItem( 'custom', [], 'product', 'price' ); |
|
175
|
|
|
$attrValues = [$attrItem->getId() => '0.01']; |
|
176
|
|
|
|
|
177
|
|
|
$result = $this->object->addProduct( $this->testItem, 1, [], [], $attrValues ); |
|
178
|
|
|
$basket = $this->object->get(); |
|
179
|
|
|
|
|
180
|
|
|
$this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
181
|
|
|
$this->assertEquals( '0.01', $basket->getProduct( 0 )->getPrice()->getValue() ); |
|
182
|
|
|
$this->assertInstanceOf( \Aimeos\Controller\Frontend\Basket\Iface::class, $result ); |
|
183
|
|
|
} |
|
184
|
|
|
|
|
185
|
|
|
|
|
186
|
|
|
public function testAddProductCustomPriceException() |
|
187
|
|
|
{ |
|
188
|
|
|
$attrItem = \Aimeos\MShop::create( $this->context, 'attribute' )->findItem( 'custom', [], 'product', 'price' ); |
|
189
|
|
|
$attrValues = [$attrItem->getId() => ',']; |
|
190
|
|
|
|
|
191
|
|
|
$this->setExpectedException( \Aimeos\Controller\Frontend\Basket\Exception::class ); |
|
192
|
|
|
$this->object->addProduct( $this->testItem, 1, [], [], $attrValues ); |
|
193
|
|
|
} |
|
194
|
|
|
|
|
195
|
|
|
|
|
196
|
|
|
public function testAddProductAttributePrice() |
|
197
|
|
|
{ |
|
198
|
|
|
$attrItem = \Aimeos\MShop::create( $this->context, 'attribute' )->findItem( 'xs', [], 'product', 'size' ); |
|
199
|
|
|
|
|
200
|
|
|
$result = $this->object->addProduct( $this->testItem, 1, [], [$attrItem->getId() => 2] ); |
|
201
|
|
|
|
|
202
|
|
|
$this->assertEquals( '43.90', $this->object->get()->getPrice()->getValue() ); |
|
203
|
|
|
$this->assertInstanceOf( \Aimeos\Controller\Frontend\Basket\Iface::class, $result ); |
|
204
|
|
|
} |
|
205
|
|
|
|
|
206
|
|
|
|
|
207
|
|
|
public function testAddProductAttributeNotAssigned() |
|
208
|
|
|
{ |
|
209
|
|
|
$attrItem = \Aimeos\MShop::create( $this->context, 'attribute' )->findItem( '30', [], 'product', 'width' ); |
|
210
|
|
|
$ids = [$attrItem->getId()]; |
|
211
|
|
|
|
|
212
|
|
|
$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
213
|
|
|
$this->object->addProduct( $this->testItem, 1, [], $ids, $ids ); |
|
214
|
|
|
} |
|
215
|
|
|
|
|
216
|
|
|
|
|
217
|
|
|
public function testAddProductNegativeQuantityException() |
|
218
|
|
|
{ |
|
219
|
|
|
$this->setExpectedException( '\\Aimeos\\MShop\\Order\\Exception' ); |
|
220
|
|
|
$this->object->addProduct( $this->testItem, -1 ); |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
|
|
|
|
224
|
|
|
public function testAddProductNoPriceException() |
|
225
|
|
|
{ |
|
226
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'product' )->findItem( 'MNOP' ); |
|
227
|
|
|
|
|
228
|
|
|
$this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' ); |
|
229
|
|
|
$this->object->addProduct( $item ); |
|
230
|
|
|
} |
|
231
|
|
|
|
|
232
|
|
|
|
|
233
|
|
|
public function testAddProductConfigAttributeException() |
|
234
|
|
|
{ |
|
235
|
|
|
$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
236
|
|
|
$this->object->addProduct( $this->testItem, 1, [], [-1] ); |
|
237
|
|
|
} |
|
238
|
|
|
|
|
239
|
|
|
|
|
240
|
|
|
public function testAddProductLowQuantityPriceException() |
|
241
|
|
|
{ |
|
242
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'product' )->findItem( 'IJKL', ['attribute', 'price'] ); |
|
243
|
|
|
|
|
244
|
|
|
$this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' ); |
|
245
|
|
|
$this->object->addProduct( $item ); |
|
246
|
|
|
} |
|
247
|
|
|
|
|
248
|
|
|
|
|
249
|
|
|
public function testAddProductHigherQuantities() |
|
250
|
|
|
{ |
|
251
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'product' )->findItem( 'IJKL' ); |
|
252
|
|
|
|
|
253
|
|
|
$result = $this->object->addProduct( $item, 2 ); |
|
254
|
|
|
|
|
255
|
|
|
$this->assertEquals( 2, $this->object->get()->getProduct( 0 )->getQuantity() ); |
|
256
|
|
|
$this->assertEquals( 'IJKL', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
257
|
|
|
$this->assertInstanceOf( \Aimeos\Controller\Frontend\Basket\Iface::class, $result ); |
|
258
|
|
|
} |
|
259
|
|
|
|
|
260
|
|
|
|
|
261
|
|
|
public function testDeleteProductFlagError() |
|
262
|
|
|
{ |
|
263
|
|
|
$this->object->addProduct( $this->testItem, 2 ); |
|
264
|
|
|
|
|
265
|
|
|
$item = $this->object->get()->getProduct( 0 ); |
|
266
|
|
|
$item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ); |
|
267
|
|
|
|
|
268
|
|
|
$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
269
|
|
|
$this->object->deleteProduct( 0 ); |
|
270
|
|
|
} |
|
271
|
|
|
|
|
272
|
|
|
|
|
273
|
|
|
public function testUpdateProduct() |
|
274
|
|
|
{ |
|
275
|
|
|
$this->object->addProduct( $this->testItem ); |
|
276
|
|
|
|
|
277
|
|
|
$item = $this->object->get()->getProduct( 0 ); |
|
278
|
|
|
$this->assertEquals( 1, $item->getQuantity() ); |
|
279
|
|
|
|
|
280
|
|
|
$result = $this->object->updateProduct( 0, 4 ); |
|
281
|
|
|
$item = $this->object->get()->getProduct( 0 ); |
|
282
|
|
|
|
|
283
|
|
|
$this->assertEquals( 4, $item->getQuantity() ); |
|
284
|
|
|
$this->assertEquals( 'U:TESTP', $item->getProductCode() ); |
|
285
|
|
|
$this->assertInstanceOf( \Aimeos\Controller\Frontend\Basket\Iface::class, $result ); |
|
286
|
|
|
} |
|
287
|
|
|
|
|
288
|
|
|
|
|
289
|
|
|
public function testUpdateProductFlagError() |
|
290
|
|
|
{ |
|
291
|
|
|
$this->object->addProduct( $this->testItem, 2 ); |
|
292
|
|
|
|
|
293
|
|
|
$item = $this->object->get()->getProduct( 0 ); |
|
294
|
|
|
$item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ); |
|
295
|
|
|
|
|
296
|
|
|
$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
297
|
|
|
$this->object->updateProduct( 0, 4 ); |
|
298
|
|
|
} |
|
299
|
|
|
|
|
300
|
|
|
|
|
301
|
|
|
public function testAddCoupon() |
|
302
|
|
|
{ |
|
303
|
|
|
$this->object->addProduct( $this->testItem, 2 ); |
|
304
|
|
|
|
|
305
|
|
|
$result = $this->object->addCoupon( 'GHIJ' ); |
|
306
|
|
|
$basket = $this->object->get(); |
|
307
|
|
|
|
|
308
|
|
|
$this->assertEquals( 1, count( $basket->getCoupons() ) ); |
|
309
|
|
|
$this->assertInstanceOf( \Aimeos\Controller\Frontend\Basket\Iface::class, $result ); |
|
310
|
|
|
} |
|
311
|
|
|
|
|
312
|
|
|
|
|
313
|
|
|
public function testAddCouponExceedCount() |
|
314
|
|
|
{ |
|
315
|
|
|
$this->object->addProduct( $this->testItem, 2 ); |
|
316
|
|
|
$this->object->addCoupon( 'GHIJ' ); |
|
317
|
|
|
|
|
318
|
|
|
$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
319
|
|
|
$this->object->addCoupon( 'GHIJ' ); |
|
320
|
|
|
} |
|
321
|
|
|
|
|
322
|
|
|
|
|
323
|
|
|
public function testAddCouponInvalidCode() |
|
324
|
|
|
{ |
|
325
|
|
|
$this->setExpectedException( \Aimeos\MShop\Plugin\Provider\Exception::class ); |
|
326
|
|
|
$this->object->addCoupon( 'invalid' ); |
|
327
|
|
|
} |
|
328
|
|
|
|
|
329
|
|
|
|
|
330
|
|
|
public function testDeleteCoupon() |
|
331
|
|
|
{ |
|
332
|
|
|
$this->object->addProduct( $this->testItem, 2 ); |
|
333
|
|
|
$this->object->addCoupon( '90AB' ); |
|
334
|
|
|
|
|
335
|
|
|
$result = $this->object->deleteCoupon( '90AB' ); |
|
336
|
|
|
$basket = $this->object->get(); |
|
337
|
|
|
|
|
338
|
|
|
$this->assertEquals( 0, count( $basket->getCoupons() ) ); |
|
339
|
|
|
$this->assertInstanceOf( \Aimeos\Controller\Frontend\Basket\Iface::class, $result ); |
|
340
|
|
|
} |
|
341
|
|
|
|
|
342
|
|
|
|
|
343
|
|
|
public function testSetAddressDelete() |
|
344
|
|
|
{ |
|
345
|
|
|
$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null ); |
|
346
|
|
|
|
|
347
|
|
|
$this->setExpectedException( \Aimeos\MShop\Order\Exception::class ); |
|
348
|
|
|
$this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 0 ); |
|
349
|
|
|
} |
|
350
|
|
|
|
|
351
|
|
|
|
|
352
|
|
|
public function testSetBillingAddressByItem() |
|
353
|
|
|
{ |
|
354
|
|
|
$item = $this->getAddress( 'Example company' ); |
|
355
|
|
|
|
|
356
|
|
|
$result = $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item ); |
|
357
|
|
|
$address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 0 ); |
|
358
|
|
|
|
|
359
|
|
|
$this->assertEquals( 'Example company', $address->getCompany() ); |
|
360
|
|
|
$this->assertInstanceOf( \Aimeos\Controller\Frontend\Basket\Iface::class, $result ); |
|
361
|
|
|
} |
|
362
|
|
|
|
|
363
|
|
|
|
|
364
|
|
|
public function testSetBillingAddressByArray() |
|
365
|
|
|
{ |
|
366
|
|
|
$fixture = array( |
|
367
|
|
|
'order.base.address.company' => '<p onclick="javascript: alert(\'gotcha\');">Example company</p>', |
|
368
|
|
|
'order.base.address.vatid' => 'DE999999999', |
|
369
|
|
|
'order.base.address.title' => '<br/>Dr.', |
|
370
|
|
|
'order.base.address.salutation' => \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR, |
|
371
|
|
|
'order.base.address.firstname' => 'firstunit', |
|
372
|
|
|
'order.base.address.lastname' => 'lastunit', |
|
373
|
|
|
'order.base.address.address1' => 'unit str.', |
|
374
|
|
|
'order.base.address.address2' => ' 166', |
|
375
|
|
|
'order.base.address.address3' => '4.OG', |
|
376
|
|
|
'order.base.address.postal' => '22769', |
|
377
|
|
|
'order.base.address.city' => 'Hamburg', |
|
378
|
|
|
'order.base.address.state' => 'Hamburg', |
|
379
|
|
|
'order.base.address.countryid' => 'de', |
|
380
|
|
|
'order.base.address.languageid' => 'de', |
|
381
|
|
|
'order.base.address.telephone' => '05554433221', |
|
382
|
|
|
'order.base.address.email' => '[email protected]', |
|
383
|
|
|
'order.base.address.telefax' => '05554433222', |
|
384
|
|
|
'order.base.address.website' => 'www.example.com', |
|
385
|
|
|
); |
|
386
|
|
|
|
|
387
|
|
|
$result = $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture ); |
|
388
|
|
|
$address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 0 ); |
|
389
|
|
|
|
|
390
|
|
|
$this->assertEquals( 'Example company', $address->getCompany() ); |
|
391
|
|
|
$this->assertEquals( 'Dr.', $address->getTitle() ); |
|
392
|
|
|
$this->assertEquals( 'firstunit', $address->getFirstname() ); |
|
393
|
|
|
$this->assertInstanceOf( \Aimeos\Controller\Frontend\Basket\Iface::class, $result ); |
|
394
|
|
|
} |
|
395
|
|
|
|
|
396
|
|
|
|
|
397
|
|
|
public function testSetBillingAddressByArrayError() |
|
398
|
|
|
{ |
|
399
|
|
|
$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
400
|
|
|
$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array( 'error' => false ) ); |
|
401
|
|
|
} |
|
402
|
|
|
|
|
403
|
|
|
|
|
404
|
|
|
public function testSetBillingAddressParameterError() |
|
405
|
|
|
{ |
|
406
|
|
|
$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
407
|
|
|
$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error' ); |
|
408
|
|
|
} |
|
409
|
|
|
|
|
410
|
|
|
|
|
411
|
|
|
public function testSetDeliveryAddressByItem() |
|
412
|
|
|
{ |
|
413
|
|
|
$item = $this->getAddress( 'Example company' ); |
|
414
|
|
|
|
|
415
|
|
|
$result = $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item ); |
|
416
|
|
|
$address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 0 ); |
|
417
|
|
|
|
|
418
|
|
|
$this->assertEquals( 'Example company', $address->getCompany() ); |
|
419
|
|
|
$this->assertInstanceOf( \Aimeos\Controller\Frontend\Basket\Iface::class, $result ); |
|
420
|
|
|
} |
|
421
|
|
|
|
|
422
|
|
|
|
|
423
|
|
|
public function testSetDeliveryAddressByArray() |
|
424
|
|
|
{ |
|
425
|
|
|
$fixture = array( |
|
426
|
|
|
'order.base.address.company' => '<p onclick="javascript: alert(\'gotcha\');">Example company</p>', |
|
427
|
|
|
'order.base.address.vatid' => 'DE999999999', |
|
428
|
|
|
'order.base.address.title' => '<br/>Dr.', |
|
429
|
|
|
'order.base.address.salutation' => \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR, |
|
430
|
|
|
'order.base.address.firstname' => 'firstunit', |
|
431
|
|
|
'order.base.address.lastname' => 'lastunit', |
|
432
|
|
|
'order.base.address.address1' => 'unit str.', |
|
433
|
|
|
'order.base.address.address2' => ' 166', |
|
434
|
|
|
'order.base.address.address3' => '4.OG', |
|
435
|
|
|
'order.base.address.postal' => '22769', |
|
436
|
|
|
'order.base.address.city' => 'Hamburg', |
|
437
|
|
|
'order.base.address.state' => 'Hamburg', |
|
438
|
|
|
'order.base.address.countryid' => 'de', |
|
439
|
|
|
'order.base.address.languageid' => 'de', |
|
440
|
|
|
'order.base.address.telephone' => '05554433221', |
|
441
|
|
|
'order.base.address.email' => '[email protected]', |
|
442
|
|
|
'order.base.address.telefax' => '05554433222', |
|
443
|
|
|
'order.base.address.website' => 'www.example.com', |
|
444
|
|
|
); |
|
445
|
|
|
|
|
446
|
|
|
$result = $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture ); |
|
447
|
|
|
$address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 0 ); |
|
448
|
|
|
|
|
449
|
|
|
$this->assertEquals( 'Example company', $address->getCompany() ); |
|
450
|
|
|
$this->assertEquals( 'Dr.', $address->getTitle() ); |
|
451
|
|
|
$this->assertEquals( 'firstunit', $address->getFirstname() ); |
|
452
|
|
|
$this->assertInstanceOf( \Aimeos\Controller\Frontend\Basket\Iface::class, $result ); |
|
453
|
|
|
} |
|
454
|
|
|
|
|
455
|
|
|
|
|
456
|
|
|
public function testSetDeliveryAddressByArrayError() |
|
457
|
|
|
{ |
|
458
|
|
|
$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
459
|
|
|
$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array( 'error' => false ) ); |
|
460
|
|
|
} |
|
461
|
|
|
|
|
462
|
|
|
|
|
463
|
|
|
public function testSetDeliveryAddressTypeError() |
|
464
|
|
|
{ |
|
465
|
|
|
$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
466
|
|
|
$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error' ); |
|
467
|
|
|
} |
|
468
|
|
|
|
|
469
|
|
|
|
|
470
|
|
|
public function testAddServicePayment() |
|
471
|
|
|
{ |
|
472
|
|
|
$manager = \Aimeos\MShop::create( $this->context, 'service' ); |
|
473
|
|
|
$service = $manager->findItem( 'unitpaymentcode', [], 'service', 'payment' ); |
|
474
|
|
|
|
|
475
|
|
|
$this->object->addService( $service ); |
|
476
|
|
|
$item = $this->object->get()->getService( 'payment', 'unitpaymentcode' )->getCode(); |
|
477
|
|
|
$this->assertEquals( 'unitpaymentcode', $item ); |
|
478
|
|
|
|
|
479
|
|
|
$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
480
|
|
|
$this->object->addService( $service, ['prepay' => true] ); |
|
481
|
|
|
} |
|
482
|
|
|
|
|
483
|
|
|
|
|
484
|
|
|
public function testAddServiceDelivery() |
|
485
|
|
|
{ |
|
486
|
|
|
$manager = \Aimeos\MShop::create( $this->context, 'service' ); |
|
487
|
|
|
$service = $manager->findItem( 'unitcode', [], 'service', 'delivery' ); |
|
488
|
|
|
|
|
489
|
|
|
$this->object->addService( $service ); |
|
490
|
|
|
$item = $this->object->get()->getService( 'delivery', 'unitcode' ); |
|
491
|
|
|
$this->assertEquals( 'unitcode', $item->getCode() ); |
|
492
|
|
|
|
|
493
|
|
|
$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
494
|
|
|
$this->object->addService( $service, ['fast shipping' => true, 'air shipping' => false] ); |
|
495
|
|
|
} |
|
496
|
|
|
|
|
497
|
|
|
|
|
498
|
|
|
public function testDeleteServices() |
|
499
|
|
|
{ |
|
500
|
|
|
$manager = \Aimeos\MShop::create( $this->context, 'service' ); |
|
501
|
|
|
$service = $manager->findItem( 'unitcode', [], 'service', 'delivery' ); |
|
502
|
|
|
|
|
503
|
|
|
$this->assertSame( $this->object, $this->object->addService( $service ) ); |
|
504
|
|
|
$this->assertEquals( 'unitcode', $this->object->get()->getService( 'delivery', 'unitcode' )->getCode() ); |
|
505
|
|
|
|
|
506
|
|
|
$this->assertSame( $this->object, $this->object->deleteService( 'delivery' ) ); |
|
507
|
|
|
$this->assertEquals( 0, count( $this->object->get()->getService( 'delivery' ) ) ); |
|
508
|
|
|
} |
|
509
|
|
|
|
|
510
|
|
|
|
|
511
|
|
|
public function testDeleteServicePosition() |
|
512
|
|
|
{ |
|
513
|
|
|
$manager = \Aimeos\MShop::create( $this->context, 'service' ); |
|
514
|
|
|
$service = $manager->findItem( 'unitcode', [], 'service', 'delivery' ); |
|
515
|
|
|
|
|
516
|
|
|
$this->assertSame( $this->object, $this->object->addService( $service ) ); |
|
517
|
|
|
$this->assertEquals( 'unitcode', $this->object->get()->getService( 'delivery', 'unitcode' )->getCode() ); |
|
518
|
|
|
|
|
519
|
|
|
$this->assertSame( $this->object, $this->object->deleteService( 'delivery', 0 ) ); |
|
520
|
|
|
$this->assertEquals( 0, count( $this->object->get()->getService( 'delivery' ) ) ); |
|
521
|
|
|
} |
|
522
|
|
|
|
|
523
|
|
|
|
|
524
|
|
|
public function testCheckLocale() |
|
525
|
|
|
{ |
|
526
|
|
|
$manager = \Aimeos\MShop::create( $this->context, 'service' ); |
|
527
|
|
|
$payment = $manager->findItem( 'unitpaymentcode', [], 'service', 'payment' ); |
|
528
|
|
|
$delivery = $manager->findItem( 'unitcode', [], 'service', 'delivery' ); |
|
529
|
|
|
|
|
530
|
|
|
$this->object->addProduct( $this->testItem, 2 ); |
|
531
|
|
|
$this->object->addCoupon( 'OPQR' ); |
|
532
|
|
|
|
|
533
|
|
|
$this->object->addService( $payment ); |
|
534
|
|
|
$this->object->addService( $delivery ); |
|
535
|
|
|
|
|
536
|
|
|
$basket = $this->object->get(); |
|
537
|
|
|
$price = $basket->getPrice(); |
|
538
|
|
|
|
|
539
|
|
|
foreach( $basket->getProducts() as $product ) |
|
540
|
|
|
{ |
|
541
|
|
|
$this->assertEquals( 2, $product->getQuantity() ); |
|
542
|
|
|
$product->getPrice()->setCurrencyId( 'CHF' ); |
|
543
|
|
|
} |
|
544
|
|
|
|
|
545
|
|
|
$basket->getService( 'delivery', 'unitcode' )->getPrice()->setCurrencyId( 'CHF' ); |
|
546
|
|
|
$basket->getService( 'payment', 'unitpaymentcode' )->getPrice()->setCurrencyId( 'CHF' ); |
|
547
|
|
|
$basket->getLocale()->setCurrencyId( 'CHF' ); |
|
548
|
|
|
$price->setCurrencyId( 'CHF' ); |
|
549
|
|
|
|
|
550
|
|
|
$this->context->getLocale()->setCurrencyId( 'CHF' ); |
|
551
|
|
|
$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress( 'Example company' ) ); |
|
552
|
|
|
|
|
553
|
|
|
$this->context->getSession()->set( 'aimeos/basket/currency', 'CHF' ); |
|
554
|
|
|
$this->context->getLocale()->setCurrencyId( 'EUR' ); |
|
555
|
|
|
|
|
556
|
|
|
$this->context->getSession()->set( 'aimeos/basket/content-unittest-en-EUR-', null ); |
|
557
|
|
|
|
|
558
|
|
|
$object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
559
|
|
|
$basket = $object->get(); |
|
560
|
|
|
|
|
561
|
|
|
foreach( $basket->getProducts() as $product ) |
|
562
|
|
|
{ |
|
563
|
|
|
$this->assertEquals( 'EUR', $product->getPrice()->getCurrencyId() ); |
|
564
|
|
|
$this->assertEquals( 2, $product->getQuantity() ); |
|
565
|
|
|
} |
|
566
|
|
|
|
|
567
|
|
|
$this->assertEquals( 'EUR', $basket->getService( 'payment', 'unitpaymentcode' )->getPrice()->getCurrencyId() ); |
|
568
|
|
|
$this->assertEquals( 'EUR', $basket->getService( 'delivery', 'unitcode' )->getPrice()->getCurrencyId() ); |
|
569
|
|
|
$this->assertEquals( 'EUR', $basket->getLocale()->getCurrencyId() ); |
|
570
|
|
|
$this->assertEquals( 'EUR', $basket->getPrice()->getCurrencyId() ); |
|
571
|
|
|
} |
|
572
|
|
|
|
|
573
|
|
|
|
|
574
|
|
|
/** |
|
575
|
|
|
* @param string $company |
|
576
|
|
|
*/ |
|
577
|
|
|
protected function getAddress( $company ) |
|
578
|
|
|
{ |
|
579
|
|
|
$customer = \Aimeos\MShop\Customer\Manager\Factory::create( \TestHelperFrontend::getContext(), 'Standard' ); |
|
580
|
|
|
$addressManager = $customer->getSubManager( 'address', 'Standard' ); |
|
581
|
|
|
|
|
582
|
|
|
$search = $addressManager->createSearch(); |
|
583
|
|
|
$search->setConditions( $search->compare( '==', 'customer.address.company', $company ) ); |
|
584
|
|
|
$items = $addressManager->searchItems( $search ); |
|
585
|
|
|
|
|
586
|
|
|
if( ( $item = reset( $items ) ) === false ) { |
|
587
|
|
|
throw new \RuntimeException( sprintf( 'No address item with company "%1$s" found', $company ) ); |
|
588
|
|
|
} |
|
589
|
|
|
|
|
590
|
|
|
return $item; |
|
591
|
|
|
} |
|
592
|
|
|
} |
|
593
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths