@@ -29,15 +29,15 @@ discard block |
||
29 | 29 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
30 | 30 | * @since 2017.03 |
31 | 31 | */ |
32 | - public function addFilterTypes( \Aimeos\MW\Criteria\Iface $filter, array $codes ) |
|
32 | + public function addFilterTypes(\Aimeos\MW\Criteria\Iface $filter, array $codes) |
|
33 | 33 | { |
34 | - if( !empty( $codes ) ) |
|
34 | + if (!empty($codes)) |
|
35 | 35 | { |
36 | 36 | $expr = [ |
37 | - $filter->compare( '==', 'attribute.type.code', $codes ), |
|
37 | + $filter->compare('==', 'attribute.type.code', $codes), |
|
38 | 38 | $filter->getConditions(), |
39 | 39 | ]; |
40 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
40 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | return $filter; |
@@ -53,15 +53,15 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function createFilter() |
55 | 55 | { |
56 | - $filter = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' )->createSearch( true ); |
|
56 | + $filter = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute')->createSearch(true); |
|
57 | 57 | |
58 | 58 | $expr = array( |
59 | - $filter->compare( '==', 'attribute.domain', 'product' ), |
|
59 | + $filter->compare('==', 'attribute.domain', 'product'), |
|
60 | 60 | $filter->getConditions(), |
61 | 61 | ); |
62 | 62 | |
63 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
64 | - $filter->setSortations( array( $filter->sort( '+', 'attribute.position' ) ) ); |
|
63 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
64 | + $filter->setSortations(array($filter->sort('+', 'attribute.position'))); |
|
65 | 65 | |
66 | 66 | return $filter; |
67 | 67 | } |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | * @return \Aimeos\MShop\Attribute\Item\Iface Attribute item including the referenced domains items |
76 | 76 | * @since 2017.03 |
77 | 77 | */ |
78 | - public function getItem( $id, array $domains = array( 'media', 'price', 'text' ) ) |
|
78 | + public function getItem($id, array $domains = array('media', 'price', 'text')) |
|
79 | 79 | { |
80 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' )->getItem( $id, $domains, true ); |
|
80 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute')->getItem($id, $domains, true); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -89,20 +89,20 @@ discard block |
||
89 | 89 | * @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute item including the referenced domains items |
90 | 90 | * @since 2017.03 |
91 | 91 | */ |
92 | - public function getItems( array $ids, array $domains = array( 'media', 'price', 'text' ) ) |
|
92 | + public function getItems(array $ids, array $domains = array('media', 'price', 'text')) |
|
93 | 93 | { |
94 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
94 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
95 | 95 | |
96 | - $filter = $manager->createSearch( true ); |
|
96 | + $filter = $manager->createSearch(true); |
|
97 | 97 | $expr = [ |
98 | - $filter->compare( '==', 'attribute.domain', 'product' ), |
|
99 | - $filter->compare( '==', 'attribute.id', $ids ), |
|
98 | + $filter->compare('==', 'attribute.domain', 'product'), |
|
99 | + $filter->compare('==', 'attribute.id', $ids), |
|
100 | 100 | $filter->getConditions(), |
101 | 101 | ]; |
102 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
103 | - $filter->setSortations( array( $filter->sort( '+', 'attribute.position' ) ) ); |
|
102 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
103 | + $filter->setSortations(array($filter->sort('+', 'attribute.position'))); |
|
104 | 104 | |
105 | - return $manager->searchItems( $filter, $domains ); |
|
105 | + return $manager->searchItems($filter, $domains); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | * @return array Ordered list of attribute items implementing \Aimeos\MShop\Attribute\Item\Iface |
116 | 116 | * @since 2017.03 |
117 | 117 | */ |
118 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null ) |
|
118 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = array('media', 'price', 'text'), &$total = null) |
|
119 | 119 | { |
120 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' )->searchItems( $filter, $domains, $total ); |
|
120 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute')->searchItems($filter, $domains, $total); |
|
121 | 121 | } |
122 | 122 | } |
@@ -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,250 +132,250 @@ 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 testAddProductAttributeNotAssigned() |
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', '30' ), |
|
180 | - $search->compare( '==', 'attribute.type.code', 'width' ), |
|
179 | + $search->compare('==', 'attribute.code', '30'), |
|
180 | + $search->compare('==', 'attribute.type.code', 'width'), |
|
181 | 181 | ); |
182 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
182 | + $search->setConditions($search->combine('&&', $expr)); |
|
183 | 183 | |
184 | - $attribute = $attributeManager->searchItems( $search ); |
|
184 | + $attribute = $attributeManager->searchItems($search); |
|
185 | 185 | |
186 | - if( empty( $attribute ) ) { |
|
187 | - throw new \RuntimeException( 'Attribute not found' ); |
|
186 | + if (empty($attribute)) { |
|
187 | + throw new \RuntimeException('Attribute not found'); |
|
188 | 188 | } |
189 | 189 | |
190 | - $hiddenAttrIds = array_keys( $attribute ); |
|
191 | - $configAttrIds = array_keys( $attribute ); |
|
190 | + $hiddenAttrIds = array_keys($attribute); |
|
191 | + $configAttrIds = array_keys($attribute); |
|
192 | 192 | |
193 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
194 | - $this->object->addProduct( self::$testItem->getId(), 1, [], [], $configAttrIds, $hiddenAttrIds ); |
|
193 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
194 | + $this->object->addProduct(self::$testItem->getId(), 1, [], [], $configAttrIds, $hiddenAttrIds); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | |
198 | 198 | public function testAddProductNegativeQuantityException() |
199 | 199 | { |
200 | - $this->setExpectedException( '\\Aimeos\\MShop\\Order\\Exception' ); |
|
201 | - $this->object->addProduct( self::$testItem->getId(), -1 ); |
|
200 | + $this->setExpectedException('\\Aimeos\\MShop\\Order\\Exception'); |
|
201 | + $this->object->addProduct(self::$testItem->getId(), -1); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | |
205 | 205 | public function testAddProductNoPriceException() |
206 | 206 | { |
207 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'MNOP' ); |
|
207 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('MNOP'); |
|
208 | 208 | |
209 | - $this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' ); |
|
210 | - $this->object->addProduct( $item->getId(), 1 ); |
|
209 | + $this->setExpectedException('\\Aimeos\\MShop\\Price\\Exception'); |
|
210 | + $this->object->addProduct($item->getId(), 1); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
214 | 214 | public function testAddProductConfigAttributeException() |
215 | 215 | { |
216 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
217 | - $this->object->addProduct( self::$testItem->getId(), 1, [], [], array( -1 ) ); |
|
216 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
217 | + $this->object->addProduct(self::$testItem->getId(), 1, [], [], array( -1 )); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | |
221 | 221 | public function testAddProductLowQuantityPriceException() |
222 | 222 | { |
223 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'IJKL' ); |
|
223 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('IJKL'); |
|
224 | 224 | |
225 | - $this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' ); |
|
226 | - $this->object->addProduct( $item->getId(), 1 ); |
|
225 | + $this->setExpectedException('\\Aimeos\\MShop\\Price\\Exception'); |
|
226 | + $this->object->addProduct($item->getId(), 1); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | |
230 | 230 | public function testAddProductHigherQuantities() |
231 | 231 | { |
232 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'IJKL' ); |
|
232 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('IJKL'); |
|
233 | 233 | |
234 | - $this->object->addProduct( $item->getId(), 2, [], [], [], [], [], 'unit_type3' ); |
|
234 | + $this->object->addProduct($item->getId(), 2, [], [], [], [], [], 'unit_type3'); |
|
235 | 235 | |
236 | - $this->assertEquals( 2, $this->object->get()->getProduct( 0 )->getQuantity() ); |
|
237 | - $this->assertEquals( 'IJKL', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
236 | + $this->assertEquals(2, $this->object->get()->getProduct(0)->getQuantity()); |
|
237 | + $this->assertEquals('IJKL', $this->object->get()->getProduct(0)->getProductCode()); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | |
241 | 241 | public function testDeleteProductFlagError() |
242 | 242 | { |
243 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
243 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
244 | 244 | |
245 | - $item = $this->object->get()->getProduct( 0 ); |
|
246 | - $item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ); |
|
245 | + $item = $this->object->get()->getProduct(0); |
|
246 | + $item->setFlags(\Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE); |
|
247 | 247 | |
248 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
249 | - $this->object->deleteProduct( 0 ); |
|
248 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
249 | + $this->object->deleteProduct(0); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | |
253 | 253 | public function testEditProduct() |
254 | 254 | { |
255 | - $this->object->addProduct( self::$testItem->getId(), 1 ); |
|
255 | + $this->object->addProduct(self::$testItem->getId(), 1); |
|
256 | 256 | |
257 | - $item = $this->object->get()->getProduct( 0 ); |
|
258 | - $this->assertEquals( 1, $item->getQuantity() ); |
|
257 | + $item = $this->object->get()->getProduct(0); |
|
258 | + $this->assertEquals(1, $item->getQuantity()); |
|
259 | 259 | |
260 | - $this->object->editProduct( 0, 4 ); |
|
260 | + $this->object->editProduct(0, 4); |
|
261 | 261 | |
262 | - $item = $this->object->get()->getProduct( 0 ); |
|
263 | - $this->assertEquals( 4, $item->getQuantity() ); |
|
264 | - $this->assertEquals( 'U:TESTP', $item->getProductCode() ); |
|
262 | + $item = $this->object->get()->getProduct(0); |
|
263 | + $this->assertEquals(4, $item->getQuantity()); |
|
264 | + $this->assertEquals('U:TESTP', $item->getProductCode()); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | |
268 | 268 | public function testEditProductAttributes() |
269 | 269 | { |
270 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
270 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
271 | 271 | |
272 | 272 | $search = $attributeManager->createSearch(); |
273 | 273 | $conditions = array( |
274 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
275 | - $search->combine( '||', array( |
|
276 | - $search->combine( '&&', array( |
|
277 | - $search->compare( '==', 'attribute.code', 'xs' ), |
|
278 | - $search->compare( '==', 'attribute.type.code', 'size' ), |
|
279 | - ) ), |
|
280 | - $search->combine( '&&', array( |
|
281 | - $search->compare( '==', 'attribute.code', 'white' ), |
|
282 | - $search->compare( '==', 'attribute.type.code', 'color' ), |
|
283 | - ) ), |
|
284 | - ) ) |
|
274 | + $search->compare('==', 'attribute.domain', 'product'), |
|
275 | + $search->combine('||', array( |
|
276 | + $search->combine('&&', array( |
|
277 | + $search->compare('==', 'attribute.code', 'xs'), |
|
278 | + $search->compare('==', 'attribute.type.code', 'size'), |
|
279 | + )), |
|
280 | + $search->combine('&&', array( |
|
281 | + $search->compare('==', 'attribute.code', 'white'), |
|
282 | + $search->compare('==', 'attribute.type.code', 'color'), |
|
283 | + )), |
|
284 | + )) |
|
285 | 285 | ); |
286 | - $search->setConditions( $search->combine( '&&', $conditions ) ); |
|
287 | - $attributes = $attributeManager->searchItems( $search ); |
|
286 | + $search->setConditions($search->combine('&&', $conditions)); |
|
287 | + $attributes = $attributeManager->searchItems($search); |
|
288 | 288 | |
289 | - if( ( $attribute = reset( $attributes ) ) === false ) { |
|
290 | - throw new \RuntimeException( 'No attributes available' ); |
|
289 | + if (($attribute = reset($attributes)) === false) { |
|
290 | + throw new \RuntimeException('No attributes available'); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | |
294 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TESTP' ); |
|
294 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TESTP'); |
|
295 | 295 | |
296 | - $this->object->addProduct( $item->getId(), 1, [], [], array_keys( $attributes ) ); |
|
297 | - $this->object->editProduct( 0, 4 ); |
|
296 | + $this->object->addProduct($item->getId(), 1, [], [], array_keys($attributes)); |
|
297 | + $this->object->editProduct(0, 4); |
|
298 | 298 | |
299 | - $item = $this->object->get()->getProduct( 0 ); |
|
300 | - $this->assertEquals( 2, count( $item->getAttributes() ) ); |
|
301 | - $this->assertEquals( 4, $item->getQuantity() ); |
|
299 | + $item = $this->object->get()->getProduct(0); |
|
300 | + $this->assertEquals(2, count($item->getAttributes())); |
|
301 | + $this->assertEquals(4, $item->getQuantity()); |
|
302 | 302 | |
303 | 303 | |
304 | - $this->object->editProduct( 0, 3, [], array( $attribute->getType() ) ); |
|
304 | + $this->object->editProduct(0, 3, [], array($attribute->getType())); |
|
305 | 305 | |
306 | - $item = $this->object->get()->getProduct( 0 ); |
|
307 | - $this->assertEquals( 3, $item->getQuantity() ); |
|
308 | - $this->assertEquals( 1, count( $item->getAttributes() ) ); |
|
309 | - $this->assertEquals( 'U:TESTP', $item->getProductCode() ); |
|
306 | + $item = $this->object->get()->getProduct(0); |
|
307 | + $this->assertEquals(3, $item->getQuantity()); |
|
308 | + $this->assertEquals(1, count($item->getAttributes())); |
|
309 | + $this->assertEquals('U:TESTP', $item->getProductCode()); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | |
313 | 313 | public function testEditProductFlagError() |
314 | 314 | { |
315 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
315 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
316 | 316 | |
317 | - $item = $this->object->get()->getProduct( 0 ); |
|
318 | - $item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ); |
|
317 | + $item = $this->object->get()->getProduct(0); |
|
318 | + $item->setFlags(\Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE); |
|
319 | 319 | |
320 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
321 | - $this->object->editProduct( 0, 4 ); |
|
320 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
321 | + $this->object->editProduct(0, 4); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | |
325 | 325 | public function testAddCoupon() |
326 | 326 | { |
327 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
328 | - $this->object->addCoupon( 'GHIJ' ); |
|
327 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
328 | + $this->object->addCoupon('GHIJ'); |
|
329 | 329 | |
330 | 330 | $basket = $this->object->get(); |
331 | 331 | |
332 | - $this->assertEquals( 1, count( $basket->getCoupons() ) ); |
|
332 | + $this->assertEquals(1, count($basket->getCoupons())); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | |
336 | 336 | public function testAddCouponInvalidCode() |
337 | 337 | { |
338 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
339 | - $this->object->addCoupon( 'invalid' ); |
|
338 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
339 | + $this->object->addCoupon('invalid'); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | |
343 | 343 | public function testAddCouponMissingRequirements() |
344 | 344 | { |
345 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
346 | - $this->object->addCoupon( 'OPQR' ); |
|
345 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
346 | + $this->object->addCoupon('OPQR'); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | |
350 | 350 | public function testDeleteCoupon() |
351 | 351 | { |
352 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
353 | - $this->object->addCoupon( '90AB' ); |
|
354 | - $this->object->deleteCoupon( '90AB' ); |
|
352 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
353 | + $this->object->addCoupon('90AB'); |
|
354 | + $this->object->deleteCoupon('90AB'); |
|
355 | 355 | |
356 | 356 | $basket = $this->object->get(); |
357 | 357 | |
358 | - $this->assertEquals( 0, count( $basket->getCoupons() ) ); |
|
358 | + $this->assertEquals(0, count($basket->getCoupons())); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | |
362 | 362 | public function testSetAddressDelete() |
363 | 363 | { |
364 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null ); |
|
364 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null); |
|
365 | 365 | |
366 | - $this->setExpectedException( '\Aimeos\MShop\Order\Exception' ); |
|
367 | - $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
366 | + $this->setExpectedException('\Aimeos\MShop\Order\Exception'); |
|
367 | + $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | |
371 | 371 | public function testSetBillingAddressByItem() |
372 | 372 | { |
373 | - $item = $this->getAddress( 'Example company' ); |
|
373 | + $item = $this->getAddress('Example company'); |
|
374 | 374 | |
375 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item ); |
|
375 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item); |
|
376 | 376 | |
377 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
378 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
377 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
378 | + $this->assertEquals('Example company', $address->getCompany()); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | |
@@ -403,37 +403,37 @@ discard block |
||
403 | 403 | 'order.base.address.flag' => 0, |
404 | 404 | ); |
405 | 405 | |
406 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture ); |
|
406 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture); |
|
407 | 407 | |
408 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
409 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
410 | - $this->assertEquals( 'Dr.', $address->getTitle() ); |
|
411 | - $this->assertEquals( 'firstunit', $address->getFirstname() ); |
|
408 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
409 | + $this->assertEquals('Example company', $address->getCompany()); |
|
410 | + $this->assertEquals('Dr.', $address->getTitle()); |
|
411 | + $this->assertEquals('firstunit', $address->getFirstname()); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | |
415 | 415 | public function testSetBillingAddressByArrayError() |
416 | 416 | { |
417 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
418 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array( 'error' => false ) ); |
|
417 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
418 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array('error' => false)); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | |
422 | 422 | public function testSetBillingAddressParameterError() |
423 | 423 | { |
424 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
425 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error' ); |
|
424 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
425 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error'); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | |
429 | 429 | public function testSetDeliveryAddressByItem() |
430 | 430 | { |
431 | - $item = $this->getAddress( 'Example company' ); |
|
431 | + $item = $this->getAddress('Example company'); |
|
432 | 432 | |
433 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item ); |
|
433 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item); |
|
434 | 434 | |
435 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY ); |
|
436 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
435 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY); |
|
436 | + $this->assertEquals('Example company', $address->getCompany()); |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | |
@@ -460,119 +460,119 @@ discard block |
||
460 | 460 | 'order.base.address.website' => 'www.example.com', |
461 | 461 | 'order.base.address.flag' => 0, |
462 | 462 | ); |
463 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture ); |
|
463 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture); |
|
464 | 464 | |
465 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY ); |
|
466 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
467 | - $this->assertEquals( 'Dr.', $address->getTitle() ); |
|
468 | - $this->assertEquals( 'firstunit', $address->getFirstname() ); |
|
465 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY); |
|
466 | + $this->assertEquals('Example company', $address->getCompany()); |
|
467 | + $this->assertEquals('Dr.', $address->getTitle()); |
|
468 | + $this->assertEquals('firstunit', $address->getFirstname()); |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | |
472 | 472 | public function testSetDeliveryAddressByArrayError() |
473 | 473 | { |
474 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
475 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array( 'error' => false ) ); |
|
474 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
475 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array('error' => false)); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | |
479 | 479 | public function testSetDeliveryAddressTypeError() |
480 | 480 | { |
481 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
482 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error' ); |
|
481 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
482 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error'); |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | |
486 | 486 | public function testSetServicePayment() |
487 | 487 | { |
488 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
489 | - $service = $manager->findItem( 'unitpaymentcode', [], 'service', 'payment' ); |
|
488 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
489 | + $service = $manager->findItem('unitpaymentcode', [], 'service', 'payment'); |
|
490 | 490 | |
491 | - $this->object->setService( 'payment', $service->getId(), [] ); |
|
492 | - $this->assertEquals( 'unitpaymentcode', $this->object->get()->getService( 'payment' )->getCode() ); |
|
491 | + $this->object->setService('payment', $service->getId(), []); |
|
492 | + $this->assertEquals('unitpaymentcode', $this->object->get()->getService('payment')->getCode()); |
|
493 | 493 | |
494 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
495 | - $this->object->setService( 'payment', $service->getId(), array( 'prepay' => true ) ); |
|
494 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
495 | + $this->object->setService('payment', $service->getId(), array('prepay' => true)); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | |
499 | 499 | public function testSetDeliveryOption() |
500 | 500 | { |
501 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
502 | - $service = $manager->findItem( 'unitcode', [], 'service', 'delivery' ); |
|
501 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
502 | + $service = $manager->findItem('unitcode', [], 'service', 'delivery'); |
|
503 | 503 | |
504 | - $this->object->setService( 'delivery', $service->getId(), [] ); |
|
505 | - $this->assertEquals( 'unitcode', $this->object->get()->getService( 'delivery' )->getCode() ); |
|
504 | + $this->object->setService('delivery', $service->getId(), []); |
|
505 | + $this->assertEquals('unitcode', $this->object->get()->getService('delivery')->getCode()); |
|
506 | 506 | |
507 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
508 | - $this->object->setService( 'delivery', $service->getId(), array( 'fast shipping' => true, 'air shipping' => false ) ); |
|
507 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
508 | + $this->object->setService('delivery', $service->getId(), array('fast shipping' => true, 'air shipping' => false)); |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | |
512 | 512 | public function testCheckLocale() |
513 | 513 | { |
514 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
515 | - $payment = $manager->findItem( 'unitpaymentcode', [], 'service', 'payment' ); |
|
516 | - $delivery = $manager->findItem( 'unitcode', [], 'service', 'delivery' ); |
|
514 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
515 | + $payment = $manager->findItem('unitpaymentcode', [], 'service', 'payment'); |
|
516 | + $delivery = $manager->findItem('unitcode', [], 'service', 'delivery'); |
|
517 | 517 | |
518 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
519 | - $this->object->addCoupon( 'OPQR' ); |
|
518 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
519 | + $this->object->addCoupon('OPQR'); |
|
520 | 520 | |
521 | - $this->object->setService( 'payment', $payment->getId() ); |
|
522 | - $this->object->setService( 'delivery', $delivery->getId() ); |
|
521 | + $this->object->setService('payment', $payment->getId()); |
|
522 | + $this->object->setService('delivery', $delivery->getId()); |
|
523 | 523 | |
524 | 524 | $basket = $this->object->get(); |
525 | 525 | $price = $basket->getPrice(); |
526 | 526 | |
527 | - foreach( $basket->getProducts() as $product ) |
|
527 | + foreach ($basket->getProducts() as $product) |
|
528 | 528 | { |
529 | - $this->assertEquals( 2, $product->getQuantity() ); |
|
530 | - $product->getPrice()->setCurrencyId( 'CHF' ); |
|
529 | + $this->assertEquals(2, $product->getQuantity()); |
|
530 | + $product->getPrice()->setCurrencyId('CHF'); |
|
531 | 531 | } |
532 | 532 | |
533 | - $basket->getService( 'delivery' )->getPrice()->setCurrencyId( 'CHF' ); |
|
534 | - $basket->getService( 'payment' )->getPrice()->setCurrencyId( 'CHF' ); |
|
535 | - $basket->getLocale()->setCurrencyId( 'CHF' ); |
|
536 | - $price->setCurrencyId( 'CHF' ); |
|
533 | + $basket->getService('delivery')->getPrice()->setCurrencyId('CHF'); |
|
534 | + $basket->getService('payment')->getPrice()->setCurrencyId('CHF'); |
|
535 | + $basket->getLocale()->setCurrencyId('CHF'); |
|
536 | + $price->setCurrencyId('CHF'); |
|
537 | 537 | |
538 | - $this->context->getLocale()->setCurrencyId( 'CHF' ); |
|
539 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress( 'Example company' ) ); |
|
538 | + $this->context->getLocale()->setCurrencyId('CHF'); |
|
539 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress('Example company')); |
|
540 | 540 | |
541 | - $this->context->getSession()->set( 'aimeos/basket/currency', 'CHF' ); |
|
542 | - $this->context->getLocale()->setCurrencyId( 'EUR' ); |
|
541 | + $this->context->getSession()->set('aimeos/basket/currency', 'CHF'); |
|
542 | + $this->context->getLocale()->setCurrencyId('EUR'); |
|
543 | 543 | |
544 | - $this->context->getSession()->set( 'aimeos/basket/content-unittest-en-EUR-', null ); |
|
544 | + $this->context->getSession()->set('aimeos/basket/content-unittest-en-EUR-', null); |
|
545 | 545 | |
546 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
546 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
547 | 547 | $basket = $object->get(); |
548 | 548 | |
549 | - foreach( $basket->getProducts() as $product ) |
|
549 | + foreach ($basket->getProducts() as $product) |
|
550 | 550 | { |
551 | - $this->assertEquals( 'EUR', $product->getPrice()->getCurrencyId() ); |
|
552 | - $this->assertEquals( 2, $product->getQuantity() ); |
|
551 | + $this->assertEquals('EUR', $product->getPrice()->getCurrencyId()); |
|
552 | + $this->assertEquals(2, $product->getQuantity()); |
|
553 | 553 | } |
554 | 554 | |
555 | - $this->assertEquals( 'EUR', $basket->getService( 'payment' )->getPrice()->getCurrencyId() ); |
|
556 | - $this->assertEquals( 'EUR', $basket->getService( 'delivery' )->getPrice()->getCurrencyId() ); |
|
557 | - $this->assertEquals( 'EUR', $basket->getLocale()->getCurrencyId() ); |
|
558 | - $this->assertEquals( 'EUR', $basket->getPrice()->getCurrencyId() ); |
|
555 | + $this->assertEquals('EUR', $basket->getService('payment')->getPrice()->getCurrencyId()); |
|
556 | + $this->assertEquals('EUR', $basket->getService('delivery')->getPrice()->getCurrencyId()); |
|
557 | + $this->assertEquals('EUR', $basket->getLocale()->getCurrencyId()); |
|
558 | + $this->assertEquals('EUR', $basket->getPrice()->getCurrencyId()); |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | |
562 | 562 | /** |
563 | 563 | * @param string $company |
564 | 564 | */ |
565 | - protected function getAddress( $company ) |
|
565 | + protected function getAddress($company) |
|
566 | 566 | { |
567 | - $customer = \Aimeos\MShop\Customer\Manager\Factory::createManager( \TestHelperFrontend::getContext(), 'Standard' ); |
|
568 | - $addressManager = $customer->getSubManager( 'address', 'Standard' ); |
|
567 | + $customer = \Aimeos\MShop\Customer\Manager\Factory::createManager(\TestHelperFrontend::getContext(), 'Standard'); |
|
568 | + $addressManager = $customer->getSubManager('address', 'Standard'); |
|
569 | 569 | |
570 | 570 | $search = $addressManager->createSearch(); |
571 | - $search->setConditions( $search->compare( '==', 'customer.address.company', $company ) ); |
|
572 | - $items = $addressManager->searchItems( $search ); |
|
571 | + $search->setConditions($search->compare('==', 'customer.address.company', $company)); |
|
572 | + $items = $addressManager->searchItems($search); |
|
573 | 573 | |
574 | - if( ( $item = reset( $items ) ) === false ) { |
|
575 | - throw new \RuntimeException( sprintf( 'No address item with company "%1$s" found', $company ) ); |
|
574 | + if (($item = reset($items)) === false) { |
|
575 | + throw new \RuntimeException(sprintf('No address item with company "%1$s" found', $company)); |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | return $item; |
@@ -31,32 +31,32 @@ discard block |
||
31 | 31 | * @param integer $quantity New product quantity |
32 | 32 | * @return \Aimeos\MShop\Price\Item\Iface Price item with calculated price |
33 | 33 | */ |
34 | - protected function calcPrice( \Aimeos\MShop\Order\Item\Base\Product\Iface $product, array $prices, $quantity ) |
|
34 | + protected function calcPrice(\Aimeos\MShop\Order\Item\Base\Product\Iface $product, array $prices, $quantity) |
|
35 | 35 | { |
36 | 36 | $context = $this->getContext(); |
37 | 37 | |
38 | - if( empty( $prices ) ) |
|
38 | + if (empty($prices)) |
|
39 | 39 | { |
40 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
41 | - $prices = $manager->getItem( $product->getProductId(), array( 'price' ) )->getRefItems( 'price', 'default' ); |
|
40 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
41 | + $prices = $manager->getItem($product->getProductId(), array('price'))->getRefItems('price', 'default'); |
|
42 | 42 | } |
43 | 43 | |
44 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
45 | - $price = $priceManager->getLowestPrice( $prices, $quantity ); |
|
44 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
45 | + $price = $priceManager->getLowestPrice($prices, $quantity); |
|
46 | 46 | |
47 | - foreach( $this->getAttributeItems( $product->getAttributes() ) as $attrItem ) |
|
47 | + foreach ($this->getAttributeItems($product->getAttributes()) as $attrItem) |
|
48 | 48 | { |
49 | - $prices = $attrItem->getRefItems( 'price', 'default' ); |
|
49 | + $prices = $attrItem->getRefItems('price', 'default'); |
|
50 | 50 | |
51 | - if( count( $prices ) > 0 ) |
|
51 | + if (count($prices) > 0) |
|
52 | 52 | { |
53 | - $attrPrice = $priceManager->getLowestPrice( $prices, $quantity ); |
|
54 | - $price->addItem( $attrPrice ); |
|
53 | + $attrPrice = $priceManager->getLowestPrice($prices, $quantity); |
|
54 | + $price->addItem($attrPrice); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | 58 | // remove product rebate of original price in favor to rebates granted for the order |
59 | - $price->setRebate( '0.00' ); |
|
59 | + $price->setRebate('0.00'); |
|
60 | 60 | |
61 | 61 | return $price; |
62 | 62 | } |
@@ -71,34 +71,34 @@ discard block |
||
71 | 71 | * @param array $refIds List of IDs that must be associated to the product |
72 | 72 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If one or more of the IDs are not associated |
73 | 73 | */ |
74 | - protected function checkReferences( $prodId, $domain, $listTypeId, array $refIds ) |
|
74 | + protected function checkReferences($prodId, $domain, $listTypeId, array $refIds) |
|
75 | 75 | { |
76 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
77 | - $search = $productManager->createSearch( true ); |
|
76 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
77 | + $search = $productManager->createSearch(true); |
|
78 | 78 | |
79 | 79 | $expr = array( |
80 | - $search->compare( '==', 'product.id', $prodId ), |
|
80 | + $search->compare('==', 'product.id', $prodId), |
|
81 | 81 | $search->getConditions(), |
82 | 82 | ); |
83 | 83 | |
84 | - if( count( $refIds ) > 0 ) |
|
84 | + if (count($refIds) > 0) |
|
85 | 85 | { |
86 | - foreach( $refIds as $key => $refId ) { |
|
86 | + foreach ($refIds as $key => $refId) { |
|
87 | 87 | $refIds[$key] = (string) $refId; |
88 | 88 | } |
89 | 89 | |
90 | - $param = array( $domain, $listTypeId, $refIds ); |
|
91 | - $cmpfunc = $search->createFunction( 'product.contains', $param ); |
|
90 | + $param = array($domain, $listTypeId, $refIds); |
|
91 | + $cmpfunc = $search->createFunction('product.contains', $param); |
|
92 | 92 | |
93 | - $expr[] = $search->compare( '==', $cmpfunc, count( $refIds ) ); |
|
93 | + $expr[] = $search->compare('==', $cmpfunc, count($refIds)); |
|
94 | 94 | } |
95 | 95 | |
96 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
96 | + $search->setConditions($search->combine('&&', $expr)); |
|
97 | 97 | |
98 | - if( count( $productManager->searchItems( $search, [] ) ) === 0 ) |
|
98 | + if (count($productManager->searchItems($search, [])) === 0) |
|
99 | 99 | { |
100 | - $msg = sprintf( 'Invalid "%1$s" references for product with ID %2$s', $domain, json_encode( $prodId ) ); |
|
101 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
100 | + $msg = sprintf('Invalid "%1$s" references for product with ID %2$s', $domain, json_encode($prodId)); |
|
101 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
@@ -108,41 +108,41 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @param string $type Basket type |
110 | 110 | */ |
111 | - protected function checkLocale( $type ) |
|
111 | + protected function checkLocale($type) |
|
112 | 112 | { |
113 | 113 | $errors = []; |
114 | 114 | $context = $this->getContext(); |
115 | 115 | $session = $context->getSession(); |
116 | 116 | $locale = $this->get()->getLocale(); |
117 | 117 | |
118 | - $localeStr = $session->get( 'aimeos/basket/locale' ); |
|
118 | + $localeStr = $session->get('aimeos/basket/locale'); |
|
119 | 119 | $localeKey = $locale->getSite()->getCode() . '|' . $locale->getLanguageId() . '|' . $locale->getCurrencyId(); |
120 | 120 | |
121 | - if( $localeStr !== null && $localeStr !== $localeKey ) |
|
121 | + if ($localeStr !== null && $localeStr !== $localeKey) |
|
122 | 122 | { |
123 | - $locParts = explode( '|', $localeStr ); |
|
124 | - $locSite = ( isset( $locParts[0] ) ? $locParts[0] : '' ); |
|
125 | - $locLanguage = ( isset( $locParts[1] ) ? $locParts[1] : '' ); |
|
126 | - $locCurrency = ( isset( $locParts[2] ) ? $locParts[2] : '' ); |
|
123 | + $locParts = explode('|', $localeStr); |
|
124 | + $locSite = (isset($locParts[0]) ? $locParts[0] : ''); |
|
125 | + $locLanguage = (isset($locParts[1]) ? $locParts[1] : ''); |
|
126 | + $locCurrency = (isset($locParts[2]) ? $locParts[2] : ''); |
|
127 | 127 | |
128 | - $localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' ); |
|
129 | - $locale = $localeManager->bootstrap( $locSite, $locLanguage, $locCurrency, false ); |
|
128 | + $localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale'); |
|
129 | + $locale = $localeManager->bootstrap($locSite, $locLanguage, $locCurrency, false); |
|
130 | 130 | |
131 | 131 | $context = clone $context; |
132 | - $context->setLocale( $locale ); |
|
132 | + $context->setLocale($locale); |
|
133 | 133 | |
134 | - $manager = \Aimeos\MShop\Order\Manager\Factory::createManager( $context )->getSubManager( 'base' ); |
|
135 | - $basket = $manager->getSession( $type ); |
|
134 | + $manager = \Aimeos\MShop\Order\Manager\Factory::createManager($context)->getSubManager('base'); |
|
135 | + $basket = $manager->getSession($type); |
|
136 | 136 | |
137 | - $this->copyAddresses( $basket, $errors, $localeKey ); |
|
138 | - $this->copyServices( $basket, $errors ); |
|
139 | - $this->copyProducts( $basket, $errors, $localeKey ); |
|
140 | - $this->copyCoupons( $basket, $errors, $localeKey ); |
|
137 | + $this->copyAddresses($basket, $errors, $localeKey); |
|
138 | + $this->copyServices($basket, $errors); |
|
139 | + $this->copyProducts($basket, $errors, $localeKey); |
|
140 | + $this->copyCoupons($basket, $errors, $localeKey); |
|
141 | 141 | |
142 | - $manager->setSession( $basket, $type ); |
|
142 | + $manager->setSession($basket, $type); |
|
143 | 143 | } |
144 | 144 | |
145 | - $session->set( 'aimeos/basket/locale', $localeKey ); |
|
145 | + $session->set('aimeos/basket/locale', $localeKey); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | |
@@ -154,20 +154,20 @@ discard block |
||
154 | 154 | * @param string $localeKey Unique identifier of the site, language and currency |
155 | 155 | * @return array Associative list of errors occured |
156 | 156 | */ |
157 | - protected function copyAddresses( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
157 | + protected function copyAddresses(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
158 | 158 | { |
159 | - foreach( $basket->getAddresses() as $type => $item ) |
|
159 | + foreach ($basket->getAddresses() as $type => $item) |
|
160 | 160 | { |
161 | 161 | try |
162 | 162 | { |
163 | - $this->setAddress( $type, $item->toArray() ); |
|
164 | - $basket->deleteAddress( $type ); |
|
163 | + $this->setAddress($type, $item->toArray()); |
|
164 | + $basket->deleteAddress($type); |
|
165 | 165 | } |
166 | - catch( \Exception $e ) |
|
166 | + catch (\Exception $e) |
|
167 | 167 | { |
168 | 168 | $logger = $this->getContext()->getLogger(); |
169 | 169 | $str = 'Error migrating address with type "%1$s" in basket to locale "%2$s": %3$s'; |
170 | - $logger->log( sprintf( $str, $type, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
170 | + $logger->log(sprintf($str, $type, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
171 | 171 | $errors['address'][$type] = $e->getMessage(); |
172 | 172 | } |
173 | 173 | } |
@@ -184,20 +184,20 @@ discard block |
||
184 | 184 | * @param string $localeKey Unique identifier of the site, language and currency |
185 | 185 | * @return array Associative list of errors occured |
186 | 186 | */ |
187 | - protected function copyCoupons( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
187 | + protected function copyCoupons(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
188 | 188 | { |
189 | - foreach( $basket->getCoupons() as $code => $list ) |
|
189 | + foreach ($basket->getCoupons() as $code => $list) |
|
190 | 190 | { |
191 | 191 | try |
192 | 192 | { |
193 | - $this->addCoupon( $code ); |
|
194 | - $basket->deleteCoupon( $code, true ); |
|
193 | + $this->addCoupon($code); |
|
194 | + $basket->deleteCoupon($code, true); |
|
195 | 195 | } |
196 | - catch( \Exception $e ) |
|
196 | + catch (\Exception $e) |
|
197 | 197 | { |
198 | 198 | $logger = $this->getContext()->getLogger(); |
199 | 199 | $str = 'Error migrating coupon with code "%1$s" in basket to locale "%2$s": %3$s'; |
200 | - $logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
200 | + $logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
201 | 201 | $errors['coupon'][$code] = $e->getMessage(); |
202 | 202 | } |
203 | 203 | } |
@@ -214,11 +214,11 @@ discard block |
||
214 | 214 | * @param string $localeKey Unique identifier of the site, language and currency |
215 | 215 | * @return array Associative list of errors occured |
216 | 216 | */ |
217 | - protected function copyProducts( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
217 | + protected function copyProducts(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
218 | 218 | { |
219 | - foreach( $basket->getProducts() as $pos => $product ) |
|
219 | + foreach ($basket->getProducts() as $pos => $product) |
|
220 | 220 | { |
221 | - if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) { |
|
221 | + if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) { |
|
222 | 222 | continue; |
223 | 223 | } |
224 | 224 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | { |
227 | 227 | $attrIds = []; |
228 | 228 | |
229 | - foreach( $product->getAttributes() as $attrItem ) { |
|
229 | + foreach ($product->getAttributes() as $attrItem) { |
|
230 | 230 | $attrIds[$attrItem->getType()][] = $attrItem->getAttributeId(); |
231 | 231 | } |
232 | 232 | |
@@ -234,23 +234,23 @@ discard block |
||
234 | 234 | $product->getProductId(), |
235 | 235 | $product->getQuantity(), |
236 | 236 | [], |
237 | - $this->getValue( $attrIds, 'variant', [] ), |
|
238 | - $this->getValue( $attrIds, 'config', [] ), |
|
239 | - $this->getValue( $attrIds, 'hidden', [] ), |
|
240 | - $this->getValue( $attrIds, 'custom', [] ), |
|
237 | + $this->getValue($attrIds, 'variant', []), |
|
238 | + $this->getValue($attrIds, 'config', []), |
|
239 | + $this->getValue($attrIds, 'hidden', []), |
|
240 | + $this->getValue($attrIds, 'custom', []), |
|
241 | 241 | $product->getStockType() |
242 | 242 | ); |
243 | 243 | |
244 | - $basket->deleteProduct( $pos ); |
|
244 | + $basket->deleteProduct($pos); |
|
245 | 245 | } |
246 | - catch( \Exception $e ) |
|
246 | + catch (\Exception $e) |
|
247 | 247 | { |
248 | 248 | $code = $product->getProductCode(); |
249 | 249 | $logger = $this->getContext()->getLogger(); |
250 | 250 | $errors['product'][$pos] = $e->getMessage(); |
251 | 251 | |
252 | 252 | $str = 'Error migrating product with code "%1$s" in basket to locale "%2$s": %3$s'; |
253 | - $logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
253 | + $logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
254 | 254 | } |
255 | 255 | } |
256 | 256 | |
@@ -265,22 +265,22 @@ discard block |
||
265 | 265 | * @param array $errors Associative list of previous errors |
266 | 266 | * @return array Associative list of errors occured |
267 | 267 | */ |
268 | - protected function copyServices( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors ) |
|
268 | + protected function copyServices(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors) |
|
269 | 269 | { |
270 | - foreach( $basket->getServices() as $type => $item ) |
|
270 | + foreach ($basket->getServices() as $type => $item) |
|
271 | 271 | { |
272 | 272 | try |
273 | 273 | { |
274 | 274 | $attributes = []; |
275 | 275 | |
276 | - foreach( $item->getAttributes() as $attrItem ) { |
|
276 | + foreach ($item->getAttributes() as $attrItem) { |
|
277 | 277 | $attributes[$attrItem->getCode()] = $attrItem->getValue(); |
278 | 278 | } |
279 | 279 | |
280 | - $this->setService( $type, $item->getServiceId(), $attributes ); |
|
281 | - $basket->deleteService( $type ); |
|
280 | + $this->setService($type, $item->getServiceId(), $attributes); |
|
281 | + $basket->deleteService($type); |
|
282 | 282 | } |
283 | - catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically |
|
283 | + catch (\Exception $e) {; } // Don't notify the user as appropriate services can be added automatically |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | return $errors; |
@@ -298,36 +298,36 @@ discard block |
||
298 | 298 | * @param array $attributeValues Associative list of attribute IDs as keys and their codes as values |
299 | 299 | * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface |
300 | 300 | */ |
301 | - protected function createOrderProductAttributes( \Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity, |
|
302 | - array $attributeIds, $type, array $attributeValues = [] ) |
|
301 | + protected function createOrderProductAttributes(\Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity, |
|
302 | + array $attributeIds, $type, array $attributeValues = []) |
|
303 | 303 | { |
304 | - if( empty( $attributeIds ) ) { |
|
304 | + if (empty($attributeIds)) { |
|
305 | 305 | return []; |
306 | 306 | } |
307 | 307 | |
308 | - $attrTypeId = $this->getProductListTypeItem( 'attribute', $type )->getId(); |
|
309 | - $this->checkReferences( $prodid, 'attribute', $attrTypeId, $attributeIds ); |
|
308 | + $attrTypeId = $this->getProductListTypeItem('attribute', $type)->getId(); |
|
309 | + $this->checkReferences($prodid, 'attribute', $attrTypeId, $attributeIds); |
|
310 | 310 | |
311 | 311 | $list = []; |
312 | 312 | $context = $this->getContext(); |
313 | 313 | |
314 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
315 | - $orderProductAttributeManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product/attribute' ); |
|
314 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
315 | + $orderProductAttributeManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/product/attribute'); |
|
316 | 316 | |
317 | - foreach( $this->getAttributes( $attributeIds ) as $id => $attrItem ) |
|
317 | + foreach ($this->getAttributes($attributeIds) as $id => $attrItem) |
|
318 | 318 | { |
319 | - $prices = $attrItem->getRefItems( 'price', 'default', 'default' ); |
|
319 | + $prices = $attrItem->getRefItems('price', 'default', 'default'); |
|
320 | 320 | |
321 | - if( !empty( $prices ) ) { |
|
322 | - $price->addItem( $priceManager->getLowestPrice( $prices, $quantity ) ); |
|
321 | + if (!empty($prices)) { |
|
322 | + $price->addItem($priceManager->getLowestPrice($prices, $quantity)); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | $item = $orderProductAttributeManager->createItem(); |
326 | - $item->copyFrom( $attrItem ); |
|
327 | - $item->setType( $type ); |
|
326 | + $item->copyFrom($attrItem); |
|
327 | + $item->setType($type); |
|
328 | 328 | |
329 | - if( isset( $attributeValues[$id] ) ) { |
|
330 | - $item->setValue( $attributeValues[$id] ); |
|
329 | + if (isset($attributeValues[$id])) { |
|
330 | + $item->setValue($attributeValues[$id]); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | $list[] = $item; |
@@ -345,31 +345,31 @@ discard block |
||
345 | 345 | * @return array List of items implementing \Aimeos\MShop\Attribute\Item\Iface |
346 | 346 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the actual attribute number doesn't match the expected one |
347 | 347 | */ |
348 | - protected function getAttributes( array $attributeIds, array $domains = array( 'price', 'text' ) ) |
|
348 | + protected function getAttributes(array $attributeIds, array $domains = array('price', 'text')) |
|
349 | 349 | { |
350 | - if( empty( $attributeIds ) ) { |
|
350 | + if (empty($attributeIds)) { |
|
351 | 351 | return []; |
352 | 352 | } |
353 | 353 | |
354 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
354 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
355 | 355 | |
356 | - $search = $attributeManager->createSearch( true ); |
|
356 | + $search = $attributeManager->createSearch(true); |
|
357 | 357 | $expr = array( |
358 | - $search->compare( '==', 'attribute.id', $attributeIds ), |
|
358 | + $search->compare('==', 'attribute.id', $attributeIds), |
|
359 | 359 | $search->getConditions(), |
360 | 360 | ); |
361 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
362 | - $search->setSlice( 0, 0x7fffffff ); |
|
361 | + $search->setConditions($search->combine('&&', $expr)); |
|
362 | + $search->setSlice(0, 0x7fffffff); |
|
363 | 363 | |
364 | - $attrItems = $attributeManager->searchItems( $search, $domains ); |
|
364 | + $attrItems = $attributeManager->searchItems($search, $domains); |
|
365 | 365 | |
366 | - if( count( $attrItems ) !== count( $attributeIds ) ) |
|
366 | + if (count($attrItems) !== count($attributeIds)) |
|
367 | 367 | { |
368 | - $expected = implode( ',', $attributeIds ); |
|
369 | - $actual = implode( ',', array_keys( $attrItems ) ); |
|
370 | - $msg = sprintf( 'Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected ); |
|
368 | + $expected = implode(',', $attributeIds); |
|
369 | + $actual = implode(',', array_keys($attrItems)); |
|
370 | + $msg = sprintf('Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected); |
|
371 | 371 | |
372 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
372 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | return $attrItems; |
@@ -382,31 +382,31 @@ discard block |
||
382 | 382 | * @param \Aimeos\MShop\Order\Item\Base\Product\Attribute\Item[] $orderAttributes List of order product attribute items |
383 | 383 | * @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute IDs as key and attribute items as values |
384 | 384 | */ |
385 | - protected function getAttributeItems( array $orderAttributes ) |
|
385 | + protected function getAttributeItems(array $orderAttributes) |
|
386 | 386 | { |
387 | - if( empty( $orderAttributes ) ) { |
|
387 | + if (empty($orderAttributes)) { |
|
388 | 388 | return []; |
389 | 389 | } |
390 | 390 | |
391 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
392 | - $search = $attributeManager->createSearch( true ); |
|
391 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
392 | + $search = $attributeManager->createSearch(true); |
|
393 | 393 | $expr = []; |
394 | 394 | |
395 | - foreach( $orderAttributes as $item ) |
|
395 | + foreach ($orderAttributes as $item) |
|
396 | 396 | { |
397 | 397 | $tmp = array( |
398 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
399 | - $search->compare( '==', 'attribute.code', $item->getValue() ), |
|
400 | - $search->compare( '==', 'attribute.type.domain', 'product' ), |
|
401 | - $search->compare( '==', 'attribute.type.code', $item->getCode() ), |
|
402 | - $search->compare( '>', 'attribute.type.status', 0 ), |
|
398 | + $search->compare('==', 'attribute.domain', 'product'), |
|
399 | + $search->compare('==', 'attribute.code', $item->getValue()), |
|
400 | + $search->compare('==', 'attribute.type.domain', 'product'), |
|
401 | + $search->compare('==', 'attribute.type.code', $item->getCode()), |
|
402 | + $search->compare('>', 'attribute.type.status', 0), |
|
403 | 403 | $search->getConditions(), |
404 | 404 | ); |
405 | - $expr[] = $search->combine( '&&', $tmp ); |
|
405 | + $expr[] = $search->combine('&&', $tmp); |
|
406 | 406 | } |
407 | 407 | |
408 | - $search->setConditions( $search->combine( '||', $expr ) ); |
|
409 | - return $attributeManager->searchItems( $search, array( 'price' ) ); |
|
408 | + $search->setConditions($search->combine('||', $expr)); |
|
409 | + return $attributeManager->searchItems($search, array('price')); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | |
@@ -421,23 +421,23 @@ discard block |
||
421 | 421 | * @throws \Aimeos\Controller\Frontend\Basket\Exception |
422 | 422 | * @deprecated Use getItem() or findItem() instead |
423 | 423 | */ |
424 | - protected function getDomainItem( $domain, $key, $value, array $ref ) |
|
424 | + protected function getDomainItem($domain, $key, $value, array $ref) |
|
425 | 425 | { |
426 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $domain ); |
|
426 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $domain); |
|
427 | 427 | |
428 | - $search = $manager->createSearch( true ); |
|
428 | + $search = $manager->createSearch(true); |
|
429 | 429 | $expr = array( |
430 | - $search->compare( '==', $key, $value ), |
|
430 | + $search->compare('==', $key, $value), |
|
431 | 431 | $search->getConditions(), |
432 | 432 | ); |
433 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
433 | + $search->setConditions($search->combine('&&', $expr)); |
|
434 | 434 | |
435 | - $result = $manager->searchItems( $search, $ref ); |
|
435 | + $result = $manager->searchItems($search, $ref); |
|
436 | 436 | |
437 | - if( ( $item = reset( $result ) ) === false ) |
|
437 | + if (($item = reset($result)) === false) |
|
438 | 438 | { |
439 | - $msg = sprintf( 'No item for "%1$s" (%2$s) found', $value, $key ); |
|
440 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
439 | + $msg = sprintf('No item for "%1$s" (%2$s) found', $value, $key); |
|
440 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | return $item; |
@@ -451,26 +451,26 @@ discard block |
||
451 | 451 | * @param string $code Code of the list type |
452 | 452 | * @return \Aimeos\MShop\Common\Item\Type\Iface List type item |
453 | 453 | */ |
454 | - protected function getProductListTypeItem( $domain, $code ) |
|
454 | + protected function getProductListTypeItem($domain, $code) |
|
455 | 455 | { |
456 | - if( !isset( $this->listTypeAttributes[$domain][$code] ) ) |
|
456 | + if (!isset($this->listTypeAttributes[$domain][$code])) |
|
457 | 457 | { |
458 | - $listTypeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists/type' ); |
|
458 | + $listTypeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists/type'); |
|
459 | 459 | |
460 | - $listTypeSearch = $listTypeManager->createSearch( true ); |
|
460 | + $listTypeSearch = $listTypeManager->createSearch(true); |
|
461 | 461 | $expr = array( |
462 | - $listTypeSearch->compare( '==', 'product.lists.type.domain', $domain ), |
|
463 | - $listTypeSearch->compare( '==', 'product.lists.type.code', $code ), |
|
462 | + $listTypeSearch->compare('==', 'product.lists.type.domain', $domain), |
|
463 | + $listTypeSearch->compare('==', 'product.lists.type.code', $code), |
|
464 | 464 | $listTypeSearch->getConditions(), |
465 | 465 | ); |
466 | - $listTypeSearch->setConditions( $listTypeSearch->combine( '&&', $expr ) ); |
|
466 | + $listTypeSearch->setConditions($listTypeSearch->combine('&&', $expr)); |
|
467 | 467 | |
468 | - $listTypeItems = $listTypeManager->searchItems( $listTypeSearch ); |
|
468 | + $listTypeItems = $listTypeManager->searchItems($listTypeSearch); |
|
469 | 469 | |
470 | - if( ( $listTypeItem = reset( $listTypeItems ) ) === false ) |
|
470 | + if (($listTypeItem = reset($listTypeItems)) === false) |
|
471 | 471 | { |
472 | - $msg = sprintf( 'List type for domain "%1$s" and code "%2$s" not found', $domain, $code ); |
|
473 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
472 | + $msg = sprintf('List type for domain "%1$s" and code "%2$s" not found', $domain, $code); |
|
473 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | $this->listTypeAttributes[$domain][$code] = $listTypeItem; |
@@ -488,43 +488,43 @@ discard block |
||
488 | 488 | * @param array $domains Names of the domain items that should be fetched too |
489 | 489 | * @return array List of products matching the given attributes |
490 | 490 | */ |
491 | - protected function getProductVariants( \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, |
|
492 | - array $domains = array( 'attribute', 'media', 'price', 'text' ) ) |
|
491 | + protected function getProductVariants(\Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, |
|
492 | + array $domains = array('attribute', 'media', 'price', 'text')) |
|
493 | 493 | { |
494 | 494 | $subProductIds = []; |
495 | - foreach( $productItem->getRefItems( 'product', 'default', 'default' ) as $item ) { |
|
495 | + foreach ($productItem->getRefItems('product', 'default', 'default') as $item) { |
|
496 | 496 | $subProductIds[] = $item->getId(); |
497 | 497 | } |
498 | 498 | |
499 | - if( count( $subProductIds ) === 0 ) { |
|
499 | + if (count($subProductIds) === 0) { |
|
500 | 500 | return []; |
501 | 501 | } |
502 | 502 | |
503 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
504 | - $search = $productManager->createSearch( true ); |
|
503 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
504 | + $search = $productManager->createSearch(true); |
|
505 | 505 | |
506 | 506 | $expr = array( |
507 | - $search->compare( '==', 'product.id', $subProductIds ), |
|
507 | + $search->compare('==', 'product.id', $subProductIds), |
|
508 | 508 | $search->getConditions(), |
509 | 509 | ); |
510 | 510 | |
511 | - if( count( $variantAttributeIds ) > 0 ) |
|
511 | + if (count($variantAttributeIds) > 0) |
|
512 | 512 | { |
513 | - foreach( $variantAttributeIds as $key => $id ) { |
|
513 | + foreach ($variantAttributeIds as $key => $id) { |
|
514 | 514 | $variantAttributeIds[$key] = (string) $id; |
515 | 515 | } |
516 | 516 | |
517 | - $listTypeItem = $this->getProductListTypeItem( 'attribute', 'variant' ); |
|
517 | + $listTypeItem = $this->getProductListTypeItem('attribute', 'variant'); |
|
518 | 518 | |
519 | - $param = array( 'attribute', $listTypeItem->getId(), $variantAttributeIds ); |
|
520 | - $cmpfunc = $search->createFunction( 'product.contains', $param ); |
|
519 | + $param = array('attribute', $listTypeItem->getId(), $variantAttributeIds); |
|
520 | + $cmpfunc = $search->createFunction('product.contains', $param); |
|
521 | 521 | |
522 | - $expr[] = $search->compare( '==', $cmpfunc, count( $variantAttributeIds ) ); |
|
522 | + $expr[] = $search->compare('==', $cmpfunc, count($variantAttributeIds)); |
|
523 | 523 | } |
524 | 524 | |
525 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
525 | + $search->setConditions($search->combine('&&', $expr)); |
|
526 | 526 | |
527 | - return $productManager->searchItems( $search, $domains ); |
|
527 | + return $productManager->searchItems($search, $domains); |
|
528 | 528 | } |
529 | 529 | |
530 | 530 | |
@@ -536,9 +536,9 @@ discard block |
||
536 | 536 | * @param mixed $default Default value if no value is available for the given name |
537 | 537 | * @return mixed Value from the array or default value |
538 | 538 | */ |
539 | - protected function getValue( array $values, $name, $default = null ) |
|
539 | + protected function getValue(array $values, $name, $default = null) |
|
540 | 540 | { |
541 | - if( isset( $values[$name] ) ) { |
|
541 | + if (isset($values[$name])) { |
|
542 | 542 | return $values[$name]; |
543 | 543 | } |
544 | 544 |
@@ -18,114 +18,114 @@ discard block |
||
18 | 18 | protected function setUp() |
19 | 19 | { |
20 | 20 | $this->context = \TestHelperFrontend::getContext(); |
21 | - $this->object = new \Aimeos\Controller\Frontend\Customer\Standard( $this->context ); |
|
21 | + $this->object = new \Aimeos\Controller\Frontend\Customer\Standard($this->context); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | |
25 | 25 | protected function tearDown() |
26 | 26 | { |
27 | - unset( $this->context, $this->object ); |
|
27 | + unset($this->context, $this->object); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | |
31 | 31 | public function testAddEditSaveDeleteItem() |
32 | 32 | { |
33 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' ); |
|
34 | - $id = $manager->findItem( 'UTC001' )->getId(); |
|
33 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer'); |
|
34 | + $id = $manager->findItem('UTC001')->getId(); |
|
35 | 35 | |
36 | - $this->context->setUserId( $id ); |
|
37 | - $item = $this->object->addItem( ['customer.code' => 'unittest-ctnl', 'customer.status' => 1] ); |
|
38 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $item ); |
|
36 | + $this->context->setUserId($id); |
|
37 | + $item = $this->object->addItem(['customer.code' => 'unittest-ctnl', 'customer.status' => 1]); |
|
38 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $item); |
|
39 | 39 | |
40 | - $this->context->setUserId( $item->getId() ); |
|
41 | - $item = $this->object->editItem( $item->getId(), ['customer.code' => 'unittest-ctnl2'] ); |
|
42 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $item ); |
|
40 | + $this->context->setUserId($item->getId()); |
|
41 | + $item = $this->object->editItem($item->getId(), ['customer.code' => 'unittest-ctnl2']); |
|
42 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $item); |
|
43 | 43 | |
44 | - $item->setStatus( 0 ); |
|
45 | - $this->object->saveItem( $item ); |
|
46 | - $this->assertEquals( 0, $item->getStatus() ); |
|
44 | + $item->setStatus(0); |
|
45 | + $this->object->saveItem($item); |
|
46 | + $this->assertEquals(0, $item->getStatus()); |
|
47 | 47 | |
48 | - $this->object->deleteItem( $item->getId() ); |
|
48 | + $this->object->deleteItem($item->getId()); |
|
49 | 49 | |
50 | - $this->setExpectedException( '\Aimeos\MShop\Exception' ); |
|
51 | - $manager->findItem( 'unittest-ctnl' ); |
|
50 | + $this->setExpectedException('\Aimeos\MShop\Exception'); |
|
51 | + $manager->findItem('unittest-ctnl'); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
55 | 55 | public function testCreateItem() |
56 | 56 | { |
57 | 57 | $result = $this->object->createItem(); |
58 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $result ); |
|
58 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $result); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
62 | 62 | public function testGetItem() |
63 | 63 | { |
64 | - $id = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' )->findItem( 'UTC001' )->getId(); |
|
65 | - $this->context->setUserId( $id ); |
|
64 | + $id = \Aimeos\MShop\Factory::createManager($this->context, 'customer')->findItem('UTC001')->getId(); |
|
65 | + $this->context->setUserId($id); |
|
66 | 66 | |
67 | - $result = $this->object->getItem( $id, ['customer/address', 'text'] ); |
|
67 | + $result = $this->object->getItem($id, ['customer/address', 'text']); |
|
68 | 68 | |
69 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $result ); |
|
70 | - $this->assertEquals( 1, count( $result->getRefItems( 'text' ) ) ); |
|
71 | - $this->assertEquals( 1, count( $result->getAddressItems() ) ); |
|
69 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $result); |
|
70 | + $this->assertEquals(1, count($result->getRefItems('text'))); |
|
71 | + $this->assertEquals(1, count($result->getAddressItems())); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
75 | 75 | public function testFindItem() |
76 | 76 | { |
77 | - $result = $this->object->findItem( 'UTC001' ); |
|
78 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $result ); |
|
77 | + $result = $this->object->findItem('UTC001'); |
|
78 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $result); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
82 | 82 | public function testAddEditSaveDeleteAddressItem() |
83 | 83 | { |
84 | - $customer = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' )->findItem( 'UTC001' ); |
|
85 | - $this->context->setUserId( $customer->getId() ); |
|
84 | + $customer = \Aimeos\MShop\Factory::createManager($this->context, 'customer')->findItem('UTC001'); |
|
85 | + $this->context->setUserId($customer->getId()); |
|
86 | 86 | |
87 | - $item = $this->object->addAddressItem( ['customer.address.lastname' => 'unittest-ctnl'] ); |
|
88 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Address\Iface', $item ); |
|
87 | + $item = $this->object->addAddressItem(['customer.address.lastname' => 'unittest-ctnl']); |
|
88 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Address\Iface', $item); |
|
89 | 89 | |
90 | - $item = $this->object->editAddressItem( $item->getId(), ['customer.address.lastname' => 'unittest-ctnl2'] ); |
|
91 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Address\Iface', $item ); |
|
90 | + $item = $this->object->editAddressItem($item->getId(), ['customer.address.lastname' => 'unittest-ctnl2']); |
|
91 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Address\Iface', $item); |
|
92 | 92 | |
93 | - $item->setLastName( 'test' ); |
|
94 | - $this->object->saveAddressItem( $item ); |
|
95 | - $this->assertEquals( 'test', $item->getLastName() ); |
|
93 | + $item->setLastName('test'); |
|
94 | + $this->object->saveAddressItem($item); |
|
95 | + $this->assertEquals('test', $item->getLastName()); |
|
96 | 96 | |
97 | - $this->object->deleteAddressItem( $item->getId() ); |
|
97 | + $this->object->deleteAddressItem($item->getId()); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | |
101 | 101 | public function testCreateAddressItem() |
102 | 102 | { |
103 | 103 | $result = $this->object->createAddressItem(); |
104 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Address\Iface', $result ); |
|
104 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Address\Iface', $result); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | |
108 | 108 | public function testGetAddressItem() |
109 | 109 | { |
110 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer/address' ); |
|
110 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer/address'); |
|
111 | 111 | $search = $manager->createSearch(); |
112 | - $search->setSlice( 0, 1 ); |
|
113 | - $result = $manager->searchItems( $search ); |
|
112 | + $search->setSlice(0, 1); |
|
113 | + $result = $manager->searchItems($search); |
|
114 | 114 | |
115 | - if( ( $item = reset( $result ) ) === false ) { |
|
116 | - throw new \RuntimeException( 'No customer address available' ); |
|
115 | + if (($item = reset($result)) === false) { |
|
116 | + throw new \RuntimeException('No customer address available'); |
|
117 | 117 | } |
118 | 118 | |
119 | - $this->context->setUserId( $item->getParentId() ); |
|
120 | - $result = $this->object->getAddressItem( $item->getId() ); |
|
121 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Address\Iface', $result ); |
|
119 | + $this->context->setUserId($item->getParentId()); |
|
120 | + $result = $this->object->getAddressItem($item->getId()); |
|
121 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Address\Iface', $result); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | |
125 | 125 | public function testAddEditDeleteListItem() |
126 | 126 | { |
127 | - $customer = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' )->findItem( 'UTC001' ); |
|
128 | - $this->context->setUserId( $customer->getId() ); |
|
127 | + $customer = \Aimeos\MShop\Factory::createManager($this->context, 'customer')->findItem('UTC001'); |
|
128 | + $this->context->setUserId($customer->getId()); |
|
129 | 129 | |
130 | 130 | $values = [ |
131 | 131 | 'customer.lists.type' => 'favorite', |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | 'customer.lists.refid' => '-1' |
134 | 134 | ]; |
135 | 135 | |
136 | - $item = $this->object->addListItem( $values ); |
|
137 | - $this->assertInstanceOf( '\Aimeos\MShop\Common\Item\Lists\Iface', $item ); |
|
136 | + $item = $this->object->addListItem($values); |
|
137 | + $this->assertInstanceOf('\Aimeos\MShop\Common\Item\Lists\Iface', $item); |
|
138 | 138 | |
139 | 139 | $values = [ |
140 | 140 | 'customer.lists.type' => 'favorite', |
@@ -142,46 +142,46 @@ discard block |
||
142 | 142 | 'customer.lists.refid' => '-2' |
143 | 143 | ]; |
144 | 144 | |
145 | - $item = $this->object->editListItem( $item->getId(), $values ); |
|
146 | - $this->assertInstanceOf( '\Aimeos\MShop\Common\Item\Lists\Iface', $item ); |
|
145 | + $item = $this->object->editListItem($item->getId(), $values); |
|
146 | + $this->assertInstanceOf('\Aimeos\MShop\Common\Item\Lists\Iface', $item); |
|
147 | 147 | |
148 | - $this->object->deleteListItem( $item->getId() ); |
|
148 | + $this->object->deleteListItem($item->getId()); |
|
149 | 149 | |
150 | - $this->setExpectedException( '\Aimeos\MShop\Exception' ); |
|
151 | - $this->object->getListItem( $item->getId() ); |
|
150 | + $this->setExpectedException('\Aimeos\MShop\Exception'); |
|
151 | + $this->object->getListItem($item->getId()); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | |
155 | 155 | public function testGetListItem() |
156 | 156 | { |
157 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer/lists' ); |
|
157 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer/lists'); |
|
158 | 158 | $search = $manager->createSearch(); |
159 | - $search->setSlice( 0, 1 ); |
|
160 | - $result = $manager->searchItems( $search ); |
|
159 | + $search->setSlice(0, 1); |
|
160 | + $result = $manager->searchItems($search); |
|
161 | 161 | |
162 | - if( ( $item = reset( $result ) ) === false ) { |
|
163 | - throw new \RuntimeException( 'No customer lists item available' ); |
|
162 | + if (($item = reset($result)) === false) { |
|
163 | + throw new \RuntimeException('No customer lists item available'); |
|
164 | 164 | } |
165 | 165 | |
166 | - $this->context->setUserId( $item->getParentId() ); |
|
167 | - $result = $this->object->getListItem( $item->getId() ); |
|
168 | - $this->assertInstanceOf( '\Aimeos\MShop\Common\Item\Lists\Iface', $result ); |
|
166 | + $this->context->setUserId($item->getParentId()); |
|
167 | + $result = $this->object->getListItem($item->getId()); |
|
168 | + $this->assertInstanceOf('\Aimeos\MShop\Common\Item\Lists\Iface', $result); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | |
172 | 172 | public function testSearchListItem() |
173 | 173 | { |
174 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' ); |
|
175 | - $customer = $manager->findItem( 'UTC001' ); |
|
176 | - $this->context->setUserId( $customer->getId() ); |
|
174 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer'); |
|
175 | + $customer = $manager->findItem('UTC001'); |
|
176 | + $this->context->setUserId($customer->getId()); |
|
177 | 177 | |
178 | 178 | $filter = $this->object->createListsFilter(); |
179 | - $result = $this->object->searchListItems( $filter ); |
|
179 | + $result = $this->object->searchListItems($filter); |
|
180 | 180 | |
181 | - foreach( $result as $item ) |
|
181 | + foreach ($result as $item) |
|
182 | 182 | { |
183 | - $this->assertEquals( $customer->getId(), $item->getParentId() ); |
|
184 | - $this->assertInstanceOf( '\Aimeos\MShop\Common\Item\Lists\Iface', $item ); |
|
183 | + $this->assertEquals($customer->getId(), $item->getParentId()); |
|
184 | + $this->assertInstanceOf('\Aimeos\MShop\Common\Item\Lists\Iface', $item); |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | } |
@@ -28,14 +28,14 @@ discard block |
||
28 | 28 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item |
29 | 29 | * @since 2017.04 |
30 | 30 | */ |
31 | - public function addItem( array $values ) |
|
31 | + public function addItem(array $values) |
|
32 | 32 | { |
33 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' ); |
|
33 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer'); |
|
34 | 34 | |
35 | 35 | $item = $manager->createItem(); |
36 | - $item->fromArray( $values ); |
|
37 | - $item->setId( null ); |
|
38 | - $manager->saveItem( $item ); |
|
36 | + $item->fromArray($values); |
|
37 | + $item->setId(null); |
|
38 | + $manager->saveItem($item); |
|
39 | 39 | |
40 | 40 | return $item; |
41 | 41 | } |
@@ -46,14 +46,14 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item |
48 | 48 | */ |
49 | - public function createItem( array $values = [] ) |
|
49 | + public function createItem(array $values = []) |
|
50 | 50 | { |
51 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' ); |
|
51 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer'); |
|
52 | 52 | |
53 | 53 | $item = $manager->createItem(); |
54 | - $item->fromArray( $values ); |
|
55 | - $item->setId( null ); |
|
56 | - $item->setStatus( 1 ); |
|
54 | + $item->fromArray($values); |
|
55 | + $item->setId(null); |
|
56 | + $item->setStatus(1); |
|
57 | 57 | |
58 | 58 | return $item; |
59 | 59 | } |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | * @param string $id Unique customer ID |
66 | 66 | * @since 2017.04 |
67 | 67 | */ |
68 | - public function deleteItem( $id ) |
|
68 | + public function deleteItem($id) |
|
69 | 69 | { |
70 | - $this->checkUser( $id ); |
|
70 | + $this->checkUser($id); |
|
71 | 71 | |
72 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' ); |
|
73 | - $manager->deleteItem( $id ); |
|
72 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer'); |
|
73 | + $manager->deleteItem($id); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | |
@@ -82,16 +82,16 @@ discard block |
||
82 | 82 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item |
83 | 83 | * @since 2017.04 |
84 | 84 | */ |
85 | - public function editItem( $id, array $values ) |
|
85 | + public function editItem($id, array $values) |
|
86 | 86 | { |
87 | - $this->checkUser( $id ); |
|
87 | + $this->checkUser($id); |
|
88 | 88 | |
89 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' ); |
|
89 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer'); |
|
90 | 90 | |
91 | - $item = $manager->getItem( $id, [], true ); |
|
92 | - $item->fromArray( $values ); |
|
93 | - $item->setId( $id ); |
|
94 | - $manager->saveItem( $item ); |
|
91 | + $item = $manager->getItem($id, [], true); |
|
92 | + $item->fromArray($values); |
|
93 | + $item->setId($id); |
|
94 | + $manager->saveItem($item); |
|
95 | 95 | |
96 | 96 | return $item; |
97 | 97 | } |
@@ -105,17 +105,17 @@ discard block |
||
105 | 105 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item including the referenced domains items |
106 | 106 | * @since 2017.04 |
107 | 107 | */ |
108 | - public function getItem( $id = null, array $domains = [] ) |
|
108 | + public function getItem($id = null, array $domains = []) |
|
109 | 109 | { |
110 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' ); |
|
110 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer'); |
|
111 | 111 | |
112 | - if( $id == null ) { |
|
113 | - return $manager->getItem( $this->getContext()->getUserId(), $domains, true ); |
|
112 | + if ($id == null) { |
|
113 | + return $manager->getItem($this->getContext()->getUserId(), $domains, true); |
|
114 | 114 | } |
115 | 115 | |
116 | - $this->checkUser( $id ); |
|
116 | + $this->checkUser($id); |
|
117 | 117 | |
118 | - return $manager->getItem( $id, $domains, true ); |
|
118 | + return $manager->getItem($id, $domains, true); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item including the referenced domains items |
130 | 130 | * @since 2017.04 |
131 | 131 | */ |
132 | - public function findItem( $code, array $domains = [] ) |
|
132 | + public function findItem($code, array $domains = []) |
|
133 | 133 | { |
134 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' )->findItem( $code, $domains ); |
|
134 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer')->findItem($code, $domains); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | |
@@ -140,9 +140,9 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @param \Aimeos\MShop\Customer\Item\Iface Customer item |
142 | 142 | */ |
143 | - public function saveItem( \Aimeos\MShop\Customer\Item\Iface $item ) |
|
143 | + public function saveItem(\Aimeos\MShop\Customer\Item\Iface $item) |
|
144 | 144 | { |
145 | - \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' )->saveItem( $item ); |
|
145 | + \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer')->saveItem($item); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | |
@@ -153,17 +153,17 @@ discard block |
||
153 | 153 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
154 | 154 | * @since 2017.04 |
155 | 155 | */ |
156 | - public function addAddressItem( array $values ) |
|
156 | + public function addAddressItem(array $values) |
|
157 | 157 | { |
158 | 158 | $context = $this->getContext(); |
159 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/address' ); |
|
159 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/address'); |
|
160 | 160 | |
161 | 161 | $item = $manager->createItem(); |
162 | - $item->fromArray( $values ); |
|
163 | - $item->setId( null ); |
|
164 | - $item->setParentId( $context->getUserId() ); |
|
162 | + $item->fromArray($values); |
|
163 | + $item->setId(null); |
|
164 | + $item->setParentId($context->getUserId()); |
|
165 | 165 | |
166 | - $manager->saveItem( $item ); |
|
166 | + $manager->saveItem($item); |
|
167 | 167 | |
168 | 168 | return $item; |
169 | 169 | } |
@@ -174,16 +174,16 @@ discard block |
||
174 | 174 | * |
175 | 175 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
176 | 176 | */ |
177 | - public function createAddressItem( array $values = [] ) |
|
177 | + public function createAddressItem(array $values = []) |
|
178 | 178 | { |
179 | 179 | $context = $this->getContext(); |
180 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/address' ); |
|
180 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/address'); |
|
181 | 181 | |
182 | 182 | $item = $manager->createItem(); |
183 | - $item->fromArray( $values ); |
|
184 | - $item->setId( null ); |
|
183 | + $item->fromArray($values); |
|
184 | + $item->setId(null); |
|
185 | 185 | |
186 | - $item->setParentId( $context->getUserId() ); |
|
186 | + $item->setParentId($context->getUserId()); |
|
187 | 187 | |
188 | 188 | return $item; |
189 | 189 | } |
@@ -195,13 +195,13 @@ discard block |
||
195 | 195 | * @param string $id Unique customer address ID |
196 | 196 | * @since 2017.04 |
197 | 197 | */ |
198 | - public function deleteAddressItem( $id ) |
|
198 | + public function deleteAddressItem($id) |
|
199 | 199 | { |
200 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/address' ); |
|
200 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/address'); |
|
201 | 201 | |
202 | - $this->checkUser( $manager->getItem( $id, [], true )->getParentId() ); |
|
202 | + $this->checkUser($manager->getItem($id, [], true)->getParentId()); |
|
203 | 203 | |
204 | - $manager->deleteItem( $id ); |
|
204 | + $manager->deleteItem($id); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | |
@@ -213,17 +213,17 @@ discard block |
||
213 | 213 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
214 | 214 | * @since 2017.04 |
215 | 215 | */ |
216 | - public function editAddressItem( $id, array $values ) |
|
216 | + public function editAddressItem($id, array $values) |
|
217 | 217 | { |
218 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/address' ); |
|
218 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/address'); |
|
219 | 219 | |
220 | - $item = $manager->getItem( $id, [], true ); |
|
221 | - $this->checkUser( $item->getParentId() ); |
|
220 | + $item = $manager->getItem($id, [], true); |
|
221 | + $this->checkUser($item->getParentId()); |
|
222 | 222 | |
223 | - $item->fromArray( $values ); |
|
224 | - $item->setId( $id ); |
|
223 | + $item->fromArray($values); |
|
224 | + $item->setId($id); |
|
225 | 225 | |
226 | - $manager->saveItem( $item ); |
|
226 | + $manager->saveItem($item); |
|
227 | 227 | |
228 | 228 | return $item; |
229 | 229 | } |
@@ -236,12 +236,12 @@ discard block |
||
236 | 236 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
237 | 237 | * @since 2017.04 |
238 | 238 | */ |
239 | - public function getAddressItem( $id ) |
|
239 | + public function getAddressItem($id) |
|
240 | 240 | { |
241 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/address' ); |
|
241 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/address'); |
|
242 | 242 | |
243 | - $item = $manager->getItem( $id ); |
|
244 | - $this->checkUser( $item->getParentId() ); |
|
243 | + $item = $manager->getItem($id); |
|
244 | + $this->checkUser($item->getParentId()); |
|
245 | 245 | |
246 | 246 | return $item; |
247 | 247 | } |
@@ -252,9 +252,9 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @param \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
254 | 254 | */ |
255 | - public function saveAddressItem( \Aimeos\MShop\Customer\Item\Address\Iface $item ) |
|
255 | + public function saveAddressItem(\Aimeos\MShop\Customer\Item\Address\Iface $item) |
|
256 | 256 | { |
257 | - \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/address' )->saveItem( $item ); |
|
257 | + \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/address')->saveItem($item); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | |
@@ -265,32 +265,32 @@ discard block |
||
265 | 265 | * @return \Aimeos\MShop\Common\Item\Lists\Iface Customer lists item |
266 | 266 | * @since 2017.06 |
267 | 267 | */ |
268 | - public function addListItem( array $values ) |
|
268 | + public function addListItem(array $values) |
|
269 | 269 | { |
270 | 270 | $context = $this->getContext(); |
271 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists' ); |
|
271 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists'); |
|
272 | 272 | |
273 | - if( !isset( $values['customer.lists.typeid'] ) ) |
|
273 | + if (!isset($values['customer.lists.typeid'])) |
|
274 | 274 | { |
275 | - if( !isset( $values['customer.lists.type'] ) ) { |
|
276 | - throw new \Aimeos\Controller\Frontend\Customer\Exception( sprintf( 'No customer lists type code' ) ); |
|
275 | + if (!isset($values['customer.lists.type'])) { |
|
276 | + throw new \Aimeos\Controller\Frontend\Customer\Exception(sprintf('No customer lists type code')); |
|
277 | 277 | } |
278 | 278 | |
279 | - if( !isset( $values['customer.lists.domain'] ) ) { |
|
280 | - throw new \Aimeos\Controller\Frontend\Customer\Exception( sprintf( 'No customer lists domain' ) ); |
|
279 | + if (!isset($values['customer.lists.domain'])) { |
|
280 | + throw new \Aimeos\Controller\Frontend\Customer\Exception(sprintf('No customer lists domain')); |
|
281 | 281 | } |
282 | 282 | |
283 | - $typeManager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists/type' ); |
|
284 | - $typeItem = $typeManager->findItem( $values['customer.lists.type'], [], $values['customer.lists.domain'] ); |
|
283 | + $typeManager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists/type'); |
|
284 | + $typeItem = $typeManager->findItem($values['customer.lists.type'], [], $values['customer.lists.domain']); |
|
285 | 285 | $values['customer.lists.typeid'] = $typeItem->getId(); |
286 | 286 | } |
287 | 287 | |
288 | 288 | $item = $manager->createItem(); |
289 | - $item->fromArray( $values ); |
|
290 | - $item->setId( null ); |
|
291 | - $item->setParentId( $context->getUserId() ); |
|
289 | + $item->fromArray($values); |
|
290 | + $item->setId(null); |
|
291 | + $item->setParentId($context->getUserId()); |
|
292 | 292 | |
293 | - $manager->saveItem( $item ); |
|
293 | + $manager->saveItem($item); |
|
294 | 294 | |
295 | 295 | return $item; |
296 | 296 | } |
@@ -305,10 +305,10 @@ discard block |
||
305 | 305 | public function createListsFilter() |
306 | 306 | { |
307 | 307 | $context = $this->getContext(); |
308 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists' ); |
|
308 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists'); |
|
309 | 309 | |
310 | 310 | $filter = $manager->createSearch(); |
311 | - $filter->setConditions( $filter->compare( '==', 'customer.lists.parentid', $context->getUserId() ) ); |
|
311 | + $filter->setConditions($filter->compare('==', 'customer.lists.parentid', $context->getUserId())); |
|
312 | 312 | |
313 | 313 | return $filter; |
314 | 314 | } |
@@ -320,13 +320,13 @@ discard block |
||
320 | 320 | * @param string $id Unique customer address ID |
321 | 321 | * @since 2017.06 |
322 | 322 | */ |
323 | - public function deleteListItem( $id ) |
|
323 | + public function deleteListItem($id) |
|
324 | 324 | { |
325 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/lists' ); |
|
325 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/lists'); |
|
326 | 326 | |
327 | - $this->checkUser( $manager->getItem( $id )->getParentId() ); |
|
327 | + $this->checkUser($manager->getItem($id)->getParentId()); |
|
328 | 328 | |
329 | - $manager->deleteItem( $id ); |
|
329 | + $manager->deleteItem($id); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | |
@@ -338,33 +338,33 @@ discard block |
||
338 | 338 | * @return \Aimeos\MShop\Common\Item\Lists\Iface Customer lists item |
339 | 339 | * @since 2017.06 |
340 | 340 | */ |
341 | - public function editListItem( $id, array $values ) |
|
341 | + public function editListItem($id, array $values) |
|
342 | 342 | { |
343 | 343 | $context = $this->getContext(); |
344 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists' ); |
|
344 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists'); |
|
345 | 345 | |
346 | - $item = $manager->getItem( $id, [], true ); |
|
347 | - $this->checkUser( $item->getParentId() ); |
|
346 | + $item = $manager->getItem($id, [], true); |
|
347 | + $this->checkUser($item->getParentId()); |
|
348 | 348 | |
349 | - if( !isset( $values['customer.lists.typeid'] ) ) |
|
349 | + if (!isset($values['customer.lists.typeid'])) |
|
350 | 350 | { |
351 | - if( !isset( $values['customer.lists.type'] ) ) { |
|
352 | - throw new \Aimeos\Controller\Frontend\Customer\Exception( sprintf( 'No customer lists type code' ) ); |
|
351 | + if (!isset($values['customer.lists.type'])) { |
|
352 | + throw new \Aimeos\Controller\Frontend\Customer\Exception(sprintf('No customer lists type code')); |
|
353 | 353 | } |
354 | 354 | |
355 | - if( !isset( $values['customer.lists.domain'] ) ) { |
|
356 | - throw new \Aimeos\Controller\Frontend\Customer\Exception( sprintf( 'No customer lists domain' ) ); |
|
355 | + if (!isset($values['customer.lists.domain'])) { |
|
356 | + throw new \Aimeos\Controller\Frontend\Customer\Exception(sprintf('No customer lists domain')); |
|
357 | 357 | } |
358 | 358 | |
359 | - $typeManager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists/type' ); |
|
360 | - $typeItem = $typeManager->findItem( $values['customer.lists.type'], [], $values['customer.lists.domain'] ); |
|
359 | + $typeManager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists/type'); |
|
360 | + $typeItem = $typeManager->findItem($values['customer.lists.type'], [], $values['customer.lists.domain']); |
|
361 | 361 | $values['customer.lists.typeid'] = $typeItem->getId(); |
362 | 362 | } |
363 | 363 | |
364 | - $item->fromArray( $values ); |
|
365 | - $item->setId( $id ); |
|
364 | + $item->fromArray($values); |
|
365 | + $item->setId($id); |
|
366 | 366 | |
367 | - $manager->saveItem( $item ); |
|
367 | + $manager->saveItem($item); |
|
368 | 368 | |
369 | 369 | return $item; |
370 | 370 | } |
@@ -377,12 +377,12 @@ discard block |
||
377 | 377 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
378 | 378 | * @since 2017.06 |
379 | 379 | */ |
380 | - public function getListItem( $id ) |
|
380 | + public function getListItem($id) |
|
381 | 381 | { |
382 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/lists' ); |
|
383 | - $item = $manager->getItem( $id ); |
|
382 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/lists'); |
|
383 | + $item = $manager->getItem($id); |
|
384 | 384 | |
385 | - $this->checkUser( $item->getParentId() ); |
|
385 | + $this->checkUser($item->getParentId()); |
|
386 | 386 | |
387 | 387 | return $item; |
388 | 388 | } |
@@ -396,11 +396,11 @@ discard block |
||
396 | 396 | * @return \Aimeos\MShop\Common\Item\Lists\Iface[] Customer list items |
397 | 397 | * @since 2017.06 |
398 | 398 | */ |
399 | - public function searchListItems( \Aimeos\MW\Criteria\Iface $filter, &$total = null ) |
|
399 | + public function searchListItems(\Aimeos\MW\Criteria\Iface $filter, &$total = null) |
|
400 | 400 | { |
401 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/lists' ); |
|
401 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/lists'); |
|
402 | 402 | |
403 | - return $manager->searchItems( $filter, [], $total ); |
|
403 | + return $manager->searchItems($filter, [], $total); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | |
@@ -410,12 +410,12 @@ discard block |
||
410 | 410 | * @param string $id Unique customer ID |
411 | 411 | * @throws \Aimeos\Controller\Frontend\Customer\Exception If access isn't allowed |
412 | 412 | */ |
413 | - protected function checkUser( $id ) |
|
413 | + protected function checkUser($id) |
|
414 | 414 | { |
415 | - if( $id != $this->getContext()->getUserId() ) |
|
415 | + if ($id != $this->getContext()->getUserId()) |
|
416 | 416 | { |
417 | - $msg = sprintf( 'Not allowed to access customer data for ID "%1$s"', $id ); |
|
418 | - throw new \Aimeos\Controller\Frontend\Customer\Exception( $msg ); |
|
417 | + $msg = sprintf('Not allowed to access customer data for ID "%1$s"', $id); |
|
418 | + throw new \Aimeos\Controller\Frontend\Customer\Exception($msg); |
|
419 | 419 | } |
420 | 420 | } |
421 | 421 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item |
27 | 27 | * @since 2017.04 |
28 | 28 | */ |
29 | - public function addItem( array $values ); |
|
29 | + public function addItem(array $values); |
|
30 | 30 | |
31 | 31 | |
32 | 32 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item |
36 | 36 | * @since 2017.04 |
37 | 37 | */ |
38 | - public function createItem( array $values = [] ); |
|
38 | + public function createItem(array $values = []); |
|
39 | 39 | |
40 | 40 | |
41 | 41 | /** |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param string $id Unique customer ID |
45 | 45 | * @since 2017.04 |
46 | 46 | */ |
47 | - public function deleteItem( $id ); |
|
47 | + public function deleteItem($id); |
|
48 | 48 | |
49 | 49 | |
50 | 50 | /** |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item |
56 | 56 | * @since 2017.04 |
57 | 57 | */ |
58 | - public function editItem( $id, array $values ); |
|
58 | + public function editItem($id, array $values); |
|
59 | 59 | |
60 | 60 | |
61 | 61 | /** |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item including the referenced domains items |
67 | 67 | * @since 2017.04 |
68 | 68 | */ |
69 | - public function getItem( $id = null, array $domains = [] ); |
|
69 | + public function getItem($id = null, array $domains = []); |
|
70 | 70 | |
71 | 71 | |
72 | 72 | /** |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item including the referenced domains items |
80 | 80 | * @since 2017.04 |
81 | 81 | */ |
82 | - public function findItem( $code, array $domains = [] ); |
|
82 | + public function findItem($code, array $domains = []); |
|
83 | 83 | |
84 | 84 | |
85 | 85 | /** |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @param \Aimeos\MShop\Customer\Item\Iface Customer item |
89 | 89 | * @since 2017.04 |
90 | 90 | */ |
91 | - public function saveItem( \Aimeos\MShop\Customer\Item\Iface $item ); |
|
91 | + public function saveItem(\Aimeos\MShop\Customer\Item\Iface $item); |
|
92 | 92 | |
93 | 93 | |
94 | 94 | /** |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @return \Aimeos\MShop\Customer\Item\Iface Customer address item |
99 | 99 | * @since 2017.04 |
100 | 100 | */ |
101 | - public function addAddressItem( array $values ); |
|
101 | + public function addAddressItem(array $values); |
|
102 | 102 | |
103 | 103 | |
104 | 104 | /** |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
108 | 108 | * @since 2017.04 |
109 | 109 | */ |
110 | - public function createAddressItem( array $values = [] ); |
|
110 | + public function createAddressItem(array $values = []); |
|
111 | 111 | |
112 | 112 | |
113 | 113 | /** |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @param string $id Unique customer address ID |
117 | 117 | * @since 2017.04 |
118 | 118 | */ |
119 | - public function deleteAddressItem( $id ); |
|
119 | + public function deleteAddressItem($id); |
|
120 | 120 | |
121 | 121 | |
122 | 122 | /** |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @return \Aimeos\MShop\Customer\Item\Iface Customer address item |
128 | 128 | * @since 2017.04 |
129 | 129 | */ |
130 | - public function editAddressItem( $id, array $values ); |
|
130 | + public function editAddressItem($id, array $values); |
|
131 | 131 | |
132 | 132 | |
133 | 133 | /** |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
138 | 138 | * @since 2017.04 |
139 | 139 | */ |
140 | - public function getAddressItem( $id ); |
|
140 | + public function getAddressItem($id); |
|
141 | 141 | |
142 | 142 | |
143 | 143 | /** |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @param \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
147 | 147 | * @since 2017.04 |
148 | 148 | */ |
149 | - public function saveAddressItem( \Aimeos\MShop\Customer\Item\Address\Iface $item ); |
|
149 | + public function saveAddressItem(\Aimeos\MShop\Customer\Item\Address\Iface $item); |
|
150 | 150 | |
151 | 151 | /** |
152 | 152 | * Creates and returns a new list item object |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @return \Aimeos\MShop\Common\Item\Lists\Iface Customer lists item |
156 | 156 | * @since 2017.06 |
157 | 157 | */ |
158 | - public function addListItem( array $values ); |
|
158 | + public function addListItem(array $values); |
|
159 | 159 | |
160 | 160 | /** |
161 | 161 | * Returns a new customer lists filter criteria object |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | * @param string $id Unique customer address ID |
172 | 172 | * @since 2017.06 |
173 | 173 | */ |
174 | - public function deleteListItem( $id ); |
|
174 | + public function deleteListItem($id); |
|
175 | 175 | |
176 | 176 | /** |
177 | 177 | * Saves a modified customer lists item object |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * @return \Aimeos\MShop\Common\Item\Lists\Iface Customer lists item |
182 | 182 | * @since 2017.06 |
183 | 183 | */ |
184 | - public function editListItem( $id, array $values ); |
|
184 | + public function editListItem($id, array $values); |
|
185 | 185 | |
186 | 186 | /** |
187 | 187 | * Returns the customer item for the given customer ID |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
191 | 191 | * @since 2017.06 |
192 | 192 | */ |
193 | - public function getListItem( $id ); |
|
193 | + public function getListItem($id); |
|
194 | 194 | |
195 | 195 | /** |
196 | 196 | * Returns the customer lists items filtered by the given criteria |
@@ -200,5 +200,5 @@ discard block |
||
200 | 200 | * @return \Aimeos\MShop\Common\Item\Lists\Iface[] Customer list items |
201 | 201 | * @since 2017.06 |
202 | 202 | */ |
203 | - public function searchListItems( \Aimeos\MW\Criteria\Iface $filter, &$total = null ); |
|
203 | + public function searchListItems(\Aimeos\MW\Criteria\Iface $filter, &$total = null); |
|
204 | 204 | } |
@@ -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; |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @category Developer |
127 | 127 | * @see controller/frontend/basket/limit-seconds |
128 | 128 | */ |
129 | - $count = $config->get( 'controller/frontend/basket/limit-count', 5 ); |
|
129 | + $count = $config->get('controller/frontend/basket/limit-count', 5); |
|
130 | 130 | |
131 | 131 | /** controller/frontend/basket/limit-seconds |
132 | 132 | * Order limitation time frame in seconds |
@@ -144,27 +144,27 @@ discard block |
||
144 | 144 | * @category Developer |
145 | 145 | * @see controller/frontend/basket/limit-count |
146 | 146 | */ |
147 | - $seconds = $config->get( 'controller/frontend/basket/limit-seconds', 300 ); |
|
147 | + $seconds = $config->get('controller/frontend/basket/limit-seconds', 300); |
|
148 | 148 | |
149 | 149 | $search = $this->domainManager->createSearch(); |
150 | 150 | $expr = [ |
151 | - $search->compare( '==', 'order.base.editor', $this->getContext()->getEditor() ), |
|
152 | - $search->compare( '>=', 'order.base.ctime', date( 'Y-m-d H:i:s', time() - $seconds ) ), |
|
151 | + $search->compare('==', 'order.base.editor', $this->getContext()->getEditor()), |
|
152 | + $search->compare('>=', 'order.base.ctime', date('Y-m-d H:i:s', time() - $seconds)), |
|
153 | 153 | ]; |
154 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
155 | - $search->setSlice( 0, 0 ); |
|
154 | + $search->setConditions($search->combine('&&', $expr)); |
|
155 | + $search->setSlice(0, 0); |
|
156 | 156 | |
157 | - $this->domainManager->searchItems( $search, [], $total ); |
|
157 | + $this->domainManager->searchItems($search, [], $total); |
|
158 | 158 | |
159 | - if( $total > $count ) { |
|
160 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Temporary order limit reached' ) ); |
|
159 | + if ($total > $count) { |
|
160 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Temporary order limit reached')); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | |
164 | 164 | $basket = $this->get()->finish(); |
165 | 165 | |
166 | 166 | $this->domainManager->begin(); |
167 | - $this->domainManager->store( $basket ); |
|
167 | + $this->domainManager->store($basket); |
|
168 | 168 | $this->domainManager->commit(); |
169 | 169 | |
170 | 170 | return $basket; |
@@ -179,9 +179,9 @@ discard block |
||
179 | 179 | * @param boolean $default True to add default criteria (user logged in), false if not |
180 | 180 | * @return \Aimeos\MShop\Order\Item\Base\Iface Order base object including the given parts |
181 | 181 | */ |
182 | - public function load( $id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true ) |
|
182 | + public function load($id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true) |
|
183 | 183 | { |
184 | - return $this->domainManager->load( $id, $parts, false, $default ); |
|
184 | + return $this->domainManager->load($id, $parts, false, $default); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | |
@@ -201,36 +201,36 @@ discard block |
||
201 | 201 | * @param string $stocktype Unique code of the stock type to deliver the products from |
202 | 202 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
203 | 203 | */ |
204 | - public function addProduct( $prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [], |
|
204 | + public function addProduct($prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [], |
|
205 | 205 | array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [], |
206 | - $stocktype = 'default' ) |
|
206 | + $stocktype = 'default') |
|
207 | 207 | { |
208 | 208 | $context = $this->getContext(); |
209 | - $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
210 | - $productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ), true ); |
|
209 | + $productManager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
210 | + $productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text'), true); |
|
211 | 211 | |
212 | - $orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem(); |
|
213 | - $orderBaseProductItem->copyFrom( $productItem ); |
|
214 | - $orderBaseProductItem->setQuantity( $quantity ); |
|
215 | - $orderBaseProductItem->setStockType( $stocktype ); |
|
212 | + $orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem(); |
|
213 | + $orderBaseProductItem->copyFrom($productItem); |
|
214 | + $orderBaseProductItem->setQuantity($quantity); |
|
215 | + $orderBaseProductItem->setStockType($stocktype); |
|
216 | 216 | |
217 | 217 | $attr = []; |
218 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
218 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
219 | 219 | |
220 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
221 | - $price = $priceManager->getLowestPrice( $prices, $quantity ); |
|
220 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
221 | + $price = $priceManager->getLowestPrice($prices, $quantity); |
|
222 | 222 | |
223 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, $configAttributeIds, 'config' ) ); |
|
224 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, $hiddenAttributeIds, 'hidden' ) ); |
|
225 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, array_keys( $customAttributeValues ), 'custom', $customAttributeValues ) ); |
|
223 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, $configAttributeIds, 'config')); |
|
224 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, $hiddenAttributeIds, 'hidden')); |
|
225 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, array_keys($customAttributeValues), 'custom', $customAttributeValues)); |
|
226 | 226 | |
227 | 227 | // remove product rebate of original price in favor to rebates granted for the order |
228 | - $price->setRebate( '0.00' ); |
|
228 | + $price->setRebate('0.00'); |
|
229 | 229 | |
230 | - $orderBaseProductItem->setPrice( $price ); |
|
231 | - $orderBaseProductItem->setAttributes( $attr ); |
|
230 | + $orderBaseProductItem->setPrice($price); |
|
231 | + $orderBaseProductItem->setAttributes($attr); |
|
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,34 +264,34 @@ 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 | - $prices = $productItem->getRefItems( 'price', 'default' ); |
|
292 | - $product->setPrice( $this->calcPrice( $product, $prices, $quantity ) ); |
|
289 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
290 | + $productItem = $manager->findItem($product->getProductCode(), array('price', 'text')); |
|
291 | + $prices = $productItem->getRefItems('price', 'default'); |
|
292 | + $product->setPrice($this->calcPrice($product, $prices, $quantity)); |
|
293 | 293 | |
294 | - $this->get()->editProduct( $product, $position ); |
|
294 | + $this->get()->editProduct($product, $position); |
|
295 | 295 | |
296 | 296 | $this->save(); |
297 | 297 | } |
@@ -303,49 +303,49 @@ discard block |
||
303 | 303 | * @param string $code Coupon code entered by the user |
304 | 304 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed |
305 | 305 | */ |
306 | - public function addCoupon( $code ) |
|
306 | + public function addCoupon($code) |
|
307 | 307 | { |
308 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' ); |
|
309 | - $codeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon/code' ); |
|
308 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon'); |
|
309 | + $codeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon/code'); |
|
310 | 310 | |
311 | 311 | |
312 | - $search = $codeManager->createSearch( true ); |
|
312 | + $search = $codeManager->createSearch(true); |
|
313 | 313 | $expr = array( |
314 | - $search->compare( '==', 'coupon.code.code', $code ), |
|
314 | + $search->compare('==', 'coupon.code.code', $code), |
|
315 | 315 | $search->getConditions(), |
316 | 316 | ); |
317 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
318 | - $search->setSlice( 0, 1 ); |
|
317 | + $search->setConditions($search->combine('&&', $expr)); |
|
318 | + $search->setSlice(0, 1); |
|
319 | 319 | |
320 | - $result = $codeManager->searchItems( $search ); |
|
320 | + $result = $codeManager->searchItems($search); |
|
321 | 321 | |
322 | - if( ( $codeItem = reset( $result ) ) === false ) { |
|
323 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon code "%1$s" is invalid or not available any more', $code ) ); |
|
322 | + if (($codeItem = reset($result)) === false) { |
|
323 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon code "%1$s" is invalid or not available any more', $code)); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | |
327 | - $search = $manager->createSearch( true ); |
|
327 | + $search = $manager->createSearch(true); |
|
328 | 328 | $expr = array( |
329 | - $search->compare( '==', 'coupon.id', $codeItem->getParentId() ), |
|
329 | + $search->compare('==', 'coupon.id', $codeItem->getParentId()), |
|
330 | 330 | $search->getConditions(), |
331 | 331 | ); |
332 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
333 | - $search->setSlice( 0, 1 ); |
|
332 | + $search->setConditions($search->combine('&&', $expr)); |
|
333 | + $search->setSlice(0, 1); |
|
334 | 334 | |
335 | - $result = $manager->searchItems( $search ); |
|
335 | + $result = $manager->searchItems($search); |
|
336 | 336 | |
337 | - if( ( $item = reset( $result ) ) === false ) { |
|
338 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon for code "%1$s" is not available any more', $code ) ); |
|
337 | + if (($item = reset($result)) === false) { |
|
338 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon for code "%1$s" is not available any more', $code)); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | |
342 | - $provider = $manager->getProvider( $item, $code ); |
|
342 | + $provider = $manager->getProvider($item, $code); |
|
343 | 343 | |
344 | - if( $provider->isAvailable( $this->get() ) !== true ) { |
|
345 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Requirements for coupon code "%1$s" aren\'t met', $code ) ); |
|
344 | + if ($provider->isAvailable($this->get()) !== true) { |
|
345 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Requirements for coupon code "%1$s" aren\'t met', $code)); |
|
346 | 346 | } |
347 | 347 | |
348 | - $provider->addCoupon( $this->get() ); |
|
348 | + $provider->addCoupon($this->get()); |
|
349 | 349 | $this->save(); |
350 | 350 | } |
351 | 351 | |
@@ -356,21 +356,21 @@ discard block |
||
356 | 356 | * @param string $code Coupon code entered by the user |
357 | 357 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid |
358 | 358 | */ |
359 | - public function deleteCoupon( $code ) |
|
359 | + public function deleteCoupon($code) |
|
360 | 360 | { |
361 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' ); |
|
361 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon'); |
|
362 | 362 | |
363 | 363 | $search = $manager->createSearch(); |
364 | - $search->setConditions( $search->compare( '==', 'coupon.code.code', $code ) ); |
|
365 | - $search->setSlice( 0, 1 ); |
|
364 | + $search->setConditions($search->compare('==', 'coupon.code.code', $code)); |
|
365 | + $search->setSlice(0, 1); |
|
366 | 366 | |
367 | - $result = $manager->searchItems( $search ); |
|
367 | + $result = $manager->searchItems($search); |
|
368 | 368 | |
369 | - if( ( $item = reset( $result ) ) === false ) { |
|
370 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon code "%1$s" is invalid', $code ) ); |
|
369 | + if (($item = reset($result)) === false) { |
|
370 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon code "%1$s" is invalid', $code)); |
|
371 | 371 | } |
372 | 372 | |
373 | - $manager->getProvider( $item, $code )->deleteCoupon( $this->get() ); |
|
373 | + $manager->getProvider($item, $code)->deleteCoupon($this->get()); |
|
374 | 374 | $this->save(); |
375 | 375 | } |
376 | 376 | |
@@ -383,28 +383,28 @@ discard block |
||
383 | 383 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the billing or delivery address is not of any required type of |
384 | 384 | * if one of the keys is invalid when using an array with key/value pairs |
385 | 385 | */ |
386 | - public function setAddress( $type, $value ) |
|
386 | + public function setAddress($type, $value) |
|
387 | 387 | { |
388 | - $address = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/address' )->createItem(); |
|
389 | - $address->setType( $type ); |
|
388 | + $address = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/address')->createItem(); |
|
389 | + $address->setType($type); |
|
390 | 390 | |
391 | - if( $value instanceof \Aimeos\MShop\Common\Item\Address\Iface ) |
|
391 | + if ($value instanceof \Aimeos\MShop\Common\Item\Address\Iface) |
|
392 | 392 | { |
393 | - $address->copyFrom( $value ); |
|
394 | - $this->get()->setAddress( $address, $type ); |
|
393 | + $address->copyFrom($value); |
|
394 | + $this->get()->setAddress($address, $type); |
|
395 | 395 | } |
396 | - else if( is_array( $value ) ) |
|
396 | + else if (is_array($value)) |
|
397 | 397 | { |
398 | - $this->setAddressFromArray( $address, $value ); |
|
399 | - $this->get()->setAddress( $address, $type ); |
|
398 | + $this->setAddressFromArray($address, $value); |
|
399 | + $this->get()->setAddress($address, $type); |
|
400 | 400 | } |
401 | - else if( $value === null ) |
|
401 | + else if ($value === null) |
|
402 | 402 | { |
403 | - $this->get()->deleteAddress( $type ); |
|
403 | + $this->get()->deleteAddress($type); |
|
404 | 404 | } |
405 | 405 | else |
406 | 406 | { |
407 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Invalid value for address type "%1$s"', $type ) ); |
|
407 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Invalid value for address type "%1$s"', $type)); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | $this->save(); |
@@ -420,48 +420,48 @@ discard block |
||
420 | 420 | * entered by the customer when choosing one of the delivery or payment options |
421 | 421 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
422 | 422 | */ |
423 | - public function setService( $type, $id, array $attributes = [] ) |
|
423 | + public function setService($type, $id, array $attributes = []) |
|
424 | 424 | { |
425 | - if( $id === null ) |
|
425 | + if ($id === null) |
|
426 | 426 | { |
427 | - $this->get()->deleteService( $type ); |
|
427 | + $this->get()->deleteService($type); |
|
428 | 428 | $this->save(); |
429 | 429 | return; |
430 | 430 | } |
431 | 431 | |
432 | 432 | $context = $this->getContext(); |
433 | 433 | |
434 | - $serviceManager = \Aimeos\MShop\Factory::createManager( $context, 'service' ); |
|
435 | - $serviceItem = $serviceManager->getItem( $id, array( 'media', 'price', 'text' ) ); |
|
434 | + $serviceManager = \Aimeos\MShop\Factory::createManager($context, 'service'); |
|
435 | + $serviceItem = $serviceManager->getItem($id, array('media', 'price', 'text')); |
|
436 | 436 | |
437 | - $provider = $serviceManager->getProvider( $serviceItem ); |
|
438 | - $result = $provider->checkConfigFE( $attributes ); |
|
439 | - $unknown = array_diff_key( $attributes, $result ); |
|
437 | + $provider = $serviceManager->getProvider($serviceItem); |
|
438 | + $result = $provider->checkConfigFE($attributes); |
|
439 | + $unknown = array_diff_key($attributes, $result); |
|
440 | 440 | |
441 | - if( count( $unknown ) > 0 ) |
|
441 | + if (count($unknown) > 0) |
|
442 | 442 | { |
443 | - $msg = sprintf( 'Unknown attributes "%1$s"', implode( '","', array_keys( $unknown ) ) ); |
|
444 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
443 | + $msg = sprintf('Unknown attributes "%1$s"', implode('","', array_keys($unknown))); |
|
444 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
445 | 445 | } |
446 | 446 | |
447 | - foreach( $result as $key => $value ) |
|
447 | + foreach ($result as $key => $value) |
|
448 | 448 | { |
449 | - if( $value !== null ) { |
|
450 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $value ); |
|
449 | + if ($value !== null) { |
|
450 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($value); |
|
451 | 451 | } |
452 | 452 | } |
453 | 453 | |
454 | - $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/service' ); |
|
454 | + $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/service'); |
|
455 | 455 | $orderServiceItem = $orderBaseServiceManager->createItem(); |
456 | - $orderServiceItem->copyFrom( $serviceItem ); |
|
456 | + $orderServiceItem->copyFrom($serviceItem); |
|
457 | 457 | |
458 | 458 | // remove service rebate of original price |
459 | - $price = $provider->calcPrice( $this->get() )->setRebate( '0.00' ); |
|
460 | - $orderServiceItem->setPrice( $price ); |
|
459 | + $price = $provider->calcPrice($this->get())->setRebate('0.00'); |
|
460 | + $orderServiceItem->setPrice($price); |
|
461 | 461 | |
462 | - $provider->setConfigFE( $orderServiceItem, $attributes ); |
|
462 | + $provider->setConfigFE($orderServiceItem, $attributes); |
|
463 | 463 | |
464 | - $this->get()->setService( $orderServiceItem, $type ); |
|
464 | + $this->get()->setService($orderServiceItem, $type); |
|
465 | 465 | $this->save(); |
466 | 466 | } |
467 | 467 | |
@@ -474,18 +474,18 @@ discard block |
||
474 | 474 | * an address item. |
475 | 475 | * @throws \Aimeos\Controller\Frontend\Basket\Exception |
476 | 476 | */ |
477 | - protected function setAddressFromArray( \Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map ) |
|
477 | + protected function setAddressFromArray(\Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map) |
|
478 | 478 | { |
479 | - foreach( $map as $key => $value ) { |
|
480 | - $map[$key] = strip_tags( $value ); // prevent XSS |
|
479 | + foreach ($map as $key => $value) { |
|
480 | + $map[$key] = strip_tags($value); // prevent XSS |
|
481 | 481 | } |
482 | 482 | |
483 | - $errors = $address->fromArray( $map ); |
|
483 | + $errors = $address->fromArray($map); |
|
484 | 484 | |
485 | - if( count( $errors ) > 0 ) |
|
485 | + if (count($errors) > 0) |
|
486 | 486 | { |
487 | - $msg = sprintf( 'Invalid address properties, please check your input' ); |
|
488 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg, 0, null, $errors ); |
|
487 | + $msg = sprintf('Invalid address properties, please check your input'); |
|
488 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg, 0, null, $errors); |
|
489 | 489 | } |
490 | 490 | } |
491 | 491 | } |
@@ -18,183 +18,183 @@ |
||
18 | 18 | |
19 | 19 | protected function setUp() |
20 | 20 | { |
21 | - \Aimeos\MShop\Factory::setCache( true ); |
|
21 | + \Aimeos\MShop\Factory::setCache(true); |
|
22 | 22 | |
23 | 23 | $this->context = \TestHelperFrontend::getContext(); |
24 | - $this->object = new \Aimeos\Controller\Frontend\Order\Standard( $this->context ); |
|
24 | + $this->object = new \Aimeos\Controller\Frontend\Order\Standard($this->context); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | |
28 | 28 | protected function tearDown() |
29 | 29 | { |
30 | - unset( $this->object, $this->context ); |
|
30 | + unset($this->object, $this->context); |
|
31 | 31 | |
32 | - \Aimeos\MShop\Factory::setCache( false ); |
|
32 | + \Aimeos\MShop\Factory::setCache(false); |
|
33 | 33 | \Aimeos\MShop\Factory::clear(); |
34 | 34 | } |
35 | 35 | |
36 | 36 | |
37 | 37 | public function testAddItem() |
38 | 38 | { |
39 | - $manager = $this->getMockBuilder( '\\Aimeos\\MShop\\Order\\Manager\\Standard' ) |
|
40 | - ->setConstructorArgs( [$this->context] ) |
|
41 | - ->setMethods( ['saveItem'] ) |
|
39 | + $manager = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Standard') |
|
40 | + ->setConstructorArgs([$this->context]) |
|
41 | + ->setMethods(['saveItem']) |
|
42 | 42 | ->getMock(); |
43 | 43 | |
44 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'order', $manager ); |
|
44 | + \Aimeos\MShop\Factory::injectManager($this->context, 'order', $manager); |
|
45 | 45 | |
46 | - $manager->expects( $this->once() )->method( 'saveItem' ); |
|
46 | + $manager->expects($this->once())->method('saveItem'); |
|
47 | 47 | |
48 | - $this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Iface', $this->object->addItem( -1, 'test' ) ); |
|
48 | + $this->assertInstanceOf('\Aimeos\MShop\Order\Item\Iface', $this->object->addItem( -1, 'test' )); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
52 | 52 | public function testAddItemLimit() |
53 | 53 | { |
54 | - $this->context->getConfig()->set( 'controller/frontend/order/limit-seconds', 86400 * 365 ); |
|
54 | + $this->context->getConfig()->set('controller/frontend/order/limit-seconds', 86400 * 365); |
|
55 | 55 | |
56 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base' ); |
|
57 | - $result = $manager->searchItems( $manager->createSearch()->setSlice( 0, 1 ) ); |
|
56 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'order/base'); |
|
57 | + $result = $manager->searchItems($manager->createSearch()->setSlice(0, 1)); |
|
58 | 58 | |
59 | - if( ( $item = reset( $result ) ) === false ) { |
|
60 | - throw new \RuntimeException( 'No order item found' ); |
|
59 | + if (($item = reset($result)) === false) { |
|
60 | + throw new \RuntimeException('No order item found'); |
|
61 | 61 | } |
62 | 62 | |
63 | - $this->setExpectedException( '\Aimeos\Controller\Frontend\Order\Exception' ); |
|
64 | - $this->object->addItem( $item->getId(), 'test' ); |
|
63 | + $this->setExpectedException('\Aimeos\Controller\Frontend\Order\Exception'); |
|
64 | + $this->object->addItem($item->getId(), 'test'); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | |
68 | 68 | public function testCreateFilter() |
69 | 69 | { |
70 | - $this->assertInstanceOf( '\Aimeos\MW\Criteria\Iface', $this->object->createFilter() ); |
|
70 | + $this->assertInstanceOf('\Aimeos\MW\Criteria\Iface', $this->object->createFilter()); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | |
74 | 74 | public function testGetItem() |
75 | 75 | { |
76 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' ); |
|
77 | - $customerItem = $manager->findItem( 'UTC001' ); |
|
76 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer'); |
|
77 | + $customerItem = $manager->findItem('UTC001'); |
|
78 | 78 | |
79 | - $this->context->setEditor( 'core:unittest' ); |
|
79 | + $this->context->setEditor('core:unittest'); |
|
80 | 80 | |
81 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'order' ); |
|
82 | - $search = $manager->createSearch()->setSlice( 0, 1 ); |
|
83 | - $search->setConditions( $search->compare( '==', 'order.base.customerid', $customerItem->getId() ) ); |
|
84 | - $result = $manager->searchItems( $search ); |
|
81 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'order'); |
|
82 | + $search = $manager->createSearch()->setSlice(0, 1); |
|
83 | + $search->setConditions($search->compare('==', 'order.base.customerid', $customerItem->getId())); |
|
84 | + $result = $manager->searchItems($search); |
|
85 | 85 | |
86 | - if( ( $item = reset( $result ) ) === false ) { |
|
87 | - throw new \RuntimeException( 'No order item found' ); |
|
86 | + if (($item = reset($result)) === false) { |
|
87 | + throw new \RuntimeException('No order item found'); |
|
88 | 88 | } |
89 | 89 | |
90 | - $this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Iface', $this->object->getItem( $item->getId() ) ); |
|
90 | + $this->assertInstanceOf('\Aimeos\MShop\Order\Item\Iface', $this->object->getItem($item->getId())); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
94 | 94 | public function testGetItemException() |
95 | 95 | { |
96 | - $this->setExpectedException( '\Aimeos\Controller\Frontend\Order\Exception' ); |
|
96 | + $this->setExpectedException('\Aimeos\Controller\Frontend\Order\Exception'); |
|
97 | 97 | $this->object->getItem( -1 ); |
98 | 98 | } |
99 | 99 | |
100 | 100 | |
101 | 101 | public function testSearchItems() |
102 | 102 | { |
103 | - $this->assertGreaterThan( 1, $this->object->searchItems( $this->object->createFilter() ) ); |
|
103 | + $this->assertGreaterThan(1, $this->object->searchItems($this->object->createFilter())); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | |
107 | 107 | public function testStore() |
108 | 108 | { |
109 | 109 | $name = 'ControllerFrontendOrderStore'; |
110 | - $this->context->getConfig()->set( 'mshop/order/manager/name', $name ); |
|
110 | + $this->context->getConfig()->set('mshop/order/manager/name', $name); |
|
111 | 111 | |
112 | 112 | |
113 | - $orderManagerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Order\\Manager\\Standard' ) |
|
114 | - ->setMethods( array( 'saveItem', 'getSubManager' ) ) |
|
115 | - ->setConstructorArgs( array( $this->context ) ) |
|
113 | + $orderManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Standard') |
|
114 | + ->setMethods(array('saveItem', 'getSubManager')) |
|
115 | + ->setConstructorArgs(array($this->context)) |
|
116 | 116 | ->getMock(); |
117 | 117 | |
118 | - $orderBaseManagerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Order\\Manager\\Base\\Standard' ) |
|
119 | - ->setMethods( array( 'store' ) ) |
|
120 | - ->setConstructorArgs( array( $this->context ) ) |
|
118 | + $orderBaseManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Base\\Standard') |
|
119 | + ->setMethods(array('store')) |
|
120 | + ->setConstructorArgs(array($this->context)) |
|
121 | 121 | ->getMock(); |
122 | 122 | |
123 | - \Aimeos\MShop\Order\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Order\\Manager\\' . $name, $orderManagerStub ); |
|
123 | + \Aimeos\MShop\Order\Manager\Factory::injectManager('\\Aimeos\\MShop\\Order\\Manager\\' . $name, $orderManagerStub); |
|
124 | 124 | |
125 | 125 | |
126 | 126 | $orderBaseItem = $orderBaseManagerStub->createItem(); |
127 | - $orderBaseItem->setId( 1 ); |
|
127 | + $orderBaseItem->setId(1); |
|
128 | 128 | |
129 | 129 | |
130 | - $orderBaseManagerStub->expects( $this->once() )->method( 'store' ); |
|
130 | + $orderBaseManagerStub->expects($this->once())->method('store'); |
|
131 | 131 | |
132 | - $orderManagerStub->expects( $this->once() )->method( 'getSubManager' ) |
|
133 | - ->will( $this->returnValue( $orderBaseManagerStub ) ); |
|
132 | + $orderManagerStub->expects($this->once())->method('getSubManager') |
|
133 | + ->will($this->returnValue($orderBaseManagerStub)); |
|
134 | 134 | |
135 | - $orderManagerStub->expects( $this->once() )->method( 'saveItem' ); |
|
135 | + $orderManagerStub->expects($this->once())->method('saveItem'); |
|
136 | 136 | |
137 | 137 | |
138 | - $this->object->store( $orderBaseItem ); |
|
138 | + $this->object->store($orderBaseItem); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | |
142 | 142 | public function testBlock() |
143 | 143 | { |
144 | 144 | $name = 'ControllerFrontendOrderBlock'; |
145 | - $this->context->getConfig()->set( 'controller/common/order/name', $name ); |
|
145 | + $this->context->getConfig()->set('controller/common/order/name', $name); |
|
146 | 146 | |
147 | 147 | |
148 | - $orderCntlStub = $this->getMockBuilder( '\\Aimeos\\Controller\\Common\\Order\\Standard' ) |
|
149 | - ->setMethods( array( 'block' ) ) |
|
150 | - ->setConstructorArgs( array( $this->context ) ) |
|
148 | + $orderCntlStub = $this->getMockBuilder('\\Aimeos\\Controller\\Common\\Order\\Standard') |
|
149 | + ->setMethods(array('block')) |
|
150 | + ->setConstructorArgs(array($this->context)) |
|
151 | 151 | ->getMock(); |
152 | 152 | |
153 | - \Aimeos\Controller\Common\Order\Factory::injectController( '\\Aimeos\\Controller\\Common\\Order\\' . $name, $orderCntlStub ); |
|
153 | + \Aimeos\Controller\Common\Order\Factory::injectController('\\Aimeos\\Controller\\Common\\Order\\' . $name, $orderCntlStub); |
|
154 | 154 | |
155 | - $orderCntlStub->expects( $this->once() )->method( 'block' ); |
|
155 | + $orderCntlStub->expects($this->once())->method('block'); |
|
156 | 156 | |
157 | 157 | |
158 | - $this->object->block( \Aimeos\MShop\Factory::createManager( $this->context, 'order' )->createItem() ); |
|
158 | + $this->object->block(\Aimeos\MShop\Factory::createManager($this->context, 'order')->createItem()); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | |
162 | 162 | public function testUnblock() |
163 | 163 | { |
164 | 164 | $name = 'ControllerFrontendOrderUnblock'; |
165 | - $this->context->getConfig()->set( 'controller/common/order/name', $name ); |
|
165 | + $this->context->getConfig()->set('controller/common/order/name', $name); |
|
166 | 166 | |
167 | 167 | |
168 | - $orderCntlStub = $this->getMockBuilder( '\\Aimeos\\Controller\\Common\\Order\\Standard' ) |
|
169 | - ->setMethods( array( 'unblock' ) ) |
|
170 | - ->setConstructorArgs( array( $this->context ) ) |
|
168 | + $orderCntlStub = $this->getMockBuilder('\\Aimeos\\Controller\\Common\\Order\\Standard') |
|
169 | + ->setMethods(array('unblock')) |
|
170 | + ->setConstructorArgs(array($this->context)) |
|
171 | 171 | ->getMock(); |
172 | 172 | |
173 | - \Aimeos\Controller\Common\Order\Factory::injectController( '\\Aimeos\\Controller\\Common\\Order\\' . $name, $orderCntlStub ); |
|
173 | + \Aimeos\Controller\Common\Order\Factory::injectController('\\Aimeos\\Controller\\Common\\Order\\' . $name, $orderCntlStub); |
|
174 | 174 | |
175 | - $orderCntlStub->expects( $this->once() )->method( 'unblock' ); |
|
175 | + $orderCntlStub->expects($this->once())->method('unblock'); |
|
176 | 176 | |
177 | 177 | |
178 | - $this->object->unblock( \Aimeos\MShop\Factory::createManager( $this->context, 'order' )->createItem() ); |
|
178 | + $this->object->unblock(\Aimeos\MShop\Factory::createManager($this->context, 'order')->createItem()); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | |
182 | 182 | public function testUpdate() |
183 | 183 | { |
184 | 184 | $name = 'ControllerFrontendOrderUpdate'; |
185 | - $this->context->getConfig()->set( 'controller/common/order/name', $name ); |
|
185 | + $this->context->getConfig()->set('controller/common/order/name', $name); |
|
186 | 186 | |
187 | 187 | |
188 | - $orderCntlStub = $this->getMockBuilder( '\\Aimeos\\Controller\\Common\\Order\\Standard' ) |
|
189 | - ->setMethods( array( 'update' ) ) |
|
190 | - ->setConstructorArgs( array( $this->context ) ) |
|
188 | + $orderCntlStub = $this->getMockBuilder('\\Aimeos\\Controller\\Common\\Order\\Standard') |
|
189 | + ->setMethods(array('update')) |
|
190 | + ->setConstructorArgs(array($this->context)) |
|
191 | 191 | ->getMock(); |
192 | 192 | |
193 | - \Aimeos\Controller\Common\Order\Factory::injectController( '\\Aimeos\\Controller\\Common\\Order\\' . $name, $orderCntlStub ); |
|
193 | + \Aimeos\Controller\Common\Order\Factory::injectController('\\Aimeos\\Controller\\Common\\Order\\' . $name, $orderCntlStub); |
|
194 | 194 | |
195 | - $orderCntlStub->expects( $this->once() )->method( 'update' ); |
|
195 | + $orderCntlStub->expects($this->once())->method('update'); |
|
196 | 196 | |
197 | 197 | |
198 | - $this->object->update( \Aimeos\MShop\Factory::createManager( $this->context, 'order' )->createItem() ); |
|
198 | + $this->object->update(\Aimeos\MShop\Factory::createManager($this->context, 'order')->createItem()); |
|
199 | 199 | } |
200 | 200 | } |
@@ -29,11 +29,11 @@ discard block |
||
29 | 29 | * @param string $type Arbitrary order type (max. eight chars) |
30 | 30 | * @return \Aimeos\MShop\Order\Item\Iface Created order object |
31 | 31 | */ |
32 | - public function addItem( $baseId, $type ) |
|
32 | + public function addItem($baseId, $type) |
|
33 | 33 | { |
34 | 34 | $total = 0; |
35 | 35 | $context = $this->getContext(); |
36 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'order' ); |
|
36 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'order'); |
|
37 | 37 | |
38 | 38 | /** controller/frontend/order/limit-seconds |
39 | 39 | * Order limitation time frame in seconds |
@@ -51,24 +51,24 @@ discard block |
||
51 | 51 | * @see controller/frontend/basket/limit-count |
52 | 52 | * @see controller/frontend/basket/limit-seconds |
53 | 53 | */ |
54 | - $seconds = $context->getConfig()->get( 'controller/frontend/order/limit-seconds', 300 ); |
|
54 | + $seconds = $context->getConfig()->get('controller/frontend/order/limit-seconds', 300); |
|
55 | 55 | |
56 | 56 | $search = $manager->createSearch(); |
57 | 57 | $expr = [ |
58 | - $search->compare( '==', 'order.baseid', $baseId ), |
|
59 | - $search->compare( '>=', 'order.ctime', date( 'Y-m-d H:i:s', time() - $seconds ) ), |
|
58 | + $search->compare('==', 'order.baseid', $baseId), |
|
59 | + $search->compare('>=', 'order.ctime', date('Y-m-d H:i:s', time() - $seconds)), |
|
60 | 60 | ]; |
61 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
62 | - $search->setSlice( 0, 0 ); |
|
61 | + $search->setConditions($search->combine('&&', $expr)); |
|
62 | + $search->setSlice(0, 0); |
|
63 | 63 | |
64 | - $manager->searchItems( $search, [], $total ); |
|
64 | + $manager->searchItems($search, [], $total); |
|
65 | 65 | |
66 | - if( $total > 0 ) { |
|
67 | - throw new \Aimeos\Controller\Frontend\Order\Exception( sprintf( 'The order has already been created' ) ); |
|
66 | + if ($total > 0) { |
|
67 | + throw new \Aimeos\Controller\Frontend\Order\Exception(sprintf('The order has already been created')); |
|
68 | 68 | } |
69 | 69 | |
70 | - $item = $manager->createItem()->setBaseId( $baseId )->setType( $type ); |
|
71 | - $manager->saveItem( $item ); |
|
70 | + $item = $manager->createItem()->setBaseId($baseId)->setType($type); |
|
71 | + $manager->saveItem($item); |
|
72 | 72 | |
73 | 73 | return $item; |
74 | 74 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function createFilter() |
83 | 83 | { |
84 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order' )->createSearch( true ); |
|
84 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'order')->createSearch(true); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | |
@@ -92,30 +92,30 @@ discard block |
||
92 | 92 | * @param boolean $default Use default criteria to limit orders |
93 | 93 | * @return \Aimeos\MShop\Order\Item\Iface Order object |
94 | 94 | */ |
95 | - public function getItem( $id, $default = true ) |
|
95 | + public function getItem($id, $default = true) |
|
96 | 96 | { |
97 | 97 | $context = $this->getContext(); |
98 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'order' ); |
|
98 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'order'); |
|
99 | 99 | |
100 | - $search = $manager->createSearch( true ); |
|
100 | + $search = $manager->createSearch(true); |
|
101 | 101 | $expr = [ |
102 | - $search->compare( '==', 'order.id', $id ), |
|
102 | + $search->compare('==', 'order.id', $id), |
|
103 | 103 | $search->getConditions(), |
104 | 104 | ]; |
105 | 105 | |
106 | - if( $default !== false ) { |
|
107 | - $expr[] = $search->compare( '==', 'order.editor', $context->getEditor() ); |
|
106 | + if ($default !== false) { |
|
107 | + $expr[] = $search->compare('==', 'order.editor', $context->getEditor()); |
|
108 | 108 | } |
109 | 109 | |
110 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
110 | + $search->setConditions($search->combine('&&', $expr)); |
|
111 | 111 | |
112 | - $items = $manager->searchItems( $search ); |
|
112 | + $items = $manager->searchItems($search); |
|
113 | 113 | |
114 | - if( ( $item = reset( $items ) ) !== false ) { |
|
114 | + if (($item = reset($items)) !== false) { |
|
115 | 115 | return $item; |
116 | 116 | } |
117 | 117 | |
118 | - throw new \Aimeos\Controller\Frontend\Order\Exception( sprintf( 'No order item for ID "%1$s" found', $id ) ); |
|
118 | + throw new \Aimeos\Controller\Frontend\Order\Exception(sprintf('No order item for ID "%1$s" found', $id)); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | |
@@ -126,18 +126,18 @@ discard block |
||
126 | 126 | * @param integer|null &$total Variable that will contain the total number of available items |
127 | 127 | * @return \Aimeos\MShop\Order\Item\Iface[] Associative list of IDs as keys and order objects as values |
128 | 128 | */ |
129 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, &$total = null ) |
|
129 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, &$total = null) |
|
130 | 130 | { |
131 | 131 | $context = $this->getContext(); |
132 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'order' ); |
|
132 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'order'); |
|
133 | 133 | |
134 | 134 | $expr = [ |
135 | 135 | $filter->getConditions(), |
136 | - $filter->compare( '==', 'order.base.customerid', $context->getUserId() ), |
|
136 | + $filter->compare('==', 'order.base.customerid', $context->getUserId()), |
|
137 | 137 | ]; |
138 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
138 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
139 | 139 | |
140 | - return $manager->searchItems( $filter, [], $total ); |
|
140 | + return $manager->searchItems($filter, [], $total); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
@@ -159,9 +159,9 @@ discard block |
||
159 | 159 | * |
160 | 160 | * @param \Aimeos\MShop\Order\Item\Iface $orderItem Order item object |
161 | 161 | */ |
162 | - public function block( \Aimeos\MShop\Order\Item\Iface $orderItem ) |
|
162 | + public function block(\Aimeos\MShop\Order\Item\Iface $orderItem) |
|
163 | 163 | { |
164 | - \Aimeos\Controller\Common\Order\Factory::createController( $this->getContext() )->block( $orderItem ); |
|
164 | + \Aimeos\Controller\Common\Order\Factory::createController($this->getContext())->block($orderItem); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -183,9 +183,9 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @param \Aimeos\MShop\Order\Item\Iface $orderItem Order item object |
185 | 185 | */ |
186 | - public function unblock( \Aimeos\MShop\Order\Item\Iface $orderItem ) |
|
186 | + public function unblock(\Aimeos\MShop\Order\Item\Iface $orderItem) |
|
187 | 187 | { |
188 | - \Aimeos\Controller\Common\Order\Factory::createController( $this->getContext() )->unblock( $orderItem ); |
|
188 | + \Aimeos\Controller\Common\Order\Factory::createController($this->getContext())->unblock($orderItem); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | |
@@ -203,9 +203,9 @@ discard block |
||
203 | 203 | * |
204 | 204 | * @param \Aimeos\MShop\Order\Item\Iface $orderItem Order item object |
205 | 205 | */ |
206 | - public function update( \Aimeos\MShop\Order\Item\Iface $orderItem ) |
|
206 | + public function update(\Aimeos\MShop\Order\Item\Iface $orderItem) |
|
207 | 207 | { |
208 | - \Aimeos\Controller\Common\Order\Factory::createController( $this->getContext() )->update( $orderItem ); |
|
208 | + \Aimeos\Controller\Common\Order\Factory::createController($this->getContext())->update($orderItem); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | |
@@ -220,22 +220,22 @@ discard block |
||
220 | 220 | * @return \Aimeos\MShop\Order\Item\Iface Order item that belongs to the stored basket |
221 | 221 | * @deprecated 2017.04 Use store() from basket controller instead |
222 | 222 | */ |
223 | - public function store( \Aimeos\MShop\Order\Item\Base\Iface $basket ) |
|
223 | + public function store(\Aimeos\MShop\Order\Item\Base\Iface $basket) |
|
224 | 224 | { |
225 | 225 | $context = $this->getContext(); |
226 | 226 | |
227 | - $orderManager = \Aimeos\MShop\Factory::createManager( $context, 'order' ); |
|
228 | - $orderBaseManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' ); |
|
227 | + $orderManager = \Aimeos\MShop\Factory::createManager($context, 'order'); |
|
228 | + $orderBaseManager = \Aimeos\MShop\Factory::createManager($context, 'order/base'); |
|
229 | 229 | |
230 | 230 | |
231 | 231 | $orderBaseManager->begin(); |
232 | - $orderBaseManager->store( $basket ); |
|
232 | + $orderBaseManager->store($basket); |
|
233 | 233 | $orderBaseManager->commit(); |
234 | 234 | |
235 | 235 | $orderItem = $orderManager->createItem(); |
236 | - $orderItem->setBaseId( $basket->getId() ); |
|
237 | - $orderItem->setType( \Aimeos\MShop\Order\Item\Base::TYPE_WEB ); |
|
238 | - $orderManager->saveItem( $orderItem ); |
|
236 | + $orderItem->setBaseId($basket->getId()); |
|
237 | + $orderItem->setType(\Aimeos\MShop\Order\Item\Base::TYPE_WEB); |
|
238 | + $orderManager->saveItem($orderItem); |
|
239 | 239 | |
240 | 240 | |
241 | 241 | return $orderItem; |