@@ -17,33 +17,33 @@ |
||
17 | 17 | protected function setUp() |
18 | 18 | { |
19 | 19 | $context = \TestHelperFrontend::getContext(); |
20 | - $cntl = new \Aimeos\Controller\Frontend\Catalog\Standard( $context ); |
|
20 | + $cntl = new \Aimeos\Controller\Frontend\Catalog\Standard($context); |
|
21 | 21 | |
22 | - $this->object = new \Aimeos\Controller\Frontend\Common\Decorator\Example( $cntl, $context ); |
|
22 | + $this->object = new \Aimeos\Controller\Frontend\Common\Decorator\Example($cntl, $context); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | |
26 | 26 | public function testCall() |
27 | 27 | { |
28 | - $this->assertInstanceOf( '\Aimeos\MShop\Common\Manager\Iface', $this->object->createManager( 'product' ) ); |
|
28 | + $this->assertInstanceOf('\Aimeos\MShop\Common\Manager\Iface', $this->object->createManager('product')); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | |
32 | 32 | public function testCallInvalid() |
33 | 33 | { |
34 | - $this->setExpectedException( '\Aimeos\Controller\Frontend\Exception' ); |
|
34 | + $this->setExpectedException('\Aimeos\Controller\Frontend\Exception'); |
|
35 | 35 | $this->object->invalidMethod(); |
36 | 36 | } |
37 | 37 | |
38 | 38 | |
39 | 39 | public function testGetContext() |
40 | 40 | { |
41 | - $this->assertInstanceOf( '\Aimeos\MShop\Context\Item\Iface', $this->object->getContext() ); |
|
41 | + $this->assertInstanceOf('\Aimeos\MShop\Context\Item\Iface', $this->object->getContext()); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | |
45 | 45 | public function testGetController() |
46 | 46 | { |
47 | - $this->assertInstanceOf( '\Aimeos\Controller\Frontend\Iface', $this->object->getController() ); |
|
47 | + $this->assertInstanceOf('\Aimeos\Controller\Frontend\Iface', $this->object->getController()); |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | \ No newline at end of file |
@@ -18,17 +18,17 @@ discard block |
||
18 | 18 | protected function setUp() |
19 | 19 | { |
20 | 20 | $this->context = \TestHelperFrontend::getContext(); |
21 | - $this->object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
21 | + $this->object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
22 | 22 | |
23 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
23 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
24 | 24 | |
25 | 25 | $search = $productManager->createSearch(); |
26 | - $search->setConditions( $search->compare( '==', 'product.code', 'U:TESTP' ) ); |
|
26 | + $search->setConditions($search->compare('==', 'product.code', 'U:TESTP')); |
|
27 | 27 | |
28 | - $items = $productManager->searchItems( $search, array( 'text' ) ); |
|
28 | + $items = $productManager->searchItems($search, array('text')); |
|
29 | 29 | |
30 | - if( ( $this->testItem = reset( $items ) ) === false ) { |
|
31 | - throw new \Exception( 'Product not found' ); |
|
30 | + if (($this->testItem = reset($items)) === false) { |
|
31 | + throw new \Exception('Product not found'); |
|
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | protected function tearDown() |
37 | 37 | { |
38 | 38 | $this->object->clear(); |
39 | - $this->context->getSession()->set( 'aimeos', array() ); |
|
39 | + $this->context->getSession()->set('aimeos', array()); |
|
40 | 40 | |
41 | - unset( $this->object, $this->testItem ); |
|
41 | + unset($this->object, $this->testItem); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | |
@@ -47,584 +47,584 @@ discard block |
||
47 | 47 | $basket = $this->object->get(); |
48 | 48 | |
49 | 49 | |
50 | - $this->object->addProduct( $this->testItem->getId(), 2 ); |
|
50 | + $this->object->addProduct($this->testItem->getId(), 2); |
|
51 | 51 | |
52 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
53 | - $this->assertEquals( 2, $basket->getProduct( 0 )->getQuantity() ); |
|
54 | - $this->assertEquals( 'U:TESTPSUB01', $basket->getProduct( 0 )->getProductCode() ); |
|
52 | + $this->assertEquals(1, count($basket->getProducts())); |
|
53 | + $this->assertEquals(2, $basket->getProduct(0)->getQuantity()); |
|
54 | + $this->assertEquals('U:TESTPSUB01', $basket->getProduct(0)->getProductCode()); |
|
55 | 55 | |
56 | 56 | |
57 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
57 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
58 | 58 | |
59 | 59 | $search = $productManager->createSearch(); |
60 | - $search->setConditions( $search->compare( '==', 'product.code', 'CNC' ) ); |
|
60 | + $search->setConditions($search->compare('==', 'product.code', 'CNC')); |
|
61 | 61 | |
62 | - $items = $productManager->searchItems( $search, array( 'text' ) ); |
|
62 | + $items = $productManager->searchItems($search, array('text')); |
|
63 | 63 | |
64 | - if( ( $item = reset( $items ) ) === false ) { |
|
65 | - throw new \Exception( 'Product not found' ); |
|
64 | + if (($item = reset($items)) === false) { |
|
65 | + throw new \Exception('Product not found'); |
|
66 | 66 | } |
67 | 67 | |
68 | - $this->object->addProduct( $item->getId(), 2, array(), array(), array(), array(), array(), 'default' ); |
|
69 | - $item2 = $this->object->get()->getProduct( 1 ); |
|
70 | - $this->object->deleteProduct( 0 ); |
|
68 | + $this->object->addProduct($item->getId(), 2, array(), array(), array(), array(), array(), 'default'); |
|
69 | + $item2 = $this->object->get()->getProduct(1); |
|
70 | + $this->object->deleteProduct(0); |
|
71 | 71 | |
72 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
73 | - $this->assertEquals( $item2, $basket->getProduct( 1 ) ); |
|
74 | - $this->assertEquals( 'CNC', $basket->getProduct( 1 )->getProductCode() ); |
|
72 | + $this->assertEquals(1, count($basket->getProducts())); |
|
73 | + $this->assertEquals($item2, $basket->getProduct(1)); |
|
74 | + $this->assertEquals('CNC', $basket->getProduct(1)->getProductCode()); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
78 | 78 | public function testAddProductBundle() |
79 | 79 | { |
80 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
80 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
81 | 81 | |
82 | 82 | $search = $productManager->createSearch(); |
83 | - $search->setConditions( $search->compare( '==', 'product.code', 'U:BUNDLE' ) ); |
|
83 | + $search->setConditions($search->compare('==', 'product.code', 'U:BUNDLE')); |
|
84 | 84 | |
85 | - $items = $productManager->searchItems( $search ); |
|
85 | + $items = $productManager->searchItems($search); |
|
86 | 86 | |
87 | - if( ( $item = reset( $items ) ) === false ) { |
|
88 | - throw new \Exception( 'Product not found' ); |
|
87 | + if (($item = reset($items)) === false) { |
|
88 | + throw new \Exception('Product not found'); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | |
92 | - $this->object->addProduct( $item->getId(), 1 ); |
|
92 | + $this->object->addProduct($item->getId(), 1); |
|
93 | 93 | |
94 | - $this->assertEquals( 1, count( $this->object->get()->getProducts() ) ); |
|
95 | - $this->assertEquals( 'U:BUNDLE', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
96 | - $this->assertEquals( 2, count( $this->object->get()->getProduct( 0 )->getProducts() ) ); |
|
94 | + $this->assertEquals(1, count($this->object->get()->getProducts())); |
|
95 | + $this->assertEquals('U:BUNDLE', $this->object->get()->getProduct(0)->getProductCode()); |
|
96 | + $this->assertEquals(2, count($this->object->get()->getProduct(0)->getProducts())); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
100 | 100 | public function testAddProductVariant() |
101 | 101 | { |
102 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
102 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
103 | 103 | |
104 | 104 | $search = $productManager->createSearch(); |
105 | - $search->setConditions( $search->compare( '==', 'product.code', 'CNC' ) ); |
|
105 | + $search->setConditions($search->compare('==', 'product.code', 'CNC')); |
|
106 | 106 | |
107 | - $items = $productManager->searchItems( $search, array( 'text' ) ); |
|
107 | + $items = $productManager->searchItems($search, array('text')); |
|
108 | 108 | |
109 | - if( ( $item = reset( $items ) ) === false ) { |
|
110 | - throw new \Exception( 'Product not found' ); |
|
109 | + if (($item = reset($items)) === false) { |
|
110 | + throw new \Exception('Product not found'); |
|
111 | 111 | } |
112 | 112 | |
113 | - $attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
113 | + $attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
114 | 114 | |
115 | 115 | $search = $attributeManager->createSearch(); |
116 | - $search->setConditions( $search->compare( '==', 'attribute.code', array( 'xs', 'white' ) ) ); |
|
116 | + $search->setConditions($search->compare('==', 'attribute.code', array('xs', 'white'))); |
|
117 | 117 | |
118 | - $attributes = $attributeManager->searchItems( $search ); |
|
118 | + $attributes = $attributeManager->searchItems($search); |
|
119 | 119 | |
120 | - if( count( $attributes ) === 0 ) { |
|
121 | - throw new \Exception( 'Attributes not found' ); |
|
120 | + if (count($attributes) === 0) { |
|
121 | + throw new \Exception('Attributes not found'); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | |
125 | - $this->object->addProduct( $item->getId(), 1, array(), array_keys( $attributes ), array(), array(), array(), 'default' ); |
|
125 | + $this->object->addProduct($item->getId(), 1, array(), array_keys($attributes), array(), array(), array(), 'default'); |
|
126 | 126 | |
127 | - $this->assertEquals( 1, count( $this->object->get()->getProducts() ) ); |
|
128 | - $this->assertEquals( 'CNC', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
127 | + $this->assertEquals(1, count($this->object->get()->getProducts())); |
|
128 | + $this->assertEquals('CNC', $this->object->get()->getProduct(0)->getProductCode()); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | |
132 | 132 | public function testAddProductVariantIncomplete() |
133 | 133 | { |
134 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
134 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
135 | 135 | |
136 | 136 | $search = $productManager->createSearch(); |
137 | - $search->setConditions( $search->compare( '==', 'product.code', 'U:TEST' ) ); |
|
137 | + $search->setConditions($search->compare('==', 'product.code', 'U:TEST')); |
|
138 | 138 | |
139 | - $items = $productManager->searchItems( $search, array() ); |
|
139 | + $items = $productManager->searchItems($search, array()); |
|
140 | 140 | |
141 | - if( ( $item = reset( $items ) ) === false ) { |
|
142 | - throw new \Exception( 'Product not found' ); |
|
141 | + if (($item = reset($items)) === false) { |
|
142 | + throw new \Exception('Product not found'); |
|
143 | 143 | } |
144 | 144 | |
145 | - $attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
145 | + $attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
146 | 146 | |
147 | 147 | $search = $attributeManager->createSearch(); |
148 | 148 | $expr = array( |
149 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
150 | - $search->compare( '==', 'attribute.code', '30' ), |
|
151 | - $search->compare( '==', 'attribute.type.code', 'length' ), |
|
149 | + $search->compare('==', 'attribute.domain', 'product'), |
|
150 | + $search->compare('==', 'attribute.code', '30'), |
|
151 | + $search->compare('==', 'attribute.type.code', 'length'), |
|
152 | 152 | ); |
153 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
153 | + $search->setConditions($search->combine('&&', $expr)); |
|
154 | 154 | |
155 | - $attributes = $attributeManager->searchItems( $search ); |
|
155 | + $attributes = $attributeManager->searchItems($search); |
|
156 | 156 | |
157 | - if( count( $attributes ) === 0 ) { |
|
158 | - throw new \Exception( 'Attributes not found' ); |
|
157 | + if (count($attributes) === 0) { |
|
158 | + throw new \Exception('Attributes not found'); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | |
162 | - $this->object->addProduct( $item->getId(), 1, array(), array_keys( $attributes ) ); |
|
162 | + $this->object->addProduct($item->getId(), 1, array(), array_keys($attributes)); |
|
163 | 163 | |
164 | - $this->assertEquals( 1, count( $this->object->get()->getProducts() ) ); |
|
165 | - $this->assertEquals( 'U:TESTSUB02', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
166 | - $this->assertEquals( 2, count( $this->object->get()->getProduct( 0 )->getAttributes() ) ); |
|
164 | + $this->assertEquals(1, count($this->object->get()->getProducts())); |
|
165 | + $this->assertEquals('U:TESTSUB02', $this->object->get()->getProduct(0)->getProductCode()); |
|
166 | + $this->assertEquals(2, count($this->object->get()->getProduct(0)->getAttributes())); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | |
170 | 170 | public function testAddProductVariantNonUnique() |
171 | 171 | { |
172 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
172 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
173 | 173 | |
174 | 174 | $search = $productManager->createSearch(); |
175 | - $search->setConditions( $search->compare( '==', 'product.code', 'U:TEST' ) ); |
|
175 | + $search->setConditions($search->compare('==', 'product.code', 'U:TEST')); |
|
176 | 176 | |
177 | - $items = $productManager->searchItems( $search, array() ); |
|
177 | + $items = $productManager->searchItems($search, array()); |
|
178 | 178 | |
179 | - if( ( $item = reset( $items ) ) === false ) { |
|
180 | - throw new \Exception( 'Product not found' ); |
|
179 | + if (($item = reset($items)) === false) { |
|
180 | + throw new \Exception('Product not found'); |
|
181 | 181 | } |
182 | 182 | |
183 | - $attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
183 | + $attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
184 | 184 | |
185 | 185 | $search = $attributeManager->createSearch(); |
186 | 186 | $expr = array( |
187 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
188 | - $search->compare( '==', 'attribute.code', '30' ), |
|
189 | - $search->compare( '==', 'attribute.type.code', 'width' ), |
|
187 | + $search->compare('==', 'attribute.domain', 'product'), |
|
188 | + $search->compare('==', 'attribute.code', '30'), |
|
189 | + $search->compare('==', 'attribute.type.code', 'width'), |
|
190 | 190 | ); |
191 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
191 | + $search->setConditions($search->combine('&&', $expr)); |
|
192 | 192 | |
193 | - $attributes = $attributeManager->searchItems( $search ); |
|
193 | + $attributes = $attributeManager->searchItems($search); |
|
194 | 194 | |
195 | - if( count( $attributes ) === 0 ) { |
|
196 | - throw new \Exception( 'Attributes not found' ); |
|
195 | + if (count($attributes) === 0) { |
|
196 | + throw new \Exception('Attributes not found'); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | |
200 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
201 | - $this->object->addProduct( $item->getId(), 1, array(), array_keys( $attributes ) ); |
|
200 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
201 | + $this->object->addProduct($item->getId(), 1, array(), array_keys($attributes)); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | |
205 | 205 | public function testAddProductVariantNotRequired() |
206 | 206 | { |
207 | - $attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
207 | + $attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
208 | 208 | |
209 | 209 | $search = $attributeManager->createSearch(); |
210 | - $search->setConditions( $search->compare( '==', 'attribute.code', 'xs' ) ); |
|
210 | + $search->setConditions($search->compare('==', 'attribute.code', 'xs')); |
|
211 | 211 | |
212 | - $attributes = $attributeManager->searchItems( $search ); |
|
212 | + $attributes = $attributeManager->searchItems($search); |
|
213 | 213 | |
214 | - if( count( $attributes ) === 0 ) { |
|
215 | - throw new \Exception( 'Attribute not found' ); |
|
214 | + if (count($attributes) === 0) { |
|
215 | + throw new \Exception('Attribute not found'); |
|
216 | 216 | } |
217 | 217 | |
218 | - $options = array( 'variant' => false ); |
|
218 | + $options = array('variant' => false); |
|
219 | 219 | |
220 | - $this->object->addProduct( $this->testItem->getId(), 1, $options, array_keys( $attributes ) ); |
|
220 | + $this->object->addProduct($this->testItem->getId(), 1, $options, array_keys($attributes)); |
|
221 | 221 | |
222 | - $this->assertEquals( 1, count( $this->object->get()->getProducts() ) ); |
|
223 | - $this->assertEquals( 'U:TESTP', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
222 | + $this->assertEquals(1, count($this->object->get()->getProducts())); |
|
223 | + $this->assertEquals('U:TESTP', $this->object->get()->getProduct(0)->getProductCode()); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | |
227 | 227 | public function testAddProductConfigAttribute() |
228 | 228 | { |
229 | - $attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
229 | + $attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
230 | 230 | |
231 | 231 | $search = $attributeManager->createSearch(); |
232 | - $search->setConditions( $search->compare( '==', 'attribute.code', 'xs' ) ); |
|
232 | + $search->setConditions($search->compare('==', 'attribute.code', 'xs')); |
|
233 | 233 | |
234 | - $attributes = $attributeManager->searchItems( $search ); |
|
234 | + $attributes = $attributeManager->searchItems($search); |
|
235 | 235 | |
236 | - if( empty( $attributes ) ) { |
|
237 | - throw new \Exception( 'Attribute not found' ); |
|
236 | + if (empty($attributes)) { |
|
237 | + throw new \Exception('Attribute not found'); |
|
238 | 238 | } |
239 | 239 | |
240 | - $this->object->addProduct( $this->testItem->getId(), 1, array(), array(), array_keys( $attributes ) ); |
|
240 | + $this->object->addProduct($this->testItem->getId(), 1, array(), array(), array_keys($attributes)); |
|
241 | 241 | $basket = $this->object->get(); |
242 | 242 | |
243 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
244 | - $this->assertEquals( 'U:TESTPSUB01', $basket->getProduct( 0 )->getProductCode() ); |
|
245 | - $this->assertEquals( 'xs', $basket->getProduct( 0 )->getAttribute( 'size', 'config' ) ); |
|
243 | + $this->assertEquals(1, count($basket->getProducts())); |
|
244 | + $this->assertEquals('U:TESTPSUB01', $basket->getProduct(0)->getProductCode()); |
|
245 | + $this->assertEquals('xs', $basket->getProduct(0)->getAttribute('size', 'config')); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | |
249 | 249 | public function testAddProductHiddenAttribute() |
250 | 250 | { |
251 | - $attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
251 | + $attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
252 | 252 | |
253 | 253 | $search = $attributeManager->createSearch(); |
254 | 254 | $expr = array( |
255 | - $search->compare( '==', 'attribute.code', '29' ), |
|
256 | - $search->compare( '==', 'attribute.type.code', 'width' ), |
|
255 | + $search->compare('==', 'attribute.code', '29'), |
|
256 | + $search->compare('==', 'attribute.type.code', 'width'), |
|
257 | 257 | ); |
258 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
258 | + $search->setConditions($search->combine('&&', $expr)); |
|
259 | 259 | |
260 | - $attributes = $attributeManager->searchItems( $search ); |
|
260 | + $attributes = $attributeManager->searchItems($search); |
|
261 | 261 | |
262 | - if( empty( $attributes ) ) { |
|
263 | - throw new \Exception( 'Attribute not found' ); |
|
262 | + if (empty($attributes)) { |
|
263 | + throw new \Exception('Attribute not found'); |
|
264 | 264 | } |
265 | 265 | |
266 | - $this->object->addProduct( $this->testItem->getId(), 1, array(), array(), array(), array_keys( $attributes ) ); |
|
266 | + $this->object->addProduct($this->testItem->getId(), 1, array(), array(), array(), array_keys($attributes)); |
|
267 | 267 | |
268 | 268 | $basket = $this->object->get(); |
269 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
269 | + $this->assertEquals(1, count($basket->getProducts())); |
|
270 | 270 | |
271 | - $product = $basket->getProduct( 0 ); |
|
272 | - $this->assertEquals( 'U:TESTPSUB01', $product->getProductCode() ); |
|
271 | + $product = $basket->getProduct(0); |
|
272 | + $this->assertEquals('U:TESTPSUB01', $product->getProductCode()); |
|
273 | 273 | |
274 | 274 | $attributes = $product->getAttributes(); |
275 | - $this->assertEquals( 1, count( $attributes ) ); |
|
275 | + $this->assertEquals(1, count($attributes)); |
|
276 | 276 | |
277 | - if( ( $attribute = reset( $attributes ) ) === false ) { |
|
278 | - throw new \Exception( 'No attribute' ); |
|
277 | + if (($attribute = reset($attributes)) === false) { |
|
278 | + throw new \Exception('No attribute'); |
|
279 | 279 | } |
280 | 280 | |
281 | - $this->assertEquals( 'hidden', $attribute->getType() ); |
|
282 | - $this->assertEquals( '29', $product->getAttribute( 'width', 'hidden' ) ); |
|
281 | + $this->assertEquals('hidden', $attribute->getType()); |
|
282 | + $this->assertEquals('29', $product->getAttribute('width', 'hidden')); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | |
286 | 286 | public function testAddProductCustomAttribute() |
287 | 287 | { |
288 | - $attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
288 | + $attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
289 | 289 | |
290 | 290 | $search = $attributeManager->createSearch(); |
291 | 291 | $expr = array( |
292 | - $search->compare( '==', 'attribute.code', 'custom' ), |
|
293 | - $search->compare( '==', 'attribute.type.code', 'date' ), |
|
292 | + $search->compare('==', 'attribute.code', 'custom'), |
|
293 | + $search->compare('==', 'attribute.type.code', 'date'), |
|
294 | 294 | ); |
295 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
295 | + $search->setConditions($search->combine('&&', $expr)); |
|
296 | 296 | |
297 | - $attributes = $attributeManager->searchItems( $search ); |
|
297 | + $attributes = $attributeManager->searchItems($search); |
|
298 | 298 | |
299 | - if( ( $attrItem = reset( $attributes ) ) === false ) { |
|
300 | - throw new \Exception( 'Attribute not found' ); |
|
299 | + if (($attrItem = reset($attributes)) === false) { |
|
300 | + throw new \Exception('Attribute not found'); |
|
301 | 301 | } |
302 | 302 | |
303 | - $attrValues = array( $attrItem->getId() => '2000-01-01' ); |
|
303 | + $attrValues = array($attrItem->getId() => '2000-01-01'); |
|
304 | 304 | |
305 | - $this->object->addProduct( $this->testItem->getId(), 1, array(), array(), array(), array(), $attrValues ); |
|
305 | + $this->object->addProduct($this->testItem->getId(), 1, array(), array(), array(), array(), $attrValues); |
|
306 | 306 | $basket = $this->object->get(); |
307 | 307 | |
308 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
309 | - $this->assertEquals( '2000-01-01', $basket->getProduct( 0 )->getAttribute( 'date', 'custom' ) ); |
|
308 | + $this->assertEquals(1, count($basket->getProducts())); |
|
309 | + $this->assertEquals('2000-01-01', $basket->getProduct(0)->getAttribute('date', 'custom')); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | |
313 | 313 | public function testAddProductAttributeNotAssigned() |
314 | 314 | { |
315 | - $attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
315 | + $attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
316 | 316 | |
317 | 317 | $search = $attributeManager->createSearch(); |
318 | 318 | $expr = array( |
319 | - $search->compare( '==', 'attribute.code', '30' ), |
|
320 | - $search->compare( '==', 'attribute.type.code', 'width' ), |
|
319 | + $search->compare('==', 'attribute.code', '30'), |
|
320 | + $search->compare('==', 'attribute.type.code', 'width'), |
|
321 | 321 | ); |
322 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
322 | + $search->setConditions($search->combine('&&', $expr)); |
|
323 | 323 | |
324 | - $attribute = $attributeManager->searchItems( $search ); |
|
324 | + $attribute = $attributeManager->searchItems($search); |
|
325 | 325 | |
326 | - if( empty( $attribute ) ) { |
|
327 | - throw new \Exception( 'Attribute not found' ); |
|
326 | + if (empty($attribute)) { |
|
327 | + throw new \Exception('Attribute not found'); |
|
328 | 328 | } |
329 | 329 | |
330 | - $hiddenAttrIds = array_keys( $attribute ); |
|
331 | - $configAttrIds = array_keys( $attribute ); |
|
330 | + $hiddenAttrIds = array_keys($attribute); |
|
331 | + $configAttrIds = array_keys($attribute); |
|
332 | 332 | |
333 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
334 | - $this->object->addProduct( $this->testItem->getId(), 1, array(), array(), $configAttrIds, $hiddenAttrIds ); |
|
333 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
334 | + $this->object->addProduct($this->testItem->getId(), 1, array(), array(), $configAttrIds, $hiddenAttrIds); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | |
338 | 338 | public function testAddProductNegativeQuantityException() |
339 | 339 | { |
340 | - $this->setExpectedException( '\\Aimeos\\MShop\\Order\\Exception' ); |
|
341 | - $this->object->addProduct( $this->testItem->getId(), -1 ); |
|
340 | + $this->setExpectedException('\\Aimeos\\MShop\\Order\\Exception'); |
|
341 | + $this->object->addProduct($this->testItem->getId(), -1); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | |
345 | 345 | public function testAddProductNotEnoughStockException() |
346 | 346 | { |
347 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
347 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
348 | 348 | |
349 | 349 | $search = $productManager->createSearch(); |
350 | - $search->setConditions( $search->compare( '==', 'product.code', 'IJKL' ) ); |
|
350 | + $search->setConditions($search->compare('==', 'product.code', 'IJKL')); |
|
351 | 351 | |
352 | - $items = $productManager->searchItems( $search ); |
|
352 | + $items = $productManager->searchItems($search); |
|
353 | 353 | |
354 | - if( ( $item = reset( $items ) ) === false ) { |
|
355 | - throw new \Exception( 'Product not found' ); |
|
354 | + if (($item = reset($items)) === false) { |
|
355 | + throw new \Exception('Product not found'); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | try |
359 | 359 | { |
360 | - $this->object->addProduct( $item->getId(), 5, array(), array(), array(), array(), array(), 'unit_warehouse3' ); |
|
361 | - throw new \Exception( 'Expected exception not thrown' ); |
|
360 | + $this->object->addProduct($item->getId(), 5, array(), array(), array(), array(), array(), 'unit_warehouse3'); |
|
361 | + throw new \Exception('Expected exception not thrown'); |
|
362 | 362 | } |
363 | - catch( \Aimeos\Controller\Frontend\Basket\Exception $e ) |
|
363 | + catch (\Aimeos\Controller\Frontend\Basket\Exception $e) |
|
364 | 364 | { |
365 | - $item = $this->object->get()->getProduct( 0 ); |
|
366 | - $this->assertEquals( 3, $item->getQuantity() ); |
|
365 | + $item = $this->object->get()->getProduct(0); |
|
366 | + $this->assertEquals(3, $item->getQuantity()); |
|
367 | 367 | } |
368 | 368 | } |
369 | 369 | |
370 | 370 | |
371 | 371 | public function testAddProductNoStockException() |
372 | 372 | { |
373 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
373 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
374 | 374 | |
375 | 375 | $search = $productManager->createSearch(); |
376 | - $search->setConditions( $search->compare( '==', 'product.code', 'EFGH' ) ); |
|
376 | + $search->setConditions($search->compare('==', 'product.code', 'EFGH')); |
|
377 | 377 | |
378 | - $items = $productManager->searchItems( $search ); |
|
378 | + $items = $productManager->searchItems($search); |
|
379 | 379 | |
380 | - if( ( $item = reset( $items ) ) === false ) { |
|
381 | - throw new \Exception( 'Product not found' ); |
|
380 | + if (($item = reset($items)) === false) { |
|
381 | + throw new \Exception('Product not found'); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | try |
385 | 385 | { |
386 | - $this->object->addProduct( $item->getId(), 5, array(), array(), array(), array(), array(), 'unit_warehouse2' ); |
|
387 | - throw new \Exception( 'Expected exception not thrown' ); |
|
386 | + $this->object->addProduct($item->getId(), 5, array(), array(), array(), array(), array(), 'unit_warehouse2'); |
|
387 | + throw new \Exception('Expected exception not thrown'); |
|
388 | 388 | } |
389 | - catch( \Aimeos\Controller\Frontend\Basket\Exception $e ) |
|
389 | + catch (\Aimeos\Controller\Frontend\Basket\Exception $e) |
|
390 | 390 | { |
391 | - $this->assertEquals( array(), $this->object->get()->getProducts() ); |
|
391 | + $this->assertEquals(array(), $this->object->get()->getProducts()); |
|
392 | 392 | } |
393 | 393 | } |
394 | 394 | |
395 | 395 | |
396 | 396 | public function testAddProductNoStockRequired() |
397 | 397 | { |
398 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
398 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
399 | 399 | |
400 | 400 | $search = $productManager->createSearch(); |
401 | - $search->setConditions( $search->compare( '==', 'product.code', 'IJKL' ) ); |
|
401 | + $search->setConditions($search->compare('==', 'product.code', 'IJKL')); |
|
402 | 402 | |
403 | - $items = $productManager->searchItems( $search ); |
|
403 | + $items = $productManager->searchItems($search); |
|
404 | 404 | |
405 | - if( ( $item = reset( $items ) ) === false ) { |
|
406 | - throw new \Exception( 'Product not found' ); |
|
405 | + if (($item = reset($items)) === false) { |
|
406 | + throw new \Exception('Product not found'); |
|
407 | 407 | } |
408 | 408 | |
409 | - $this->object->addProduct( $item->getId(), 5, array( 'stock' => false ) ); |
|
409 | + $this->object->addProduct($item->getId(), 5, array('stock' => false)); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | |
413 | 413 | public function testAddProductNoStockItem() |
414 | 414 | { |
415 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
415 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
416 | 416 | |
417 | 417 | $search = $productManager->createSearch(); |
418 | - $search->setConditions( $search->compare( '==', 'product.code', 'QRST' ) ); |
|
418 | + $search->setConditions($search->compare('==', 'product.code', 'QRST')); |
|
419 | 419 | |
420 | - $items = $productManager->searchItems( $search ); |
|
420 | + $items = $productManager->searchItems($search); |
|
421 | 421 | |
422 | - if( ( $item = reset( $items ) ) === false ) { |
|
423 | - throw new \Exception( 'Product not found' ); |
|
422 | + if (($item = reset($items)) === false) { |
|
423 | + throw new \Exception('Product not found'); |
|
424 | 424 | } |
425 | 425 | |
426 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
427 | - $this->object->addProduct( $item->getId(), 1 ); |
|
426 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
427 | + $this->object->addProduct($item->getId(), 1); |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | |
431 | 431 | public function testAddProductNoPriceException() |
432 | 432 | { |
433 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
433 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
434 | 434 | |
435 | 435 | $search = $productManager->createSearch(); |
436 | - $search->setConditions( $search->compare( '==', 'product.code', 'MNOP' ) ); |
|
436 | + $search->setConditions($search->compare('==', 'product.code', 'MNOP')); |
|
437 | 437 | |
438 | - $items = $productManager->searchItems( $search ); |
|
438 | + $items = $productManager->searchItems($search); |
|
439 | 439 | |
440 | - if( ( $item = reset( $items ) ) === false ) { |
|
441 | - throw new \Exception( 'Product not found' ); |
|
440 | + if (($item = reset($items)) === false) { |
|
441 | + throw new \Exception('Product not found'); |
|
442 | 442 | } |
443 | 443 | |
444 | - $this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' ); |
|
445 | - $this->object->addProduct( $item->getId(), 1 ); |
|
444 | + $this->setExpectedException('\\Aimeos\\MShop\\Price\\Exception'); |
|
445 | + $this->object->addProduct($item->getId(), 1); |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | |
449 | 449 | public function testAddProductConfigAttributeException() |
450 | 450 | { |
451 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
452 | - $this->object->addProduct( $this->testItem->getId(), 1, array(), array(), array( -1 ) ); |
|
451 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
452 | + $this->object->addProduct($this->testItem->getId(), 1, array(), array(), array( -1 )); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | |
456 | 456 | public function testAddProductEmptySelectionException() |
457 | 457 | { |
458 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
458 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
459 | 459 | $search = $productManager->createSearch(); |
460 | - $search->setConditions( $search->compare( '==', 'product.code', 'U:noSel' ) ); |
|
461 | - $items = $productManager->searchItems( $search ); |
|
460 | + $search->setConditions($search->compare('==', 'product.code', 'U:noSel')); |
|
461 | + $items = $productManager->searchItems($search); |
|
462 | 462 | |
463 | - if( ( $item = reset( $items ) ) === false ) { |
|
464 | - throw new \Exception( 'Product not found' ); |
|
463 | + if (($item = reset($items)) === false) { |
|
464 | + throw new \Exception('Product not found'); |
|
465 | 465 | } |
466 | 466 | |
467 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
468 | - $this->object->addProduct( $item->getId(), 1 ); |
|
467 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
468 | + $this->object->addProduct($item->getId(), 1); |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | |
472 | 472 | public function testAddProductSelectionWithPricelessItem() |
473 | 473 | { |
474 | - $this->object->addProduct( $this->testItem->getId(), 1 ); |
|
474 | + $this->object->addProduct($this->testItem->getId(), 1); |
|
475 | 475 | |
476 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
476 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
477 | 477 | $search = $productManager->createSearch(); |
478 | 478 | |
479 | - $search->setConditions( $search->compare( '==', 'product.code', 'U:TESTPSUB01' ) ); |
|
480 | - $items = $productManager->searchItems( $search ); |
|
479 | + $search->setConditions($search->compare('==', 'product.code', 'U:TESTPSUB01')); |
|
480 | + $items = $productManager->searchItems($search); |
|
481 | 481 | |
482 | - if( ( $item = reset( $items ) ) === false ) { |
|
483 | - throw new \Exception( 'Product not found' ); |
|
482 | + if (($item = reset($items)) === false) { |
|
483 | + throw new \Exception('Product not found'); |
|
484 | 484 | } |
485 | 485 | |
486 | - $this->assertEquals( 'U:TESTPSUB01', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
486 | + $this->assertEquals('U:TESTPSUB01', $this->object->get()->getProduct(0)->getProductCode()); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | |
490 | 490 | public function testAddProductLowQuantityPriceException() |
491 | 491 | { |
492 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
492 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
493 | 493 | $search = $productManager->createSearch(); |
494 | - $search->setConditions( $search->compare( '==', 'product.code', 'IJKL' ) ); |
|
495 | - $items = $productManager->searchItems( $search ); |
|
494 | + $search->setConditions($search->compare('==', 'product.code', 'IJKL')); |
|
495 | + $items = $productManager->searchItems($search); |
|
496 | 496 | |
497 | - if( ( $item = reset( $items ) ) === false ) { |
|
498 | - throw new \Exception( 'Product not found' ); |
|
497 | + if (($item = reset($items)) === false) { |
|
498 | + throw new \Exception('Product not found'); |
|
499 | 499 | } |
500 | 500 | |
501 | - $this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' ); |
|
502 | - $this->object->addProduct( $item->getId(), 1 ); |
|
501 | + $this->setExpectedException('\\Aimeos\\MShop\\Price\\Exception'); |
|
502 | + $this->object->addProduct($item->getId(), 1); |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | |
506 | 506 | public function testAddProductHigherQuantities() |
507 | 507 | { |
508 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
508 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
509 | 509 | $search = $productManager->createSearch(); |
510 | - $search->setConditions( $search->compare( '==', 'product.code', 'IJKL' ) ); |
|
511 | - $items = $productManager->searchItems( $search ); |
|
510 | + $search->setConditions($search->compare('==', 'product.code', 'IJKL')); |
|
511 | + $items = $productManager->searchItems($search); |
|
512 | 512 | |
513 | - if( ( $item = reset( $items ) ) === false ) { |
|
514 | - throw new \Exception( 'Product not found' ); |
|
513 | + if (($item = reset($items)) === false) { |
|
514 | + throw new \Exception('Product not found'); |
|
515 | 515 | } |
516 | 516 | |
517 | - $this->object->addProduct( $item->getId(), 2, array(), array(), array(), array(), array(), 'unit_warehouse3' ); |
|
517 | + $this->object->addProduct($item->getId(), 2, array(), array(), array(), array(), array(), 'unit_warehouse3'); |
|
518 | 518 | |
519 | - $this->assertEquals( 2, $this->object->get()->getProduct( 0 )->getQuantity() ); |
|
520 | - $this->assertEquals( 'IJKL', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
519 | + $this->assertEquals(2, $this->object->get()->getProduct(0)->getQuantity()); |
|
520 | + $this->assertEquals('IJKL', $this->object->get()->getProduct(0)->getProductCode()); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | |
524 | 524 | public function testDeleteProductFlagError() |
525 | 525 | { |
526 | - $this->object->addProduct( $this->testItem->getId(), 2 ); |
|
526 | + $this->object->addProduct($this->testItem->getId(), 2); |
|
527 | 527 | |
528 | - $item = $this->object->get()->getProduct( 0 ); |
|
529 | - $item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ); |
|
528 | + $item = $this->object->get()->getProduct(0); |
|
529 | + $item->setFlags(\Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE); |
|
530 | 530 | |
531 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
532 | - $this->object->deleteProduct( 0 ); |
|
531 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
532 | + $this->object->deleteProduct(0); |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | |
536 | 536 | public function testEditProduct() |
537 | 537 | { |
538 | - $this->object->addProduct( $this->testItem->getId(), 1 ); |
|
538 | + $this->object->addProduct($this->testItem->getId(), 1); |
|
539 | 539 | |
540 | - $item = $this->object->get()->getProduct( 0 ); |
|
541 | - $this->assertEquals( 1, $item->getQuantity() ); |
|
540 | + $item = $this->object->get()->getProduct(0); |
|
541 | + $this->assertEquals(1, $item->getQuantity()); |
|
542 | 542 | |
543 | - $this->object->editProduct( 0, 4 ); |
|
543 | + $this->object->editProduct(0, 4); |
|
544 | 544 | |
545 | - $item = $this->object->get()->getProduct( 0 ); |
|
546 | - $this->assertEquals( 4, $item->getQuantity() ); |
|
547 | - $this->assertEquals( 'U:TESTPSUB01', $item->getProductCode() ); |
|
545 | + $item = $this->object->get()->getProduct(0); |
|
546 | + $this->assertEquals(4, $item->getQuantity()); |
|
547 | + $this->assertEquals('U:TESTPSUB01', $item->getProductCode()); |
|
548 | 548 | } |
549 | 549 | |
550 | 550 | |
551 | 551 | public function testEditProductAttributes() |
552 | 552 | { |
553 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
553 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
554 | 554 | $search = $productManager->createSearch(); |
555 | - $search->setConditions( $search->compare( '==', 'product.code', 'U:TESTP' ) ); |
|
556 | - $items = $productManager->searchItems( $search ); |
|
555 | + $search->setConditions($search->compare('==', 'product.code', 'U:TESTP')); |
|
556 | + $items = $productManager->searchItems($search); |
|
557 | 557 | |
558 | - if( ( $item = reset( $items ) ) === false ) { |
|
559 | - throw new \Exception( 'Product not found' ); |
|
558 | + if (($item = reset($items)) === false) { |
|
559 | + throw new \Exception('Product not found'); |
|
560 | 560 | } |
561 | 561 | |
562 | - $attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
562 | + $attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
563 | 563 | $search = $attributeManager->createSearch(); |
564 | 564 | $conditions = array( |
565 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
566 | - $search->combine( '||', array( |
|
567 | - $search->combine( '&&', array( |
|
568 | - $search->compare( '==', 'attribute.code', 'xs' ), |
|
569 | - $search->compare( '==', 'attribute.type.code', 'size' ), |
|
570 | - ) ), |
|
571 | - $search->combine( '&&', array( |
|
572 | - $search->compare( '==', 'attribute.code', 'white' ), |
|
573 | - $search->compare( '==', 'attribute.type.code', 'color' ), |
|
574 | - ) ), |
|
575 | - ) ) |
|
565 | + $search->compare('==', 'attribute.domain', 'product'), |
|
566 | + $search->combine('||', array( |
|
567 | + $search->combine('&&', array( |
|
568 | + $search->compare('==', 'attribute.code', 'xs'), |
|
569 | + $search->compare('==', 'attribute.type.code', 'size'), |
|
570 | + )), |
|
571 | + $search->combine('&&', array( |
|
572 | + $search->compare('==', 'attribute.code', 'white'), |
|
573 | + $search->compare('==', 'attribute.type.code', 'color'), |
|
574 | + )), |
|
575 | + )) |
|
576 | 576 | ); |
577 | - $search->setConditions( $search->combine( '&&', $conditions ) ); |
|
578 | - $attributes = $attributeManager->searchItems( $search ); |
|
577 | + $search->setConditions($search->combine('&&', $conditions)); |
|
578 | + $attributes = $attributeManager->searchItems($search); |
|
579 | 579 | |
580 | - if( ( $attribute = reset( $attributes ) ) === false ) { |
|
581 | - throw new \Exception( 'No attributes available' ); |
|
580 | + if (($attribute = reset($attributes)) === false) { |
|
581 | + throw new \Exception('No attributes available'); |
|
582 | 582 | } |
583 | 583 | |
584 | 584 | |
585 | - $this->object->addProduct( $item->getId(), 1, array(), array(), array_keys( $attributes ) ); |
|
586 | - $this->object->editProduct( 0, 4 ); |
|
585 | + $this->object->addProduct($item->getId(), 1, array(), array(), array_keys($attributes)); |
|
586 | + $this->object->editProduct(0, 4); |
|
587 | 587 | |
588 | - $item = $this->object->get()->getProduct( 0 ); |
|
589 | - $this->assertEquals( 2, count( $item->getAttributes() ) ); |
|
590 | - $this->assertEquals( 4, $item->getQuantity() ); |
|
588 | + $item = $this->object->get()->getProduct(0); |
|
589 | + $this->assertEquals(2, count($item->getAttributes())); |
|
590 | + $this->assertEquals(4, $item->getQuantity()); |
|
591 | 591 | |
592 | 592 | |
593 | - $this->object->editProduct( 0, 3, array(), array( $attribute->getType() ) ); |
|
593 | + $this->object->editProduct(0, 3, array(), array($attribute->getType())); |
|
594 | 594 | |
595 | - $item = $this->object->get()->getProduct( 0 ); |
|
596 | - $this->assertEquals( 3, $item->getQuantity() ); |
|
597 | - $this->assertEquals( 1, count( $item->getAttributes() ) ); |
|
598 | - $this->assertEquals( 'U:TESTPSUB01', $item->getProductCode() ); |
|
595 | + $item = $this->object->get()->getProduct(0); |
|
596 | + $this->assertEquals(3, $item->getQuantity()); |
|
597 | + $this->assertEquals(1, count($item->getAttributes())); |
|
598 | + $this->assertEquals('U:TESTPSUB01', $item->getProductCode()); |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | |
602 | 602 | public function testEditProductNotEnoughStock() |
603 | 603 | { |
604 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
604 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
605 | 605 | $search = $productManager->createSearch(); |
606 | - $search->setConditions( $search->compare( '==', 'product.code', 'IJKL' ) ); |
|
607 | - $items = $productManager->searchItems( $search ); |
|
606 | + $search->setConditions($search->compare('==', 'product.code', 'IJKL')); |
|
607 | + $items = $productManager->searchItems($search); |
|
608 | 608 | |
609 | - if( ( $item = reset( $items ) ) === false ) { |
|
610 | - throw new \Exception( 'Product not found' ); |
|
609 | + if (($item = reset($items)) === false) { |
|
610 | + throw new \Exception('Product not found'); |
|
611 | 611 | } |
612 | 612 | |
613 | - $this->object->addProduct( $item->getId(), 2, array(), array(), array(), array(), array(), 'unit_warehouse3' ); |
|
613 | + $this->object->addProduct($item->getId(), 2, array(), array(), array(), array(), array(), 'unit_warehouse3'); |
|
614 | 614 | |
615 | - $item = $this->object->get()->getProduct( 0 ); |
|
616 | - $this->assertEquals( 2, $item->getQuantity() ); |
|
615 | + $item = $this->object->get()->getProduct(0); |
|
616 | + $this->assertEquals(2, $item->getQuantity()); |
|
617 | 617 | |
618 | 618 | try |
619 | 619 | { |
620 | - $this->object->editProduct( 0, 5 ); |
|
621 | - throw new \Exception( 'Expected exception not thrown' ); |
|
620 | + $this->object->editProduct(0, 5); |
|
621 | + throw new \Exception('Expected exception not thrown'); |
|
622 | 622 | } |
623 | - catch( \Aimeos\Controller\Frontend\Basket\Exception $e ) |
|
623 | + catch (\Aimeos\Controller\Frontend\Basket\Exception $e) |
|
624 | 624 | { |
625 | - $item = $this->object->get()->getProduct( 0 ); |
|
626 | - $this->assertEquals( 3, $item->getQuantity() ); |
|
627 | - $this->assertEquals( 'IJKL', $item->getProductCode() ); |
|
625 | + $item = $this->object->get()->getProduct(0); |
|
626 | + $this->assertEquals(3, $item->getQuantity()); |
|
627 | + $this->assertEquals('IJKL', $item->getProductCode()); |
|
628 | 628 | } |
629 | 629 | } |
630 | 630 | |
@@ -633,137 +633,137 @@ discard block |
||
633 | 633 | { |
634 | 634 | $context = \TestHelperFrontend::getContext(); |
635 | 635 | |
636 | - $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
636 | + $productManager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
637 | 637 | $search = $productManager->createSearch(); |
638 | - $search->setConditions( $search->compare( '==', 'product.code', 'IJKL' ) ); |
|
639 | - $items = $productManager->searchItems( $search ); |
|
638 | + $search->setConditions($search->compare('==', 'product.code', 'IJKL')); |
|
639 | + $items = $productManager->searchItems($search); |
|
640 | 640 | |
641 | - if( ( $item = reset( $items ) ) === false ) { |
|
642 | - throw new \Exception( 'Product not found' ); |
|
641 | + if (($item = reset($items)) === false) { |
|
642 | + throw new \Exception('Product not found'); |
|
643 | 643 | } |
644 | 644 | |
645 | - $orderProductManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' ); |
|
645 | + $orderProductManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/product'); |
|
646 | 646 | $orderProductItem = $orderProductManager->createItem(); |
647 | - $orderProductItem->copyFrom( $item ); |
|
648 | - $orderProductItem->setQuantity( 2 ); |
|
649 | - $orderProductItem->setWarehouseCode( 'unit_warehouse3' ); |
|
647 | + $orderProductItem->copyFrom($item); |
|
648 | + $orderProductItem->setQuantity(2); |
|
649 | + $orderProductItem->setWarehouseCode('unit_warehouse3'); |
|
650 | 650 | |
651 | - $pos = $this->object->get()->addProduct( $orderProductItem, 1 ); |
|
651 | + $pos = $this->object->get()->addProduct($orderProductItem, 1); |
|
652 | 652 | |
653 | - $item = $this->object->get()->getProduct( $pos ); |
|
654 | - $this->assertEquals( 2, $item->getQuantity() ); |
|
653 | + $item = $this->object->get()->getProduct($pos); |
|
654 | + $this->assertEquals(2, $item->getQuantity()); |
|
655 | 655 | |
656 | 656 | try |
657 | 657 | { |
658 | - $this->object->editProduct( $pos, 5 ); |
|
659 | - throw new \Exception( 'Expected exception not thrown' ); |
|
658 | + $this->object->editProduct($pos, 5); |
|
659 | + throw new \Exception('Expected exception not thrown'); |
|
660 | 660 | } |
661 | - catch( \Aimeos\Controller\Frontend\Basket\Exception $e ) |
|
661 | + catch (\Aimeos\Controller\Frontend\Basket\Exception $e) |
|
662 | 662 | { |
663 | - $this->assertEquals( 3, $this->object->get()->getProduct( $pos )->getQuantity() ); |
|
663 | + $this->assertEquals(3, $this->object->get()->getProduct($pos)->getQuantity()); |
|
664 | 664 | } |
665 | 665 | } |
666 | 666 | |
667 | 667 | |
668 | 668 | public function testEditProductStockNotChecked() |
669 | 669 | { |
670 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
670 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
671 | 671 | $search = $productManager->createSearch(); |
672 | - $search->setConditions( $search->compare( '==', 'product.code', 'IJKL' ) ); |
|
673 | - $items = $productManager->searchItems( $search ); |
|
672 | + $search->setConditions($search->compare('==', 'product.code', 'IJKL')); |
|
673 | + $items = $productManager->searchItems($search); |
|
674 | 674 | |
675 | - if( ( $item = reset( $items ) ) === false ) { |
|
676 | - throw new \Exception( 'Product not found' ); |
|
675 | + if (($item = reset($items)) === false) { |
|
676 | + throw new \Exception('Product not found'); |
|
677 | 677 | } |
678 | 678 | |
679 | - $this->object->addProduct( $item->getId(), 2, array(), array(), array(), array(), array(), 'unit_warehouse3' ); |
|
679 | + $this->object->addProduct($item->getId(), 2, array(), array(), array(), array(), array(), 'unit_warehouse3'); |
|
680 | 680 | |
681 | - $item = $this->object->get()->getProduct( 0 ); |
|
682 | - $this->assertEquals( 2, $item->getQuantity() ); |
|
681 | + $item = $this->object->get()->getProduct(0); |
|
682 | + $this->assertEquals(2, $item->getQuantity()); |
|
683 | 683 | |
684 | - $this->object->editProduct( 0, 5, array( 'stock' => false ) ); |
|
684 | + $this->object->editProduct(0, 5, array('stock' => false)); |
|
685 | 685 | |
686 | - $item = $this->object->get()->getProduct( 0 ); |
|
687 | - $this->assertEquals( 5, $item->getQuantity() ); |
|
688 | - $this->assertEquals( 'IJKL', $item->getProductCode() ); |
|
686 | + $item = $this->object->get()->getProduct(0); |
|
687 | + $this->assertEquals(5, $item->getQuantity()); |
|
688 | + $this->assertEquals('IJKL', $item->getProductCode()); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | |
692 | 692 | public function testEditProductFlagError() |
693 | 693 | { |
694 | - $this->object->addProduct( $this->testItem->getId(), 2 ); |
|
694 | + $this->object->addProduct($this->testItem->getId(), 2); |
|
695 | 695 | |
696 | - $item = $this->object->get()->getProduct( 0 ); |
|
697 | - $item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ); |
|
696 | + $item = $this->object->get()->getProduct(0); |
|
697 | + $item->setFlags(\Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE); |
|
698 | 698 | |
699 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
700 | - $this->object->editProduct( 0, 4 ); |
|
699 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
700 | + $this->object->editProduct(0, 4); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | |
704 | 704 | public function testAddCoupon() |
705 | 705 | { |
706 | - $this->object->addProduct( $this->testItem->getId(), 2 ); |
|
707 | - $this->object->addCoupon( 'GHIJ' ); |
|
706 | + $this->object->addProduct($this->testItem->getId(), 2); |
|
707 | + $this->object->addCoupon('GHIJ'); |
|
708 | 708 | |
709 | 709 | $basket = $this->object->get(); |
710 | 710 | |
711 | - $this->assertEquals( 1, count( $basket->getCoupons() ) ); |
|
711 | + $this->assertEquals(1, count($basket->getCoupons())); |
|
712 | 712 | } |
713 | 713 | |
714 | 714 | |
715 | 715 | public function testAddCouponInvalidCode() |
716 | 716 | { |
717 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
718 | - $this->object->addCoupon( 'invalid' ); |
|
717 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
718 | + $this->object->addCoupon('invalid'); |
|
719 | 719 | } |
720 | 720 | |
721 | 721 | |
722 | 722 | public function testAddCouponMissingRequirements() |
723 | 723 | { |
724 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
725 | - $this->object->addCoupon( 'OPQR' ); |
|
724 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
725 | + $this->object->addCoupon('OPQR'); |
|
726 | 726 | } |
727 | 727 | |
728 | 728 | |
729 | 729 | public function testDeleteCoupon() |
730 | 730 | { |
731 | - $this->object->addProduct( $this->testItem->getId(), 2 ); |
|
732 | - $this->object->addCoupon( '90AB' ); |
|
733 | - $this->object->deleteCoupon( '90AB' ); |
|
731 | + $this->object->addProduct($this->testItem->getId(), 2); |
|
732 | + $this->object->addCoupon('90AB'); |
|
733 | + $this->object->deleteCoupon('90AB'); |
|
734 | 734 | |
735 | 735 | $basket = $this->object->get(); |
736 | 736 | |
737 | - $this->assertEquals( 0, count( $basket->getCoupons() ) ); |
|
737 | + $this->assertEquals(0, count($basket->getCoupons())); |
|
738 | 738 | } |
739 | 739 | |
740 | 740 | |
741 | 741 | public function testClear() |
742 | 742 | { |
743 | - $this->object->addProduct( $this->testItem->getId(), 2 ); |
|
743 | + $this->object->addProduct($this->testItem->getId(), 2); |
|
744 | 744 | $this->object->clear(); |
745 | 745 | |
746 | - $this->assertEquals( 0, count( $this->object->get()->getProducts() ) ); |
|
746 | + $this->assertEquals(0, count($this->object->get()->getProducts())); |
|
747 | 747 | } |
748 | 748 | |
749 | 749 | |
750 | 750 | public function testSetAddressDelete() |
751 | 751 | { |
752 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null ); |
|
752 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null); |
|
753 | 753 | |
754 | - $this->setExpectedException( '\Aimeos\MShop\Order\Exception' ); |
|
755 | - $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
754 | + $this->setExpectedException('\Aimeos\MShop\Order\Exception'); |
|
755 | + $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
756 | 756 | } |
757 | 757 | |
758 | 758 | |
759 | 759 | public function testSetBillingAddressByItem() |
760 | 760 | { |
761 | - $item = $this->getAddress( 'Example company' ); |
|
761 | + $item = $this->getAddress('Example company'); |
|
762 | 762 | |
763 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item ); |
|
763 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item); |
|
764 | 764 | |
765 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
766 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
765 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
766 | + $this->assertEquals('Example company', $address->getCompany()); |
|
767 | 767 | } |
768 | 768 | |
769 | 769 | |
@@ -791,37 +791,37 @@ discard block |
||
791 | 791 | 'order.base.address.flag' => 0, |
792 | 792 | ); |
793 | 793 | |
794 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture ); |
|
794 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture); |
|
795 | 795 | |
796 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
797 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
798 | - $this->assertEquals( 'Dr.', $address->getTitle() ); |
|
799 | - $this->assertEquals( 'firstunit', $address->getFirstname() ); |
|
796 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
797 | + $this->assertEquals('Example company', $address->getCompany()); |
|
798 | + $this->assertEquals('Dr.', $address->getTitle()); |
|
799 | + $this->assertEquals('firstunit', $address->getFirstname()); |
|
800 | 800 | } |
801 | 801 | |
802 | 802 | |
803 | 803 | public function testSetBillingAddressByArrayError() |
804 | 804 | { |
805 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
806 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array( 'error' => false ) ); |
|
805 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
806 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array('error' => false)); |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | |
810 | 810 | public function testSetBillingAddressParameterError() |
811 | 811 | { |
812 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
813 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error' ); |
|
812 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
813 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error'); |
|
814 | 814 | } |
815 | 815 | |
816 | 816 | |
817 | 817 | public function testSetDeliveryAddressByItem() |
818 | 818 | { |
819 | - $item = $this->getAddress( 'Example company' ); |
|
819 | + $item = $this->getAddress('Example company'); |
|
820 | 820 | |
821 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item ); |
|
821 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item); |
|
822 | 822 | |
823 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY ); |
|
824 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
823 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY); |
|
824 | + $this->assertEquals('Example company', $address->getCompany()); |
|
825 | 825 | } |
826 | 826 | |
827 | 827 | |
@@ -848,113 +848,113 @@ discard block |
||
848 | 848 | 'order.base.address.website' => 'www.example.com', |
849 | 849 | 'order.base.address.flag' => 0, |
850 | 850 | ); |
851 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture ); |
|
851 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture); |
|
852 | 852 | |
853 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY ); |
|
854 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
855 | - $this->assertEquals( 'Dr.', $address->getTitle() ); |
|
856 | - $this->assertEquals( 'firstunit', $address->getFirstname() ); |
|
853 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY); |
|
854 | + $this->assertEquals('Example company', $address->getCompany()); |
|
855 | + $this->assertEquals('Dr.', $address->getTitle()); |
|
856 | + $this->assertEquals('firstunit', $address->getFirstname()); |
|
857 | 857 | } |
858 | 858 | |
859 | 859 | |
860 | 860 | public function testSetDeliveryAddressByArrayError() |
861 | 861 | { |
862 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
863 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array( 'error' => false ) ); |
|
862 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
863 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array('error' => false)); |
|
864 | 864 | } |
865 | 865 | |
866 | 866 | |
867 | 867 | public function testSetDeliveryAddressTypeError() |
868 | 868 | { |
869 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
870 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error' ); |
|
869 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
870 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error'); |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | |
874 | 874 | public function testSetServicePayment() |
875 | 875 | { |
876 | - $service = $this->getService( 'unitpaymentcode' ); |
|
876 | + $service = $this->getService('unitpaymentcode'); |
|
877 | 877 | |
878 | - $this->object->setService( 'payment', $service->getId(), array() ); |
|
879 | - $this->assertEquals( 'unitpaymentcode', $this->object->get()->getService( 'payment' )->getCode() ); |
|
878 | + $this->object->setService('payment', $service->getId(), array()); |
|
879 | + $this->assertEquals('unitpaymentcode', $this->object->get()->getService('payment')->getCode()); |
|
880 | 880 | |
881 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
882 | - $this->object->setService( 'payment', $service->getId(), array( 'prepay' => true ) ); |
|
881 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
882 | + $this->object->setService('payment', $service->getId(), array('prepay' => true)); |
|
883 | 883 | } |
884 | 884 | |
885 | 885 | |
886 | 886 | public function testSetDeliveryOption() |
887 | 887 | { |
888 | - $service = $this->getService( 'unitcode' ); |
|
888 | + $service = $this->getService('unitcode'); |
|
889 | 889 | |
890 | - $this->object->setService( 'delivery', $service->getId(), array() ); |
|
891 | - $this->assertEquals( 'unitcode', $this->object->get()->getService( 'delivery' )->getCode() ); |
|
890 | + $this->object->setService('delivery', $service->getId(), array()); |
|
891 | + $this->assertEquals('unitcode', $this->object->get()->getService('delivery')->getCode()); |
|
892 | 892 | |
893 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
894 | - $this->object->setService( 'delivery', $service->getId(), array( 'fast shipping' => true, 'air shipping' => false ) ); |
|
893 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
894 | + $this->object->setService('delivery', $service->getId(), array('fast shipping' => true, 'air shipping' => false)); |
|
895 | 895 | } |
896 | 896 | |
897 | 897 | |
898 | 898 | public function testCheckLocale() |
899 | 899 | { |
900 | - $this->object->addProduct( $this->testItem->getId(), 2 ); |
|
901 | - $this->object->addCoupon( 'OPQR' ); |
|
900 | + $this->object->addProduct($this->testItem->getId(), 2); |
|
901 | + $this->object->addCoupon('OPQR'); |
|
902 | 902 | |
903 | - $this->object->setService( 'payment', $this->getService( 'unitpaymentcode' )->getId() ); |
|
904 | - $this->object->setService( 'delivery', $this->getService( 'unitcode' )->getId() ); |
|
903 | + $this->object->setService('payment', $this->getService('unitpaymentcode')->getId()); |
|
904 | + $this->object->setService('delivery', $this->getService('unitcode')->getId()); |
|
905 | 905 | |
906 | 906 | $basket = $this->object->get(); |
907 | 907 | $price = $basket->getPrice(); |
908 | 908 | |
909 | - foreach( $basket->getProducts() as $product ) |
|
909 | + foreach ($basket->getProducts() as $product) |
|
910 | 910 | { |
911 | - $this->assertEquals( 2, $product->getQuantity() ); |
|
912 | - $product->getPrice()->setCurrencyId( 'CHF' ); |
|
911 | + $this->assertEquals(2, $product->getQuantity()); |
|
912 | + $product->getPrice()->setCurrencyId('CHF'); |
|
913 | 913 | } |
914 | 914 | |
915 | - $basket->getService( 'delivery' )->getPrice()->setCurrencyId( 'CHF' ); |
|
916 | - $basket->getService( 'payment' )->getPrice()->setCurrencyId( 'CHF' ); |
|
917 | - $basket->getLocale()->setCurrencyId( 'CHF' ); |
|
918 | - $price->setCurrencyId( 'CHF' ); |
|
915 | + $basket->getService('delivery')->getPrice()->setCurrencyId('CHF'); |
|
916 | + $basket->getService('payment')->getPrice()->setCurrencyId('CHF'); |
|
917 | + $basket->getLocale()->setCurrencyId('CHF'); |
|
918 | + $price->setCurrencyId('CHF'); |
|
919 | 919 | |
920 | - $this->context->getLocale()->setCurrencyId( 'CHF' ); |
|
921 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress( 'Example company' ) ); |
|
920 | + $this->context->getLocale()->setCurrencyId('CHF'); |
|
921 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress('Example company')); |
|
922 | 922 | |
923 | - $this->context->getSession()->set( 'aimeos/basket/currency', 'CHF' ); |
|
924 | - $this->context->getLocale()->setCurrencyId( 'EUR' ); |
|
923 | + $this->context->getSession()->set('aimeos/basket/currency', 'CHF'); |
|
924 | + $this->context->getLocale()->setCurrencyId('EUR'); |
|
925 | 925 | |
926 | - $this->context->getSession()->set( 'aimeos/basket/content-unittest-en-EUR-', null ); |
|
926 | + $this->context->getSession()->set('aimeos/basket/content-unittest-en-EUR-', null); |
|
927 | 927 | |
928 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
928 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
929 | 929 | $basket = $object->get(); |
930 | 930 | |
931 | - foreach( $basket->getProducts() as $product ) |
|
931 | + foreach ($basket->getProducts() as $product) |
|
932 | 932 | { |
933 | - $this->assertEquals( 'EUR', $product->getPrice()->getCurrencyId() ); |
|
934 | - $this->assertEquals( 2, $product->getQuantity() ); |
|
933 | + $this->assertEquals('EUR', $product->getPrice()->getCurrencyId()); |
|
934 | + $this->assertEquals(2, $product->getQuantity()); |
|
935 | 935 | } |
936 | 936 | |
937 | - $this->assertEquals( 'EUR', $basket->getService( 'payment' )->getPrice()->getCurrencyId() ); |
|
938 | - $this->assertEquals( 'EUR', $basket->getService( 'delivery' )->getPrice()->getCurrencyId() ); |
|
939 | - $this->assertEquals( 'EUR', $basket->getLocale()->getCurrencyId() ); |
|
940 | - $this->assertEquals( 'EUR', $basket->getPrice()->getCurrencyId() ); |
|
937 | + $this->assertEquals('EUR', $basket->getService('payment')->getPrice()->getCurrencyId()); |
|
938 | + $this->assertEquals('EUR', $basket->getService('delivery')->getPrice()->getCurrencyId()); |
|
939 | + $this->assertEquals('EUR', $basket->getLocale()->getCurrencyId()); |
|
940 | + $this->assertEquals('EUR', $basket->getPrice()->getCurrencyId()); |
|
941 | 941 | } |
942 | 942 | |
943 | 943 | |
944 | 944 | /** |
945 | 945 | * @param string $company |
946 | 946 | */ |
947 | - protected function getAddress( $company ) |
|
947 | + protected function getAddress($company) |
|
948 | 948 | { |
949 | - $customer = \Aimeos\MShop\Customer\Manager\Factory::createManager( \TestHelperFrontend::getContext(), 'Standard' ); |
|
950 | - $addressManager = $customer->getSubManager( 'address', 'Standard' ); |
|
949 | + $customer = \Aimeos\MShop\Customer\Manager\Factory::createManager(\TestHelperFrontend::getContext(), 'Standard'); |
|
950 | + $addressManager = $customer->getSubManager('address', 'Standard'); |
|
951 | 951 | |
952 | 952 | $search = $addressManager->createSearch(); |
953 | - $search->setConditions( $search->compare( '==', 'customer.address.company', $company ) ); |
|
954 | - $items = $addressManager->searchItems( $search ); |
|
953 | + $search->setConditions($search->compare('==', 'customer.address.company', $company)); |
|
954 | + $items = $addressManager->searchItems($search); |
|
955 | 955 | |
956 | - if( ( $item = reset( $items ) ) === false ) { |
|
957 | - throw new \Exception( sprintf( 'No address item with company "%1$s" found', $company ) ); |
|
956 | + if (($item = reset($items)) === false) { |
|
957 | + throw new \Exception(sprintf('No address item with company "%1$s" found', $company)); |
|
958 | 958 | } |
959 | 959 | |
960 | 960 | return $item; |
@@ -964,17 +964,17 @@ discard block |
||
964 | 964 | /** |
965 | 965 | * @param string $code |
966 | 966 | */ |
967 | - protected function getService( $code ) |
|
967 | + protected function getService($code) |
|
968 | 968 | { |
969 | - $serviceManager = \Aimeos\MShop\Service\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
969 | + $serviceManager = \Aimeos\MShop\Service\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
970 | 970 | |
971 | 971 | $search = $serviceManager->createSearch(); |
972 | - $search->setConditions( $search->compare( '==', 'service.code', $code ) ); |
|
972 | + $search->setConditions($search->compare('==', 'service.code', $code)); |
|
973 | 973 | |
974 | - $result = $serviceManager->searchItems( $search, array( 'text' ) ); |
|
974 | + $result = $serviceManager->searchItems($search, array('text')); |
|
975 | 975 | |
976 | - if( ( $item = reset( $result ) ) === false ) { |
|
977 | - throw new \Exception( sprintf( 'No service item with code "%1$s" found', $code ) ); |
|
976 | + if (($item = reset($result)) === false) { |
|
977 | + throw new \Exception(sprintf('No service item with code "%1$s" found', $code)); |
|
978 | 978 | } |
979 | 979 | |
980 | 980 | return $item; |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @param \Aimeos\MShop\Context\Item\Iface $context Common MShop context object |
30 | 30 | */ |
31 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context ) |
|
31 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context) |
|
32 | 32 | { |
33 | 33 | $this->context = $context; |
34 | 34 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param array $param List of method parameter |
42 | 42 | * @return boolean Returns always false |
43 | 43 | */ |
44 | - public function __call( $name, array $param ) |
|
44 | + public function __call($name, array $param) |
|
45 | 45 | { |
46 | 46 | return false; |
47 | 47 | } |