@@ -19,112 +19,112 @@ discard block |
||
19 | 19 | public static function setUpBeforeClass() |
20 | 20 | { |
21 | 21 | $context = \TestHelperFrontend::getContext(); |
22 | - self::$testItem = \Aimeos\MShop\Factory::createManager( $context, 'product' )->findItem( 'U:TESTP' ); |
|
22 | + self::$testItem = \Aimeos\MShop\Factory::createManager($context, 'product')->findItem('U:TESTP'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | |
26 | 26 | protected function setUp() |
27 | 27 | { |
28 | - \Aimeos\MShop\Factory::setCache( true ); |
|
28 | + \Aimeos\MShop\Factory::setCache(true); |
|
29 | 29 | |
30 | 30 | $this->context = \TestHelperFrontend::getContext(); |
31 | - $this->object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
31 | + $this->object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
35 | 35 | protected function tearDown() |
36 | 36 | { |
37 | - \Aimeos\MShop\Factory::setCache( false ); |
|
37 | + \Aimeos\MShop\Factory::setCache(false); |
|
38 | 38 | \Aimeos\MShop\Factory::clear(); |
39 | 39 | |
40 | 40 | $this->object->clear(); |
41 | - $this->context->getSession()->set( 'aimeos', [] ); |
|
41 | + $this->context->getSession()->set('aimeos', []); |
|
42 | 42 | |
43 | - unset( $this->context, $this->object ); |
|
43 | + unset($this->context, $this->object); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
47 | 47 | public function testClear() |
48 | 48 | { |
49 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
49 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
50 | 50 | $this->object->clear(); |
51 | 51 | |
52 | - $this->assertEquals( 0, count( $this->object->get()->getProducts() ) ); |
|
52 | + $this->assertEquals(0, count($this->object->get()->getProducts())); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | |
56 | 56 | public function testGet() |
57 | 57 | { |
58 | - $this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Base\Iface', $this->object->get() ); |
|
58 | + $this->assertInstanceOf('\Aimeos\MShop\Order\Item\Base\Iface', $this->object->get()); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
62 | 62 | public function testSave() |
63 | 63 | { |
64 | - $stub = $this->getMockBuilder( '\Aimeos\MShop\Order\Manager\Base\Standard' ) |
|
65 | - ->setConstructorArgs( [$this->context] ) |
|
66 | - ->setMethods( ['setSession'] ) |
|
64 | + $stub = $this->getMockBuilder('\Aimeos\MShop\Order\Manager\Base\Standard') |
|
65 | + ->setConstructorArgs([$this->context]) |
|
66 | + ->setMethods(['setSession']) |
|
67 | 67 | ->getMock(); |
68 | 68 | |
69 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'order/base', $stub ); |
|
69 | + \Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $stub); |
|
70 | 70 | |
71 | - $stub->expects( $this->exactly( 2 ) )->method( 'setSession' ); |
|
71 | + $stub->expects($this->exactly(2))->method('setSession'); |
|
72 | 72 | |
73 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
74 | - $object->addProduct( self::$testItem->getId(), 2 ); |
|
73 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
74 | + $object->addProduct(self::$testItem->getId(), 2); |
|
75 | 75 | $object->save(); |
76 | 76 | } |
77 | 77 | |
78 | 78 | |
79 | 79 | public function testSetType() |
80 | 80 | { |
81 | - $this->assertInstanceOf( '\Aimeos\Controller\Frontend\Basket\Iface', $this->object->setType( 'test' ) ); |
|
81 | + $this->assertInstanceOf('\Aimeos\Controller\Frontend\Basket\Iface', $this->object->setType('test')); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
85 | 85 | public function testStore() |
86 | 86 | { |
87 | - $stub = $this->getMockBuilder( '\Aimeos\MShop\Order\Manager\Base\Standard' ) |
|
88 | - ->setConstructorArgs( [$this->context] ) |
|
89 | - ->setMethods( ['store'] ) |
|
87 | + $stub = $this->getMockBuilder('\Aimeos\MShop\Order\Manager\Base\Standard') |
|
88 | + ->setConstructorArgs([$this->context]) |
|
89 | + ->setMethods(['store']) |
|
90 | 90 | ->getMock(); |
91 | 91 | |
92 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'order/base', $stub ); |
|
92 | + \Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $stub); |
|
93 | 93 | |
94 | - $stub->expects( $this->once() )->method( 'store' ); |
|
94 | + $stub->expects($this->once())->method('store'); |
|
95 | 95 | |
96 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
96 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
97 | 97 | $object->store(); |
98 | 98 | } |
99 | 99 | |
100 | 100 | |
101 | 101 | public function testStoreLimit() |
102 | 102 | { |
103 | - $this->context->setEditor( 'core:unittest' ); |
|
103 | + $this->context->setEditor('core:unittest'); |
|
104 | 104 | $config = $this->context->getConfig(); |
105 | - $config->set( 'controller/frontend/basket/limit-count', 0 ); |
|
106 | - $config->set( 'controller/frontend/basket/limit-seconds', 86400 * 365 ); |
|
105 | + $config->set('controller/frontend/basket/limit-count', 0); |
|
106 | + $config->set('controller/frontend/basket/limit-seconds', 86400 * 365); |
|
107 | 107 | |
108 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
108 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
109 | 109 | |
110 | - $this->setExpectedException( '\Aimeos\Controller\Frontend\Basket\Exception' ); |
|
110 | + $this->setExpectedException('\Aimeos\Controller\Frontend\Basket\Exception'); |
|
111 | 111 | $object->store(); |
112 | 112 | } |
113 | 113 | |
114 | 114 | |
115 | 115 | public function testLoad() |
116 | 116 | { |
117 | - $stub = $this->getMockBuilder( '\Aimeos\MShop\Order\Manager\Base\Standard' ) |
|
118 | - ->setConstructorArgs( [$this->context] ) |
|
119 | - ->setMethods( ['load'] ) |
|
117 | + $stub = $this->getMockBuilder('\Aimeos\MShop\Order\Manager\Base\Standard') |
|
118 | + ->setConstructorArgs([$this->context]) |
|
119 | + ->setMethods(['load']) |
|
120 | 120 | ->getMock(); |
121 | 121 | |
122 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'order/base', $stub ); |
|
122 | + \Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $stub); |
|
123 | 123 | |
124 | - $stub->expects( $this->once() )->method( 'load' ) |
|
125 | - ->will( $this->returnValue( $stub->createItem() ) ); |
|
124 | + $stub->expects($this->once())->method('load') |
|
125 | + ->will($this->returnValue($stub->createItem())); |
|
126 | 126 | |
127 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
127 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
128 | 128 | $object->load( -1 ); |
129 | 129 | } |
130 | 130 | |
@@ -132,311 +132,311 @@ discard block |
||
132 | 132 | public function testAddDeleteProduct() |
133 | 133 | { |
134 | 134 | $basket = $this->object->get(); |
135 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' ); |
|
135 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC'); |
|
136 | 136 | |
137 | - $this->object->addProduct( $item->getId(), 2, [], [], [], [], [], 'default' ); |
|
138 | - $item2 = $this->object->get()->getProduct( 0 ); |
|
139 | - $this->object->deleteProduct( 0 ); |
|
137 | + $this->object->addProduct($item->getId(), 2, [], [], [], [], [], 'default'); |
|
138 | + $item2 = $this->object->get()->getProduct(0); |
|
139 | + $this->object->deleteProduct(0); |
|
140 | 140 | |
141 | - $this->assertEquals( 0, count( $basket->getProducts() ) ); |
|
142 | - $this->assertEquals( 'CNC', $item2->getProductCode() ); |
|
141 | + $this->assertEquals(0, count($basket->getProducts())); |
|
142 | + $this->assertEquals('CNC', $item2->getProductCode()); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | |
146 | 146 | public function testAddProductCustomAttribute() |
147 | 147 | { |
148 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
148 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
149 | 149 | |
150 | 150 | $search = $attributeManager->createSearch(); |
151 | 151 | $expr = array( |
152 | - $search->compare( '==', 'attribute.code', 'custom' ), |
|
153 | - $search->compare( '==', 'attribute.type.code', 'date' ), |
|
152 | + $search->compare('==', 'attribute.code', 'custom'), |
|
153 | + $search->compare('==', 'attribute.type.code', 'date'), |
|
154 | 154 | ); |
155 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
155 | + $search->setConditions($search->combine('&&', $expr)); |
|
156 | 156 | |
157 | - $attributes = $attributeManager->searchItems( $search ); |
|
157 | + $attributes = $attributeManager->searchItems($search); |
|
158 | 158 | |
159 | - if( ( $attrItem = reset( $attributes ) ) === false ) { |
|
160 | - throw new \RuntimeException( 'Attribute not found' ); |
|
159 | + if (($attrItem = reset($attributes)) === false) { |
|
160 | + throw new \RuntimeException('Attribute not found'); |
|
161 | 161 | } |
162 | 162 | |
163 | - $attrValues = array( $attrItem->getId() => '2000-01-01' ); |
|
163 | + $attrValues = array($attrItem->getId() => '2000-01-01'); |
|
164 | 164 | |
165 | - $this->object->addProduct( self::$testItem->getId(), 1, [], [], [], [], $attrValues ); |
|
165 | + $this->object->addProduct(self::$testItem->getId(), 1, [], [], [], [], $attrValues); |
|
166 | 166 | $basket = $this->object->get(); |
167 | 167 | |
168 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
169 | - $this->assertEquals( '2000-01-01', $basket->getProduct( 0 )->getAttribute( 'date', 'custom' ) ); |
|
168 | + $this->assertEquals(1, count($basket->getProducts())); |
|
169 | + $this->assertEquals('2000-01-01', $basket->getProduct(0)->getAttribute('date', 'custom')); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | |
173 | 173 | public function testAddProductCustomPrice() |
174 | 174 | { |
175 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
175 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
176 | 176 | |
177 | 177 | $search = $attributeManager->createSearch(); |
178 | 178 | $expr = array( |
179 | - $search->compare( '==', 'attribute.code', 'custom' ), |
|
180 | - $search->compare( '==', 'attribute.type.code', 'price' ), |
|
179 | + $search->compare('==', 'attribute.code', 'custom'), |
|
180 | + $search->compare('==', 'attribute.type.code', 'price'), |
|
181 | 181 | ); |
182 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
182 | + $search->setConditions($search->combine('&&', $expr)); |
|
183 | 183 | |
184 | - $attributes = $attributeManager->searchItems( $search ); |
|
184 | + $attributes = $attributeManager->searchItems($search); |
|
185 | 185 | |
186 | - if( ( $attrItem = reset( $attributes ) ) === false ) { |
|
187 | - throw new \RuntimeException( 'Attribute not found' ); |
|
186 | + if (($attrItem = reset($attributes)) === false) { |
|
187 | + throw new \RuntimeException('Attribute not found'); |
|
188 | 188 | } |
189 | 189 | |
190 | - $attrValues = array( $attrItem->getId() => '0.01' ); |
|
190 | + $attrValues = array($attrItem->getId() => '0.01'); |
|
191 | 191 | |
192 | - $this->object->addProduct( self::$testItem->getId(), 1, [], [], [], [], $attrValues ); |
|
192 | + $this->object->addProduct(self::$testItem->getId(), 1, [], [], [], [], $attrValues); |
|
193 | 193 | $basket = $this->object->get(); |
194 | 194 | |
195 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
196 | - $this->assertEquals( '0.01', $basket->getProduct( 0 )->getPrice()->getValue() ); |
|
195 | + $this->assertEquals(1, count($basket->getProducts())); |
|
196 | + $this->assertEquals('0.01', $basket->getProduct(0)->getPrice()->getValue()); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | |
200 | 200 | public function testAddProductCustomPriceException() |
201 | 201 | { |
202 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
202 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
203 | 203 | |
204 | 204 | $search = $attributeManager->createSearch(); |
205 | 205 | $expr = array( |
206 | - $search->compare( '==', 'attribute.code', 'custom' ), |
|
207 | - $search->compare( '==', 'attribute.type.code', 'price' ), |
|
206 | + $search->compare('==', 'attribute.code', 'custom'), |
|
207 | + $search->compare('==', 'attribute.type.code', 'price'), |
|
208 | 208 | ); |
209 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
209 | + $search->setConditions($search->combine('&&', $expr)); |
|
210 | 210 | |
211 | - $attributes = $attributeManager->searchItems( $search ); |
|
211 | + $attributes = $attributeManager->searchItems($search); |
|
212 | 212 | |
213 | - if( ( $attrItem = reset( $attributes ) ) === false ) { |
|
214 | - throw new \RuntimeException( 'Attribute not found' ); |
|
213 | + if (($attrItem = reset($attributes)) === false) { |
|
214 | + throw new \RuntimeException('Attribute not found'); |
|
215 | 215 | } |
216 | 216 | |
217 | - $attrValues = array( $attrItem->getId() => ',' ); |
|
217 | + $attrValues = array($attrItem->getId() => ','); |
|
218 | 218 | |
219 | - $this->setExpectedException( '\Aimeos\Controller\Frontend\Basket\Exception' ); |
|
220 | - $this->object->addProduct( self::$testItem->getId(), 1, [], [], [], [], $attrValues ); |
|
219 | + $this->setExpectedException('\Aimeos\Controller\Frontend\Basket\Exception'); |
|
220 | + $this->object->addProduct(self::$testItem->getId(), 1, [], [], [], [], $attrValues); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | |
224 | 224 | public function testAddProductAttributeNotAssigned() |
225 | 225 | { |
226 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
226 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
227 | 227 | |
228 | 228 | $search = $attributeManager->createSearch(); |
229 | 229 | $expr = array( |
230 | - $search->compare( '==', 'attribute.code', '30' ), |
|
231 | - $search->compare( '==', 'attribute.type.code', 'width' ), |
|
230 | + $search->compare('==', 'attribute.code', '30'), |
|
231 | + $search->compare('==', 'attribute.type.code', 'width'), |
|
232 | 232 | ); |
233 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
233 | + $search->setConditions($search->combine('&&', $expr)); |
|
234 | 234 | |
235 | - $attribute = $attributeManager->searchItems( $search ); |
|
235 | + $attribute = $attributeManager->searchItems($search); |
|
236 | 236 | |
237 | - if( empty( $attribute ) ) { |
|
238 | - throw new \RuntimeException( 'Attribute not found' ); |
|
237 | + if (empty($attribute)) { |
|
238 | + throw new \RuntimeException('Attribute not found'); |
|
239 | 239 | } |
240 | 240 | |
241 | - $hiddenAttrIds = array_keys( $attribute ); |
|
242 | - $configAttrIds = array_keys( $attribute ); |
|
241 | + $hiddenAttrIds = array_keys($attribute); |
|
242 | + $configAttrIds = array_keys($attribute); |
|
243 | 243 | |
244 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
245 | - $this->object->addProduct( self::$testItem->getId(), 1, [], [], $configAttrIds, $hiddenAttrIds ); |
|
244 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
245 | + $this->object->addProduct(self::$testItem->getId(), 1, [], [], $configAttrIds, $hiddenAttrIds); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | |
249 | 249 | public function testAddProductNegativeQuantityException() |
250 | 250 | { |
251 | - $this->setExpectedException( '\\Aimeos\\MShop\\Order\\Exception' ); |
|
252 | - $this->object->addProduct( self::$testItem->getId(), -1 ); |
|
251 | + $this->setExpectedException('\\Aimeos\\MShop\\Order\\Exception'); |
|
252 | + $this->object->addProduct(self::$testItem->getId(), -1); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | |
256 | 256 | public function testAddProductNoPriceException() |
257 | 257 | { |
258 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'MNOP' ); |
|
258 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('MNOP'); |
|
259 | 259 | |
260 | - $this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' ); |
|
261 | - $this->object->addProduct( $item->getId(), 1 ); |
|
260 | + $this->setExpectedException('\\Aimeos\\MShop\\Price\\Exception'); |
|
261 | + $this->object->addProduct($item->getId(), 1); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | |
265 | 265 | public function testAddProductConfigAttributeException() |
266 | 266 | { |
267 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
268 | - $this->object->addProduct( self::$testItem->getId(), 1, [], [], array( -1 ) ); |
|
267 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
268 | + $this->object->addProduct(self::$testItem->getId(), 1, [], [], array( -1 )); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | |
272 | 272 | public function testAddProductLowQuantityPriceException() |
273 | 273 | { |
274 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'IJKL' ); |
|
274 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('IJKL'); |
|
275 | 275 | |
276 | - $this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' ); |
|
277 | - $this->object->addProduct( $item->getId(), 1 ); |
|
276 | + $this->setExpectedException('\\Aimeos\\MShop\\Price\\Exception'); |
|
277 | + $this->object->addProduct($item->getId(), 1); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | |
281 | 281 | public function testAddProductHigherQuantities() |
282 | 282 | { |
283 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'IJKL' ); |
|
283 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('IJKL'); |
|
284 | 284 | |
285 | - $this->object->addProduct( $item->getId(), 2, [], [], [], [], [], 'unit_type3' ); |
|
285 | + $this->object->addProduct($item->getId(), 2, [], [], [], [], [], 'unit_type3'); |
|
286 | 286 | |
287 | - $this->assertEquals( 2, $this->object->get()->getProduct( 0 )->getQuantity() ); |
|
288 | - $this->assertEquals( 'IJKL', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
287 | + $this->assertEquals(2, $this->object->get()->getProduct(0)->getQuantity()); |
|
288 | + $this->assertEquals('IJKL', $this->object->get()->getProduct(0)->getProductCode()); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | |
292 | 292 | public function testDeleteProductFlagError() |
293 | 293 | { |
294 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
294 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
295 | 295 | |
296 | - $item = $this->object->get()->getProduct( 0 ); |
|
297 | - $item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ); |
|
296 | + $item = $this->object->get()->getProduct(0); |
|
297 | + $item->setFlags(\Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE); |
|
298 | 298 | |
299 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
300 | - $this->object->deleteProduct( 0 ); |
|
299 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
300 | + $this->object->deleteProduct(0); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | |
304 | 304 | public function testEditProduct() |
305 | 305 | { |
306 | - $this->object->addProduct( self::$testItem->getId(), 1 ); |
|
306 | + $this->object->addProduct(self::$testItem->getId(), 1); |
|
307 | 307 | |
308 | - $item = $this->object->get()->getProduct( 0 ); |
|
309 | - $this->assertEquals( 1, $item->getQuantity() ); |
|
308 | + $item = $this->object->get()->getProduct(0); |
|
309 | + $this->assertEquals(1, $item->getQuantity()); |
|
310 | 310 | |
311 | - $this->object->editProduct( 0, 4 ); |
|
311 | + $this->object->editProduct(0, 4); |
|
312 | 312 | |
313 | - $item = $this->object->get()->getProduct( 0 ); |
|
314 | - $this->assertEquals( 4, $item->getQuantity() ); |
|
315 | - $this->assertEquals( 'U:TESTP', $item->getProductCode() ); |
|
313 | + $item = $this->object->get()->getProduct(0); |
|
314 | + $this->assertEquals(4, $item->getQuantity()); |
|
315 | + $this->assertEquals('U:TESTP', $item->getProductCode()); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | |
319 | 319 | public function testEditProductAttributes() |
320 | 320 | { |
321 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
321 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
322 | 322 | |
323 | 323 | $search = $attributeManager->createSearch(); |
324 | 324 | $conditions = array( |
325 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
326 | - $search->combine( '||', array( |
|
327 | - $search->combine( '&&', array( |
|
328 | - $search->compare( '==', 'attribute.code', 'xs' ), |
|
329 | - $search->compare( '==', 'attribute.type.code', 'size' ), |
|
330 | - ) ), |
|
331 | - $search->combine( '&&', array( |
|
332 | - $search->compare( '==', 'attribute.code', 'white' ), |
|
333 | - $search->compare( '==', 'attribute.type.code', 'color' ), |
|
334 | - ) ), |
|
335 | - ) ) |
|
325 | + $search->compare('==', 'attribute.domain', 'product'), |
|
326 | + $search->combine('||', array( |
|
327 | + $search->combine('&&', array( |
|
328 | + $search->compare('==', 'attribute.code', 'xs'), |
|
329 | + $search->compare('==', 'attribute.type.code', 'size'), |
|
330 | + )), |
|
331 | + $search->combine('&&', array( |
|
332 | + $search->compare('==', 'attribute.code', 'white'), |
|
333 | + $search->compare('==', 'attribute.type.code', 'color'), |
|
334 | + )), |
|
335 | + )) |
|
336 | 336 | ); |
337 | - $search->setConditions( $search->combine( '&&', $conditions ) ); |
|
338 | - $attributes = $attributeManager->searchItems( $search ); |
|
337 | + $search->setConditions($search->combine('&&', $conditions)); |
|
338 | + $attributes = $attributeManager->searchItems($search); |
|
339 | 339 | |
340 | - if( ( $attribute = reset( $attributes ) ) === false ) { |
|
341 | - throw new \RuntimeException( 'No attributes available' ); |
|
340 | + if (($attribute = reset($attributes)) === false) { |
|
341 | + throw new \RuntimeException('No attributes available'); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | |
345 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TESTP' ); |
|
345 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TESTP'); |
|
346 | 346 | |
347 | - $this->object->addProduct( $item->getId(), 1, [], [], array_keys( $attributes ) ); |
|
348 | - $this->object->editProduct( 0, 4 ); |
|
347 | + $this->object->addProduct($item->getId(), 1, [], [], array_keys($attributes)); |
|
348 | + $this->object->editProduct(0, 4); |
|
349 | 349 | |
350 | - $item = $this->object->get()->getProduct( 0 ); |
|
351 | - $this->assertEquals( 2, count( $item->getAttributes() ) ); |
|
352 | - $this->assertEquals( 4, $item->getQuantity() ); |
|
350 | + $item = $this->object->get()->getProduct(0); |
|
351 | + $this->assertEquals(2, count($item->getAttributes())); |
|
352 | + $this->assertEquals(4, $item->getQuantity()); |
|
353 | 353 | |
354 | 354 | |
355 | - $this->object->editProduct( 0, 3, [], array( $attribute->getType() ) ); |
|
355 | + $this->object->editProduct(0, 3, [], array($attribute->getType())); |
|
356 | 356 | |
357 | - $item = $this->object->get()->getProduct( 0 ); |
|
358 | - $this->assertEquals( 3, $item->getQuantity() ); |
|
359 | - $this->assertEquals( 1, count( $item->getAttributes() ) ); |
|
360 | - $this->assertEquals( 'U:TESTP', $item->getProductCode() ); |
|
357 | + $item = $this->object->get()->getProduct(0); |
|
358 | + $this->assertEquals(3, $item->getQuantity()); |
|
359 | + $this->assertEquals(1, count($item->getAttributes())); |
|
360 | + $this->assertEquals('U:TESTP', $item->getProductCode()); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | |
364 | 364 | public function testEditProductFlagError() |
365 | 365 | { |
366 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
366 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
367 | 367 | |
368 | - $item = $this->object->get()->getProduct( 0 ); |
|
369 | - $item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ); |
|
368 | + $item = $this->object->get()->getProduct(0); |
|
369 | + $item->setFlags(\Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE); |
|
370 | 370 | |
371 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
372 | - $this->object->editProduct( 0, 4 ); |
|
371 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
372 | + $this->object->editProduct(0, 4); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | |
376 | 376 | public function testAddCoupon() |
377 | 377 | { |
378 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
379 | - $this->object->addCoupon( 'GHIJ' ); |
|
378 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
379 | + $this->object->addCoupon('GHIJ'); |
|
380 | 380 | |
381 | 381 | $basket = $this->object->get(); |
382 | 382 | |
383 | - $this->assertEquals( 1, count( $basket->getCoupons() ) ); |
|
383 | + $this->assertEquals(1, count($basket->getCoupons())); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | |
387 | 387 | public function testAddCouponExceedCount() |
388 | 388 | { |
389 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
390 | - $this->object->addCoupon( 'GHIJ' ); |
|
389 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
390 | + $this->object->addCoupon('GHIJ'); |
|
391 | 391 | |
392 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
393 | - $this->object->addCoupon( 'GHIJ' ); |
|
392 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
393 | + $this->object->addCoupon('GHIJ'); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | |
397 | 397 | public function testAddCouponInvalidCode() |
398 | 398 | { |
399 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
400 | - $this->object->addCoupon( 'invalid' ); |
|
399 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
400 | + $this->object->addCoupon('invalid'); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | |
404 | 404 | public function testAddCouponMissingRequirements() |
405 | 405 | { |
406 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
407 | - $this->object->addCoupon( 'OPQR' ); |
|
406 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
407 | + $this->object->addCoupon('OPQR'); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | |
411 | 411 | public function testDeleteCoupon() |
412 | 412 | { |
413 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
414 | - $this->object->addCoupon( '90AB' ); |
|
415 | - $this->object->deleteCoupon( '90AB' ); |
|
413 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
414 | + $this->object->addCoupon('90AB'); |
|
415 | + $this->object->deleteCoupon('90AB'); |
|
416 | 416 | |
417 | 417 | $basket = $this->object->get(); |
418 | 418 | |
419 | - $this->assertEquals( 0, count( $basket->getCoupons() ) ); |
|
419 | + $this->assertEquals(0, count($basket->getCoupons())); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | |
423 | 423 | public function testSetAddressDelete() |
424 | 424 | { |
425 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null ); |
|
425 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null); |
|
426 | 426 | |
427 | - $this->setExpectedException( '\Aimeos\MShop\Order\Exception' ); |
|
428 | - $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
427 | + $this->setExpectedException('\Aimeos\MShop\Order\Exception'); |
|
428 | + $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | |
432 | 432 | public function testSetBillingAddressByItem() |
433 | 433 | { |
434 | - $item = $this->getAddress( 'Example company' ); |
|
434 | + $item = $this->getAddress('Example company'); |
|
435 | 435 | |
436 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item ); |
|
436 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item); |
|
437 | 437 | |
438 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
439 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
438 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
439 | + $this->assertEquals('Example company', $address->getCompany()); |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | |
@@ -464,37 +464,37 @@ discard block |
||
464 | 464 | 'order.base.address.flag' => 0, |
465 | 465 | ); |
466 | 466 | |
467 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture ); |
|
467 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture); |
|
468 | 468 | |
469 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
470 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
471 | - $this->assertEquals( 'Dr.', $address->getTitle() ); |
|
472 | - $this->assertEquals( 'firstunit', $address->getFirstname() ); |
|
469 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
470 | + $this->assertEquals('Example company', $address->getCompany()); |
|
471 | + $this->assertEquals('Dr.', $address->getTitle()); |
|
472 | + $this->assertEquals('firstunit', $address->getFirstname()); |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | |
476 | 476 | public function testSetBillingAddressByArrayError() |
477 | 477 | { |
478 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
479 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array( 'error' => false ) ); |
|
478 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
479 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array('error' => false)); |
|
480 | 480 | } |
481 | 481 | |
482 | 482 | |
483 | 483 | public function testSetBillingAddressParameterError() |
484 | 484 | { |
485 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
486 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error' ); |
|
485 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
486 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error'); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | |
490 | 490 | public function testSetDeliveryAddressByItem() |
491 | 491 | { |
492 | - $item = $this->getAddress( 'Example company' ); |
|
492 | + $item = $this->getAddress('Example company'); |
|
493 | 493 | |
494 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item ); |
|
494 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item); |
|
495 | 495 | |
496 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY ); |
|
497 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
496 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY); |
|
497 | + $this->assertEquals('Example company', $address->getCompany()); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | |
@@ -521,119 +521,119 @@ discard block |
||
521 | 521 | 'order.base.address.website' => 'www.example.com', |
522 | 522 | 'order.base.address.flag' => 0, |
523 | 523 | ); |
524 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture ); |
|
524 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture); |
|
525 | 525 | |
526 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY ); |
|
527 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
528 | - $this->assertEquals( 'Dr.', $address->getTitle() ); |
|
529 | - $this->assertEquals( 'firstunit', $address->getFirstname() ); |
|
526 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY); |
|
527 | + $this->assertEquals('Example company', $address->getCompany()); |
|
528 | + $this->assertEquals('Dr.', $address->getTitle()); |
|
529 | + $this->assertEquals('firstunit', $address->getFirstname()); |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | |
533 | 533 | public function testSetDeliveryAddressByArrayError() |
534 | 534 | { |
535 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
536 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array( 'error' => false ) ); |
|
535 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
536 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array('error' => false)); |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | |
540 | 540 | public function testSetDeliveryAddressTypeError() |
541 | 541 | { |
542 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
543 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error' ); |
|
542 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
543 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error'); |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | |
547 | 547 | public function testSetServicePayment() |
548 | 548 | { |
549 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
550 | - $service = $manager->findItem( 'unitpaymentcode', [], 'service', 'payment' ); |
|
549 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
550 | + $service = $manager->findItem('unitpaymentcode', [], 'service', 'payment'); |
|
551 | 551 | |
552 | - $this->object->setService( 'payment', $service->getId(), [] ); |
|
553 | - $this->assertEquals( 'unitpaymentcode', $this->object->get()->getService( 'payment' )->getCode() ); |
|
552 | + $this->object->setService('payment', $service->getId(), []); |
|
553 | + $this->assertEquals('unitpaymentcode', $this->object->get()->getService('payment')->getCode()); |
|
554 | 554 | |
555 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
556 | - $this->object->setService( 'payment', $service->getId(), array( 'prepay' => true ) ); |
|
555 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
556 | + $this->object->setService('payment', $service->getId(), array('prepay' => true)); |
|
557 | 557 | } |
558 | 558 | |
559 | 559 | |
560 | 560 | public function testSetDeliveryOption() |
561 | 561 | { |
562 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
563 | - $service = $manager->findItem( 'unitcode', [], 'service', 'delivery' ); |
|
562 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
563 | + $service = $manager->findItem('unitcode', [], 'service', 'delivery'); |
|
564 | 564 | |
565 | - $this->object->setService( 'delivery', $service->getId(), [] ); |
|
566 | - $this->assertEquals( 'unitcode', $this->object->get()->getService( 'delivery' )->getCode() ); |
|
565 | + $this->object->setService('delivery', $service->getId(), []); |
|
566 | + $this->assertEquals('unitcode', $this->object->get()->getService('delivery')->getCode()); |
|
567 | 567 | |
568 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
569 | - $this->object->setService( 'delivery', $service->getId(), array( 'fast shipping' => true, 'air shipping' => false ) ); |
|
568 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
569 | + $this->object->setService('delivery', $service->getId(), array('fast shipping' => true, 'air shipping' => false)); |
|
570 | 570 | } |
571 | 571 | |
572 | 572 | |
573 | 573 | public function testCheckLocale() |
574 | 574 | { |
575 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
576 | - $payment = $manager->findItem( 'unitpaymentcode', [], 'service', 'payment' ); |
|
577 | - $delivery = $manager->findItem( 'unitcode', [], 'service', 'delivery' ); |
|
575 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
576 | + $payment = $manager->findItem('unitpaymentcode', [], 'service', 'payment'); |
|
577 | + $delivery = $manager->findItem('unitcode', [], 'service', 'delivery'); |
|
578 | 578 | |
579 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
580 | - $this->object->addCoupon( 'OPQR' ); |
|
579 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
580 | + $this->object->addCoupon('OPQR'); |
|
581 | 581 | |
582 | - $this->object->setService( 'payment', $payment->getId() ); |
|
583 | - $this->object->setService( 'delivery', $delivery->getId() ); |
|
582 | + $this->object->setService('payment', $payment->getId()); |
|
583 | + $this->object->setService('delivery', $delivery->getId()); |
|
584 | 584 | |
585 | 585 | $basket = $this->object->get(); |
586 | 586 | $price = $basket->getPrice(); |
587 | 587 | |
588 | - foreach( $basket->getProducts() as $product ) |
|
588 | + foreach ($basket->getProducts() as $product) |
|
589 | 589 | { |
590 | - $this->assertEquals( 2, $product->getQuantity() ); |
|
591 | - $product->getPrice()->setCurrencyId( 'CHF' ); |
|
590 | + $this->assertEquals(2, $product->getQuantity()); |
|
591 | + $product->getPrice()->setCurrencyId('CHF'); |
|
592 | 592 | } |
593 | 593 | |
594 | - $basket->getService( 'delivery' )->getPrice()->setCurrencyId( 'CHF' ); |
|
595 | - $basket->getService( 'payment' )->getPrice()->setCurrencyId( 'CHF' ); |
|
596 | - $basket->getLocale()->setCurrencyId( 'CHF' ); |
|
597 | - $price->setCurrencyId( 'CHF' ); |
|
594 | + $basket->getService('delivery')->getPrice()->setCurrencyId('CHF'); |
|
595 | + $basket->getService('payment')->getPrice()->setCurrencyId('CHF'); |
|
596 | + $basket->getLocale()->setCurrencyId('CHF'); |
|
597 | + $price->setCurrencyId('CHF'); |
|
598 | 598 | |
599 | - $this->context->getLocale()->setCurrencyId( 'CHF' ); |
|
600 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress( 'Example company' ) ); |
|
599 | + $this->context->getLocale()->setCurrencyId('CHF'); |
|
600 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress('Example company')); |
|
601 | 601 | |
602 | - $this->context->getSession()->set( 'aimeos/basket/currency', 'CHF' ); |
|
603 | - $this->context->getLocale()->setCurrencyId( 'EUR' ); |
|
602 | + $this->context->getSession()->set('aimeos/basket/currency', 'CHF'); |
|
603 | + $this->context->getLocale()->setCurrencyId('EUR'); |
|
604 | 604 | |
605 | - $this->context->getSession()->set( 'aimeos/basket/content-unittest-en-EUR-', null ); |
|
605 | + $this->context->getSession()->set('aimeos/basket/content-unittest-en-EUR-', null); |
|
606 | 606 | |
607 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
607 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
608 | 608 | $basket = $object->get(); |
609 | 609 | |
610 | - foreach( $basket->getProducts() as $product ) |
|
610 | + foreach ($basket->getProducts() as $product) |
|
611 | 611 | { |
612 | - $this->assertEquals( 'EUR', $product->getPrice()->getCurrencyId() ); |
|
613 | - $this->assertEquals( 2, $product->getQuantity() ); |
|
612 | + $this->assertEquals('EUR', $product->getPrice()->getCurrencyId()); |
|
613 | + $this->assertEquals(2, $product->getQuantity()); |
|
614 | 614 | } |
615 | 615 | |
616 | - $this->assertEquals( 'EUR', $basket->getService( 'payment' )->getPrice()->getCurrencyId() ); |
|
617 | - $this->assertEquals( 'EUR', $basket->getService( 'delivery' )->getPrice()->getCurrencyId() ); |
|
618 | - $this->assertEquals( 'EUR', $basket->getLocale()->getCurrencyId() ); |
|
619 | - $this->assertEquals( 'EUR', $basket->getPrice()->getCurrencyId() ); |
|
616 | + $this->assertEquals('EUR', $basket->getService('payment')->getPrice()->getCurrencyId()); |
|
617 | + $this->assertEquals('EUR', $basket->getService('delivery')->getPrice()->getCurrencyId()); |
|
618 | + $this->assertEquals('EUR', $basket->getLocale()->getCurrencyId()); |
|
619 | + $this->assertEquals('EUR', $basket->getPrice()->getCurrencyId()); |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | |
623 | 623 | /** |
624 | 624 | * @param string $company |
625 | 625 | */ |
626 | - protected function getAddress( $company ) |
|
626 | + protected function getAddress($company) |
|
627 | 627 | { |
628 | - $customer = \Aimeos\MShop\Customer\Manager\Factory::createManager( \TestHelperFrontend::getContext(), 'Standard' ); |
|
629 | - $addressManager = $customer->getSubManager( 'address', 'Standard' ); |
|
628 | + $customer = \Aimeos\MShop\Customer\Manager\Factory::createManager(\TestHelperFrontend::getContext(), 'Standard'); |
|
629 | + $addressManager = $customer->getSubManager('address', 'Standard'); |
|
630 | 630 | |
631 | 631 | $search = $addressManager->createSearch(); |
632 | - $search->setConditions( $search->compare( '==', 'customer.address.company', $company ) ); |
|
633 | - $items = $addressManager->searchItems( $search ); |
|
632 | + $search->setConditions($search->compare('==', 'customer.address.company', $company)); |
|
633 | + $items = $addressManager->searchItems($search); |
|
634 | 634 | |
635 | - if( ( $item = reset( $items ) ) === false ) { |
|
636 | - throw new \RuntimeException( sprintf( 'No address item with company "%1$s" found', $company ) ); |
|
635 | + if (($item = reset($items)) === false) { |
|
636 | + throw new \RuntimeException(sprintf('No address item with company "%1$s" found', $company)); |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | return $item; |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | * @param \Aimeos\MShop\Context\Item\Iface $context Object storing the required instances for manaing databases |
34 | 34 | * connections, logger, session, etc. |
35 | 35 | */ |
36 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context ) |
|
36 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context) |
|
37 | 37 | { |
38 | - parent::__construct( $context ); |
|
38 | + parent::__construct($context); |
|
39 | 39 | |
40 | - $this->domainManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' ); |
|
40 | + $this->domainManager = \Aimeos\MShop\Factory::createManager($context, 'order/base'); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | public function clear() |
50 | 50 | { |
51 | 51 | $this->baskets[$this->type] = $this->domainManager->createItem(); |
52 | - $this->domainManager->setSession( $this->baskets[$this->type], $this->type ); |
|
52 | + $this->domainManager->setSession($this->baskets[$this->type], $this->type); |
|
53 | 53 | |
54 | 54 | return $this; |
55 | 55 | } |
@@ -62,10 +62,10 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function get() |
64 | 64 | { |
65 | - if( !isset( $this->baskets[$this->type] ) ) |
|
65 | + if (!isset($this->baskets[$this->type])) |
|
66 | 66 | { |
67 | - $this->baskets[$this->type] = $this->domainManager->getSession( $this->type ); |
|
68 | - $this->checkLocale( $this->type ); |
|
67 | + $this->baskets[$this->type] = $this->domainManager->getSession($this->type); |
|
68 | + $this->checkLocale($this->type); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | return $this->baskets[$this->type]; |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function save() |
81 | 81 | { |
82 | - if( isset( $this->baskets[$this->type] ) && $this->baskets[$this->type]->isModified() ) { |
|
83 | - $this->domainManager->setSession( $this->baskets[$this->type], $this->type ); |
|
82 | + if (isset($this->baskets[$this->type]) && $this->baskets[$this->type]->isModified()) { |
|
83 | + $this->domainManager->setSession($this->baskets[$this->type], $this->type); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | return $this; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param string $type Basket type |
94 | 94 | * @return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object |
95 | 95 | */ |
96 | - public function setType( $type ) |
|
96 | + public function setType($type) |
|
97 | 97 | { |
98 | 98 | $this->type = $type; |
99 | 99 | return $this; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @category Developer |
128 | 128 | * @see controller/frontend/basket/limit-seconds |
129 | 129 | */ |
130 | - $count = $config->get( 'controller/frontend/basket/limit-count', 5 ); |
|
130 | + $count = $config->get('controller/frontend/basket/limit-count', 5); |
|
131 | 131 | |
132 | 132 | /** controller/frontend/basket/limit-seconds |
133 | 133 | * Order limitation time frame in seconds |
@@ -145,28 +145,28 @@ discard block |
||
145 | 145 | * @category Developer |
146 | 146 | * @see controller/frontend/basket/limit-count |
147 | 147 | */ |
148 | - $seconds = $config->get( 'controller/frontend/basket/limit-seconds', 300 ); |
|
148 | + $seconds = $config->get('controller/frontend/basket/limit-seconds', 300); |
|
149 | 149 | |
150 | 150 | $search = $this->domainManager->createSearch(); |
151 | 151 | $expr = [ |
152 | - $search->compare( '==', 'order.base.editor', $context->getEditor() ), |
|
153 | - $search->compare( '>=', 'order.base.ctime', date( 'Y-m-d H:i:s', time() - $seconds ) ), |
|
152 | + $search->compare('==', 'order.base.editor', $context->getEditor()), |
|
153 | + $search->compare('>=', 'order.base.ctime', date('Y-m-d H:i:s', time() - $seconds)), |
|
154 | 154 | ]; |
155 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
156 | - $search->setSlice( 0, 0 ); |
|
155 | + $search->setConditions($search->combine('&&', $expr)); |
|
156 | + $search->setSlice(0, 0); |
|
157 | 157 | |
158 | - $this->domainManager->searchItems( $search, [], $total ); |
|
158 | + $this->domainManager->searchItems($search, [], $total); |
|
159 | 159 | |
160 | - if( $total > $count ) { |
|
161 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Temporary order limit reached' ) ); |
|
160 | + if ($total > $count) { |
|
161 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Temporary order limit reached')); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | |
165 | 165 | $basket = $this->get()->finish(); |
166 | - $basket->setCustomerId( (string) $context->getUserId() ); |
|
166 | + $basket->setCustomerId((string) $context->getUserId()); |
|
167 | 167 | |
168 | 168 | $this->domainManager->begin(); |
169 | - $this->domainManager->store( $basket ); |
|
169 | + $this->domainManager->store($basket); |
|
170 | 170 | $this->domainManager->commit(); |
171 | 171 | |
172 | 172 | return $basket; |
@@ -181,9 +181,9 @@ discard block |
||
181 | 181 | * @param boolean $default True to add default criteria (user logged in), false if not |
182 | 182 | * @return \Aimeos\MShop\Order\Item\Base\Iface Order base object including the given parts |
183 | 183 | */ |
184 | - public function load( $id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true ) |
|
184 | + public function load($id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true) |
|
185 | 185 | { |
186 | - return $this->domainManager->load( $id, $parts, false, $default ); |
|
186 | + return $this->domainManager->load($id, $parts, false, $default); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | |
@@ -203,34 +203,34 @@ discard block |
||
203 | 203 | * @param string $stocktype Unique code of the stock type to deliver the products from |
204 | 204 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
205 | 205 | */ |
206 | - public function addProduct( $prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [], |
|
206 | + public function addProduct($prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [], |
|
207 | 207 | array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [], |
208 | - $stocktype = 'default' ) |
|
208 | + $stocktype = 'default') |
|
209 | 209 | { |
210 | 210 | $attributeMap = [ |
211 | - 'custom' => array_keys( $customAttributeValues ), |
|
211 | + 'custom' => array_keys($customAttributeValues), |
|
212 | 212 | 'config' => $configAttributeIds, |
213 | 213 | 'hidden' => $hiddenAttributeIds, |
214 | 214 | ]; |
215 | - $this->checkListRef( $prodid, 'attribute', $attributeMap ); |
|
215 | + $this->checkListRef($prodid, 'attribute', $attributeMap); |
|
216 | 216 | |
217 | 217 | |
218 | 218 | $context = $this->getContext(); |
219 | - $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
220 | - $productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ), true ); |
|
221 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
219 | + $productManager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
220 | + $productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text'), true); |
|
221 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
222 | 222 | |
223 | - $orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem(); |
|
224 | - $orderBaseProductItem->copyFrom( $productItem )->setQuantity( $quantity )->setStockType( $stocktype ); |
|
223 | + $orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem(); |
|
224 | + $orderBaseProductItem->copyFrom($productItem)->setQuantity($quantity)->setStockType($stocktype); |
|
225 | 225 | |
226 | - $attr = $this->getOrderProductAttributes( 'custom', array_keys( $customAttributeValues ), $customAttributeValues ); |
|
227 | - $attr = array_merge( $attr, $this->getOrderProductAttributes( 'config', $configAttributeIds ) ); |
|
228 | - $attr = array_merge( $attr, $this->getOrderProductAttributes( 'hidden', $hiddenAttributeIds ) ); |
|
226 | + $attr = $this->getOrderProductAttributes('custom', array_keys($customAttributeValues), $customAttributeValues); |
|
227 | + $attr = array_merge($attr, $this->getOrderProductAttributes('config', $configAttributeIds)); |
|
228 | + $attr = array_merge($attr, $this->getOrderProductAttributes('hidden', $hiddenAttributeIds)); |
|
229 | 229 | |
230 | - $orderBaseProductItem->setAttributes( $attr ); |
|
231 | - $orderBaseProductItem->setPrice( $this->calcPrice( $orderBaseProductItem, $prices, $quantity ) ); |
|
230 | + $orderBaseProductItem->setAttributes($attr); |
|
231 | + $orderBaseProductItem->setPrice($this->calcPrice($orderBaseProductItem, $prices, $quantity)); |
|
232 | 232 | |
233 | - $this->get()->addProduct( $orderBaseProductItem ); |
|
233 | + $this->get()->addProduct($orderBaseProductItem); |
|
234 | 234 | $this->save(); |
235 | 235 | } |
236 | 236 | |
@@ -240,17 +240,17 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @param integer $position Position number (key) of the order product item |
242 | 242 | */ |
243 | - public function deleteProduct( $position ) |
|
243 | + public function deleteProduct($position) |
|
244 | 244 | { |
245 | - $product = $this->get()->getProduct( $position ); |
|
245 | + $product = $this->get()->getProduct($position); |
|
246 | 246 | |
247 | - if( $product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) |
|
247 | + if ($product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) |
|
248 | 248 | { |
249 | - $msg = sprintf( 'Basket item at position "%1$d" cannot be deleted manually', $position ); |
|
250 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
249 | + $msg = sprintf('Basket item at position "%1$d" cannot be deleted manually', $position); |
|
250 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
251 | 251 | } |
252 | 252 | |
253 | - $this->get()->deleteProduct( $position ); |
|
253 | + $this->get()->deleteProduct($position); |
|
254 | 254 | $this->save(); |
255 | 255 | } |
256 | 256 | |
@@ -264,33 +264,33 @@ discard block |
||
264 | 264 | * The 'stock'=>false option allows adding products without being in stock. |
265 | 265 | * @param string[] $configAttributeCodes Codes of the product config attributes that should be REMOVED |
266 | 266 | */ |
267 | - public function editProduct( $position, $quantity, array $options = [], |
|
268 | - array $configAttributeCodes = [] ) |
|
267 | + public function editProduct($position, $quantity, array $options = [], |
|
268 | + array $configAttributeCodes = []) |
|
269 | 269 | { |
270 | - $product = $this->get()->getProduct( $position ); |
|
270 | + $product = $this->get()->getProduct($position); |
|
271 | 271 | |
272 | - if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) |
|
272 | + if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) |
|
273 | 273 | { |
274 | - $msg = sprintf( 'Basket item at position "%1$d" cannot be changed', $position ); |
|
275 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
274 | + $msg = sprintf('Basket item at position "%1$d" cannot be changed', $position); |
|
275 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
276 | 276 | } |
277 | 277 | |
278 | - $product->setQuantity( $quantity ); |
|
278 | + $product->setQuantity($quantity); |
|
279 | 279 | |
280 | 280 | $attributes = $product->getAttributes(); |
281 | - foreach( $attributes as $key => $attribute ) |
|
281 | + foreach ($attributes as $key => $attribute) |
|
282 | 282 | { |
283 | - if( in_array( $attribute->getCode(), $configAttributeCodes ) ) { |
|
284 | - unset( $attributes[$key] ); |
|
283 | + if (in_array($attribute->getCode(), $configAttributeCodes)) { |
|
284 | + unset($attributes[$key]); |
|
285 | 285 | } |
286 | 286 | } |
287 | - $product->setAttributes( $attributes ); |
|
287 | + $product->setAttributes($attributes); |
|
288 | 288 | |
289 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
290 | - $productItem = $manager->findItem( $product->getProductCode(), array( 'price', 'text' ) ); |
|
291 | - $product->setPrice( $this->calcPrice( $product, $productItem->getRefItems( 'price', 'default' ), $quantity ) ); |
|
289 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
290 | + $productItem = $manager->findItem($product->getProductCode(), array('price', 'text')); |
|
291 | + $product->setPrice($this->calcPrice($product, $productItem->getRefItems('price', 'default'), $quantity)); |
|
292 | 292 | |
293 | - $this->get()->editProduct( $product, $position ); |
|
293 | + $this->get()->editProduct($product, $position); |
|
294 | 294 | |
295 | 295 | $this->save(); |
296 | 296 | } |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @param string $code Coupon code entered by the user |
303 | 303 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed |
304 | 304 | */ |
305 | - public function addCoupon( $code ) |
|
305 | + public function addCoupon($code) |
|
306 | 306 | { |
307 | 307 | $context = $this->getContext(); |
308 | 308 | |
@@ -322,55 +322,55 @@ discard block |
||
322 | 322 | * @category User |
323 | 323 | * @category Developer |
324 | 324 | */ |
325 | - $allowed = $context->getConfig()->get( 'client/html/basket/standard/coupon/allowed', 1 ); // @deprecated |
|
326 | - $allowed = $context->getConfig()->get( 'controller/frontend/basket/standard/coupon/allowed', $allowed ); |
|
325 | + $allowed = $context->getConfig()->get('client/html/basket/standard/coupon/allowed', 1); // @deprecated |
|
326 | + $allowed = $context->getConfig()->get('controller/frontend/basket/standard/coupon/allowed', $allowed); |
|
327 | 327 | |
328 | - if( $allowed <= count( $this->get()->getCoupons() ) ) { |
|
329 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Number of coupon codes exceeds the limit' ) ); |
|
328 | + if ($allowed <= count($this->get()->getCoupons())) { |
|
329 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Number of coupon codes exceeds the limit')); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | |
333 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' ); |
|
334 | - $codeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon/code' ); |
|
333 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon'); |
|
334 | + $codeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon/code'); |
|
335 | 335 | |
336 | 336 | |
337 | - $search = $codeManager->createSearch( true ); |
|
337 | + $search = $codeManager->createSearch(true); |
|
338 | 338 | $expr = array( |
339 | - $search->compare( '==', 'coupon.code.code', $code ), |
|
339 | + $search->compare('==', 'coupon.code.code', $code), |
|
340 | 340 | $search->getConditions(), |
341 | 341 | ); |
342 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
343 | - $search->setSlice( 0, 1 ); |
|
342 | + $search->setConditions($search->combine('&&', $expr)); |
|
343 | + $search->setSlice(0, 1); |
|
344 | 344 | |
345 | - $result = $codeManager->searchItems( $search ); |
|
345 | + $result = $codeManager->searchItems($search); |
|
346 | 346 | |
347 | - if( ( $codeItem = reset( $result ) ) === false ) { |
|
348 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon code "%1$s" is invalid or not available any more', $code ) ); |
|
347 | + if (($codeItem = reset($result)) === false) { |
|
348 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon code "%1$s" is invalid or not available any more', $code)); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | |
352 | - $search = $manager->createSearch( true ); |
|
352 | + $search = $manager->createSearch(true); |
|
353 | 353 | $expr = array( |
354 | - $search->compare( '==', 'coupon.id', $codeItem->getParentId() ), |
|
354 | + $search->compare('==', 'coupon.id', $codeItem->getParentId()), |
|
355 | 355 | $search->getConditions(), |
356 | 356 | ); |
357 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
358 | - $search->setSlice( 0, 1 ); |
|
357 | + $search->setConditions($search->combine('&&', $expr)); |
|
358 | + $search->setSlice(0, 1); |
|
359 | 359 | |
360 | - $result = $manager->searchItems( $search ); |
|
360 | + $result = $manager->searchItems($search); |
|
361 | 361 | |
362 | - if( ( $item = reset( $result ) ) === false ) { |
|
363 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon for code "%1$s" is not available any more', $code ) ); |
|
362 | + if (($item = reset($result)) === false) { |
|
363 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon for code "%1$s" is not available any more', $code)); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | |
367 | - $provider = $manager->getProvider( $item, $codeItem->getCode() ); |
|
367 | + $provider = $manager->getProvider($item, $codeItem->getCode()); |
|
368 | 368 | |
369 | - if( $provider->isAvailable( $this->get() ) !== true ) { |
|
370 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Requirements for coupon code "%1$s" aren\'t met', $code ) ); |
|
369 | + if ($provider->isAvailable($this->get()) !== true) { |
|
370 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Requirements for coupon code "%1$s" aren\'t met', $code)); |
|
371 | 371 | } |
372 | 372 | |
373 | - $provider->addCoupon( $this->get() ); |
|
373 | + $provider->addCoupon($this->get()); |
|
374 | 374 | $this->save(); |
375 | 375 | } |
376 | 376 | |
@@ -381,21 +381,21 @@ discard block |
||
381 | 381 | * @param string $code Coupon code entered by the user |
382 | 382 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid |
383 | 383 | */ |
384 | - public function deleteCoupon( $code ) |
|
384 | + public function deleteCoupon($code) |
|
385 | 385 | { |
386 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' ); |
|
386 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon'); |
|
387 | 387 | |
388 | 388 | $search = $manager->createSearch(); |
389 | - $search->setConditions( $search->compare( '==', 'coupon.code.code', $code ) ); |
|
390 | - $search->setSlice( 0, 1 ); |
|
389 | + $search->setConditions($search->compare('==', 'coupon.code.code', $code)); |
|
390 | + $search->setSlice(0, 1); |
|
391 | 391 | |
392 | - $result = $manager->searchItems( $search ); |
|
392 | + $result = $manager->searchItems($search); |
|
393 | 393 | |
394 | - if( ( $item = reset( $result ) ) === false ) { |
|
395 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon code "%1$s" is invalid', $code ) ); |
|
394 | + if (($item = reset($result)) === false) { |
|
395 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon code "%1$s" is invalid', $code)); |
|
396 | 396 | } |
397 | 397 | |
398 | - $manager->getProvider( $item, $code )->deleteCoupon( $this->get() ); |
|
398 | + $manager->getProvider($item, $code)->deleteCoupon($this->get()); |
|
399 | 399 | $this->save(); |
400 | 400 | } |
401 | 401 | |
@@ -408,28 +408,28 @@ discard block |
||
408 | 408 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the billing or delivery address is not of any required type of |
409 | 409 | * if one of the keys is invalid when using an array with key/value pairs |
410 | 410 | */ |
411 | - public function setAddress( $type, $value ) |
|
411 | + public function setAddress($type, $value) |
|
412 | 412 | { |
413 | - $address = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/address' )->createItem(); |
|
414 | - $address->setType( $type ); |
|
413 | + $address = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/address')->createItem(); |
|
414 | + $address->setType($type); |
|
415 | 415 | |
416 | - if( $value instanceof \Aimeos\MShop\Common\Item\Address\Iface ) |
|
416 | + if ($value instanceof \Aimeos\MShop\Common\Item\Address\Iface) |
|
417 | 417 | { |
418 | - $address->copyFrom( $value ); |
|
419 | - $this->get()->setAddress( $address, $type ); |
|
418 | + $address->copyFrom($value); |
|
419 | + $this->get()->setAddress($address, $type); |
|
420 | 420 | } |
421 | - else if( is_array( $value ) ) |
|
421 | + else if (is_array($value)) |
|
422 | 422 | { |
423 | - $this->setAddressFromArray( $address, $value ); |
|
424 | - $this->get()->setAddress( $address, $type ); |
|
423 | + $this->setAddressFromArray($address, $value); |
|
424 | + $this->get()->setAddress($address, $type); |
|
425 | 425 | } |
426 | - else if( $value === null ) |
|
426 | + else if ($value === null) |
|
427 | 427 | { |
428 | - $this->get()->deleteAddress( $type ); |
|
428 | + $this->get()->deleteAddress($type); |
|
429 | 429 | } |
430 | 430 | else |
431 | 431 | { |
432 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Invalid value for address type "%1$s"', $type ) ); |
|
432 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Invalid value for address type "%1$s"', $type)); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | $this->save(); |
@@ -445,48 +445,48 @@ discard block |
||
445 | 445 | * entered by the customer when choosing one of the delivery or payment options |
446 | 446 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
447 | 447 | */ |
448 | - public function setService( $type, $id, array $attributes = [] ) |
|
448 | + public function setService($type, $id, array $attributes = []) |
|
449 | 449 | { |
450 | - if( $id === null ) |
|
450 | + if ($id === null) |
|
451 | 451 | { |
452 | - $this->get()->deleteService( $type ); |
|
452 | + $this->get()->deleteService($type); |
|
453 | 453 | $this->save(); |
454 | 454 | return; |
455 | 455 | } |
456 | 456 | |
457 | 457 | $context = $this->getContext(); |
458 | 458 | |
459 | - $serviceManager = \Aimeos\MShop\Factory::createManager( $context, 'service' ); |
|
460 | - $serviceItem = $serviceManager->getItem( $id, array( 'media', 'price', 'text' ) ); |
|
459 | + $serviceManager = \Aimeos\MShop\Factory::createManager($context, 'service'); |
|
460 | + $serviceItem = $serviceManager->getItem($id, array('media', 'price', 'text')); |
|
461 | 461 | |
462 | - $provider = $serviceManager->getProvider( $serviceItem ); |
|
463 | - $result = $provider->checkConfigFE( $attributes ); |
|
464 | - $unknown = array_diff_key( $attributes, $result ); |
|
462 | + $provider = $serviceManager->getProvider($serviceItem); |
|
463 | + $result = $provider->checkConfigFE($attributes); |
|
464 | + $unknown = array_diff_key($attributes, $result); |
|
465 | 465 | |
466 | - if( count( $unknown ) > 0 ) |
|
466 | + if (count($unknown) > 0) |
|
467 | 467 | { |
468 | - $msg = sprintf( 'Unknown attributes "%1$s"', implode( '","', array_keys( $unknown ) ) ); |
|
469 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
468 | + $msg = sprintf('Unknown attributes "%1$s"', implode('","', array_keys($unknown))); |
|
469 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
470 | 470 | } |
471 | 471 | |
472 | - foreach( $result as $key => $value ) |
|
472 | + foreach ($result as $key => $value) |
|
473 | 473 | { |
474 | - if( $value !== null ) { |
|
475 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $value ); |
|
474 | + if ($value !== null) { |
|
475 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($value); |
|
476 | 476 | } |
477 | 477 | } |
478 | 478 | |
479 | - $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/service' ); |
|
479 | + $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/service'); |
|
480 | 480 | $orderServiceItem = $orderBaseServiceManager->createItem(); |
481 | - $orderServiceItem->copyFrom( $serviceItem ); |
|
481 | + $orderServiceItem->copyFrom($serviceItem); |
|
482 | 482 | |
483 | 483 | // remove service rebate of original price |
484 | - $price = $provider->calcPrice( $this->get() )->setRebate( '0.00' ); |
|
485 | - $orderServiceItem->setPrice( $price ); |
|
484 | + $price = $provider->calcPrice($this->get())->setRebate('0.00'); |
|
485 | + $orderServiceItem->setPrice($price); |
|
486 | 486 | |
487 | - $provider->setConfigFE( $orderServiceItem, $attributes ); |
|
487 | + $provider->setConfigFE($orderServiceItem, $attributes); |
|
488 | 488 | |
489 | - $this->get()->setService( $orderServiceItem, $type ); |
|
489 | + $this->get()->setService($orderServiceItem, $type); |
|
490 | 490 | $this->save(); |
491 | 491 | } |
492 | 492 | |
@@ -499,18 +499,18 @@ discard block |
||
499 | 499 | * an address item. |
500 | 500 | * @throws \Aimeos\Controller\Frontend\Basket\Exception |
501 | 501 | */ |
502 | - protected function setAddressFromArray( \Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map ) |
|
502 | + protected function setAddressFromArray(\Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map) |
|
503 | 503 | { |
504 | - foreach( $map as $key => $value ) { |
|
505 | - $map[$key] = strip_tags( $value ); // prevent XSS |
|
504 | + foreach ($map as $key => $value) { |
|
505 | + $map[$key] = strip_tags($value); // prevent XSS |
|
506 | 506 | } |
507 | 507 | |
508 | - $errors = $address->fromArray( $map ); |
|
508 | + $errors = $address->fromArray($map); |
|
509 | 509 | |
510 | - if( count( $errors ) > 0 ) |
|
510 | + if (count($errors) > 0) |
|
511 | 511 | { |
512 | - $msg = sprintf( 'Invalid address properties, please check your input' ); |
|
513 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg, 0, null, $errors ); |
|
512 | + $msg = sprintf('Invalid address properties, please check your input'); |
|
513 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg, 0, null, $errors); |
|
514 | 514 | } |
515 | 515 | } |
516 | 516 | } |