@@ -17,125 +17,125 @@ discard block |
||
17 | 17 | |
18 | 18 | protected function setUp() |
19 | 19 | { |
20 | - \Aimeos\MShop\Factory::setCache( true ); |
|
20 | + \Aimeos\MShop\Factory::setCache(true); |
|
21 | 21 | |
22 | 22 | $this->context = \TestHelperFrontend::getContext(); |
23 | - $this->object = new \Aimeos\Controller\Frontend\Service\Standard( $this->context ); |
|
23 | + $this->object = new \Aimeos\Controller\Frontend\Service\Standard($this->context); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | |
27 | 27 | public static function setUpBeforeClass() |
28 | 28 | { |
29 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
30 | - $orderBaseMgr = $orderManager->getSubManager( 'base' ); |
|
29 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
30 | + $orderBaseMgr = $orderManager->getSubManager('base'); |
|
31 | 31 | self::$basket = $orderBaseMgr->createItem(); |
32 | 32 | } |
33 | 33 | |
34 | 34 | |
35 | 35 | protected function tearDown() |
36 | 36 | { |
37 | - unset( $this->object, $this->context ); |
|
37 | + unset($this->object, $this->context); |
|
38 | 38 | |
39 | - \Aimeos\MShop\Factory::setCache( false ); |
|
39 | + \Aimeos\MShop\Factory::setCache(false); |
|
40 | 40 | \Aimeos\MShop\Factory::clear(); |
41 | 41 | } |
42 | 42 | |
43 | 43 | |
44 | 44 | public function testCheckAttributes() |
45 | 45 | { |
46 | - $attributes = $this->object->checkAttributes( $this->getServiceItem()->getId(), [] ); |
|
47 | - $this->assertEquals( [], $attributes ); |
|
46 | + $attributes = $this->object->checkAttributes($this->getServiceItem()->getId(), []); |
|
47 | + $this->assertEquals([], $attributes); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | |
51 | 51 | public function testGetProviders() |
52 | 52 | { |
53 | - $providers = $this->object->getProviders( 'delivery' ); |
|
54 | - $this->assertGreaterThan( 0, count( $providers ) ); |
|
53 | + $providers = $this->object->getProviders('delivery'); |
|
54 | + $this->assertGreaterThan(0, count($providers)); |
|
55 | 55 | |
56 | - foreach( $providers as $provider ) { |
|
57 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Service\\Provider\\Iface', $provider ); |
|
56 | + foreach ($providers as $provider) { |
|
57 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Service\\Provider\\Iface', $provider); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | 61 | |
62 | 62 | public function testGetProvider() |
63 | 63 | { |
64 | - $provider = $this->object->getProvider( $this->getServiceItem()->getId() ); |
|
65 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Service\\Provider\\Iface', $provider ); |
|
64 | + $provider = $this->object->getProvider($this->getServiceItem()->getId()); |
|
65 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Service\\Provider\\Iface', $provider); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | |
69 | 69 | public function testProcess() |
70 | 70 | { |
71 | 71 | $form = new \Aimeos\MShop\Common\Item\Helper\Form\Standard(); |
72 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'order' )->createItem(); |
|
73 | - $serviceId = \Aimeos\MShop\Factory::createManager( $this->context, 'service' )->findItem( 'unitcode' )->getId(); |
|
72 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'order')->createItem(); |
|
73 | + $serviceId = \Aimeos\MShop\Factory::createManager($this->context, 'service')->findItem('unitcode')->getId(); |
|
74 | 74 | |
75 | - $provider = $this->getMockBuilder( '\\Aimeos\\MShop\\Service\\Provider\\Delivery\\Standard' ) |
|
75 | + $provider = $this->getMockBuilder('\\Aimeos\\MShop\\Service\\Provider\\Delivery\\Standard') |
|
76 | 76 | ->disableOriginalConstructor() |
77 | - ->setMethods( ['process'] ) |
|
77 | + ->setMethods(['process']) |
|
78 | 78 | ->getMock(); |
79 | 79 | |
80 | - $manager = $this->getMockBuilder( '\\Aimeos\\MShop\\Service\\Manager\\Standard' ) |
|
81 | - ->setConstructorArgs( [$this->context] ) |
|
82 | - ->setMethods( ['getProvider'] ) |
|
80 | + $manager = $this->getMockBuilder('\\Aimeos\\MShop\\Service\\Manager\\Standard') |
|
81 | + ->setConstructorArgs([$this->context]) |
|
82 | + ->setMethods(['getProvider']) |
|
83 | 83 | ->getMock(); |
84 | 84 | |
85 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'service', $manager ); |
|
85 | + \Aimeos\MShop\Factory::injectManager($this->context, 'service', $manager); |
|
86 | 86 | |
87 | - $provider->expects( $this->once() )->method( 'process' )->will( $this->returnValue( $form ) ); |
|
88 | - $manager->expects( $this->once() )->method( 'getProvider' )->will( $this->returnValue( $provider ) ); |
|
87 | + $provider->expects($this->once())->method('process')->will($this->returnValue($form)); |
|
88 | + $manager->expects($this->once())->method('getProvider')->will($this->returnValue($provider)); |
|
89 | 89 | |
90 | 90 | |
91 | - $result = $this->object->process( $item, $serviceId, [], [] ); |
|
92 | - $this->assertInstanceOf( '\Aimeos\MShop\Common\Item\Helper\Form\Iface', $result ); |
|
91 | + $result = $this->object->process($item, $serviceId, [], []); |
|
92 | + $this->assertInstanceOf('\Aimeos\MShop\Common\Item\Helper\Form\Iface', $result); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
96 | 96 | public function testUpdateSync() |
97 | 97 | { |
98 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'order' )->createItem(); |
|
98 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'order')->createItem(); |
|
99 | 99 | |
100 | - $stream = $this->getMockBuilder( 'Psr\Http\Message\StreamInterface' )->getMock(); |
|
101 | - $request = $this->getMockBuilder( '\Psr\Http\Message\ServerRequestInterface' )->getMock(); |
|
102 | - $response = $this->getMockBuilder( '\Aimeos\MW\View\Helper\Response\Iface' ) |
|
100 | + $stream = $this->getMockBuilder('Psr\Http\Message\StreamInterface')->getMock(); |
|
101 | + $request = $this->getMockBuilder('\Psr\Http\Message\ServerRequestInterface')->getMock(); |
|
102 | + $response = $this->getMockBuilder('\Aimeos\MW\View\Helper\Response\Iface') |
|
103 | 103 | ->getMock(); |
104 | 104 | |
105 | - $provider = $this->getMockBuilder( '\\Aimeos\\MShop\\Service\\Provider\\Delivery\\Standard' ) |
|
106 | - ->setMethods( ['updateSync', 'query', 'isImplemented'] ) |
|
105 | + $provider = $this->getMockBuilder('\\Aimeos\\MShop\\Service\\Provider\\Delivery\\Standard') |
|
106 | + ->setMethods(['updateSync', 'query', 'isImplemented']) |
|
107 | 107 | ->disableOriginalConstructor() |
108 | 108 | ->getMock(); |
109 | 109 | |
110 | - $manager = $this->getMockBuilder( '\\Aimeos\\MShop\\Service\\Manager\\Standard' ) |
|
111 | - ->setConstructorArgs( array( $this->context ) ) |
|
112 | - ->setMethods( ['getProvider'] ) |
|
110 | + $manager = $this->getMockBuilder('\\Aimeos\\MShop\\Service\\Manager\\Standard') |
|
111 | + ->setConstructorArgs(array($this->context)) |
|
112 | + ->setMethods(['getProvider']) |
|
113 | 113 | ->getMock(); |
114 | 114 | |
115 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'service', $manager ); |
|
115 | + \Aimeos\MShop\Factory::injectManager($this->context, 'service', $manager); |
|
116 | 116 | |
117 | 117 | |
118 | - $request->expects( $this->once() )->method( 'getQueryParams' )->will( $this->returnValue( ['code' => 'unitcode'] ) ); |
|
119 | - $response->expects( $this->once() )->method( 'createStreamFromString' )->will( $this->returnValue( $stream ) ); |
|
120 | - $manager->expects( $this->once() )->method( 'getProvider' )->will( $this->returnValue( $provider ) ); |
|
121 | - $provider->expects( $this->once() )->method( 'updateSync' )->will( $this->returnValue( $item ) ); |
|
122 | - $provider->expects( $this->once() )->method( 'isImplemented' )->will( $this->returnValue( true ) ); |
|
123 | - $provider->expects( $this->once() )->method( 'query' ); |
|
118 | + $request->expects($this->once())->method('getQueryParams')->will($this->returnValue(['code' => 'unitcode'])); |
|
119 | + $response->expects($this->once())->method('createStreamFromString')->will($this->returnValue($stream)); |
|
120 | + $manager->expects($this->once())->method('getProvider')->will($this->returnValue($provider)); |
|
121 | + $provider->expects($this->once())->method('updateSync')->will($this->returnValue($item)); |
|
122 | + $provider->expects($this->once())->method('isImplemented')->will($this->returnValue(true)); |
|
123 | + $provider->expects($this->once())->method('query'); |
|
124 | 124 | |
125 | - $this->object->updateSync( $request, $response, [], 'paypalexpress', -1 ); |
|
125 | + $this->object->updateSync($request, $response, [], 'paypalexpress', -1); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | |
129 | 129 | public function testGetServices() |
130 | 130 | { |
131 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
132 | - $basket = $orderManager->getSubManager( 'base' )->createItem(); |
|
131 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
132 | + $basket = $orderManager->getSubManager('base')->createItem(); |
|
133 | 133 | |
134 | - $services = $this->object->getServices( 'delivery', $basket ); |
|
135 | - $this->assertGreaterThan( 0, count( $services ) ); |
|
134 | + $services = $this->object->getServices('delivery', $basket); |
|
135 | + $this->assertGreaterThan(0, count($services)); |
|
136 | 136 | |
137 | - foreach( $services as $service ) { |
|
138 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Service\\Item\\Iface', $service ); |
|
137 | + foreach ($services as $service) { |
|
138 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Service\\Item\\Iface', $service); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
@@ -143,83 +143,83 @@ discard block |
||
143 | 143 | public function testGetServiceAttributes() |
144 | 144 | { |
145 | 145 | $service = $this->getServiceItem(); |
146 | - $attributes = $this->object->getServiceAttributes( 'delivery', $service->getId(), self::$basket ); |
|
146 | + $attributes = $this->object->getServiceAttributes('delivery', $service->getId(), self::$basket); |
|
147 | 147 | |
148 | - $this->assertEquals( 0, count( $attributes ) ); |
|
148 | + $this->assertEquals(0, count($attributes)); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | |
152 | 152 | public function testGetServiceAttributesCache() |
153 | 153 | { |
154 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
155 | - $basket = $orderManager->getSubManager( 'base' )->createItem(); |
|
154 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
155 | + $basket = $orderManager->getSubManager('base')->createItem(); |
|
156 | 156 | |
157 | - $services = $this->object->getServices( 'delivery', $basket ); |
|
157 | + $services = $this->object->getServices('delivery', $basket); |
|
158 | 158 | |
159 | - if( ( $service = reset( $services ) ) === false ) { |
|
160 | - throw new \RuntimeException( 'No service item found' ); |
|
159 | + if (($service = reset($services)) === false) { |
|
160 | + throw new \RuntimeException('No service item found'); |
|
161 | 161 | } |
162 | 162 | |
163 | - $attributes = $this->object->getServiceAttributes( 'delivery', $service->getId(), self::$basket ); |
|
163 | + $attributes = $this->object->getServiceAttributes('delivery', $service->getId(), self::$basket); |
|
164 | 164 | |
165 | - $this->assertEquals( 0, count( $attributes ) ); |
|
165 | + $this->assertEquals(0, count($attributes)); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | |
169 | 169 | public function testGetServiceAttributesNoItems() |
170 | 170 | { |
171 | - $this->setExpectedException( '\\Aimeos\\MShop\\Exception' ); |
|
172 | - $this->object->getServiceAttributes( 'invalid', -1, self::$basket ); |
|
171 | + $this->setExpectedException('\\Aimeos\\MShop\\Exception'); |
|
172 | + $this->object->getServiceAttributes('invalid', -1, self::$basket); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | |
176 | 176 | public function testGetServicePrice() |
177 | 177 | { |
178 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
179 | - $basket = $orderManager->getSubManager( 'base' )->createItem(); |
|
178 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
179 | + $basket = $orderManager->getSubManager('base')->createItem(); |
|
180 | 180 | |
181 | 181 | $service = $this->getServiceItem(); |
182 | - $price = $this->object->getServicePrice( 'delivery', $service->getId(), $basket ); |
|
182 | + $price = $this->object->getServicePrice('delivery', $service->getId(), $basket); |
|
183 | 183 | |
184 | - $this->assertEquals( '12.95', $price->getValue() ); |
|
185 | - $this->assertEquals( '1.99', $price->getCosts() ); |
|
184 | + $this->assertEquals('12.95', $price->getValue()); |
|
185 | + $this->assertEquals('1.99', $price->getCosts()); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | |
189 | 189 | public function testGetServicePriceCache() |
190 | 190 | { |
191 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
192 | - $basket = $orderManager->getSubManager( 'base' )->createItem(); |
|
191 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
192 | + $basket = $orderManager->getSubManager('base')->createItem(); |
|
193 | 193 | |
194 | - $services = $this->object->getServices( 'delivery', $basket ); |
|
194 | + $services = $this->object->getServices('delivery', $basket); |
|
195 | 195 | |
196 | - if( ( $service = reset( $services ) ) === false ) { |
|
197 | - throw new \RuntimeException( 'No service item found' ); |
|
196 | + if (($service = reset($services)) === false) { |
|
197 | + throw new \RuntimeException('No service item found'); |
|
198 | 198 | } |
199 | 199 | |
200 | - $price = $this->object->getServicePrice( 'delivery', $service->getId(), $basket ); |
|
200 | + $price = $this->object->getServicePrice('delivery', $service->getId(), $basket); |
|
201 | 201 | |
202 | - $this->assertEquals( '12.95', $price->getValue() ); |
|
203 | - $this->assertEquals( '1.99', $price->getCosts() ); |
|
202 | + $this->assertEquals('12.95', $price->getValue()); |
|
203 | + $this->assertEquals('1.99', $price->getCosts()); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | |
207 | 207 | public function testGetServicePriceNoItems() |
208 | 208 | { |
209 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
210 | - $basket = $orderManager->getSubManager( 'base' )->createItem(); |
|
209 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
210 | + $basket = $orderManager->getSubManager('base')->createItem(); |
|
211 | 211 | |
212 | - $this->setExpectedException( '\\Aimeos\\MShop\\Exception' ); |
|
213 | - $this->object->getServicePrice( 'invalid', -1, $basket ); |
|
212 | + $this->setExpectedException('\\Aimeos\\MShop\\Exception'); |
|
213 | + $this->object->getServicePrice('invalid', -1, $basket); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | |
217 | 217 | public function testCheckServiceAttributes() |
218 | 218 | { |
219 | 219 | $service = $this->getServiceItem(); |
220 | - $attributes = $this->object->checkServiceAttributes( 'delivery', $service->getId(), [] ); |
|
220 | + $attributes = $this->object->checkServiceAttributes('delivery', $service->getId(), []); |
|
221 | 221 | |
222 | - $this->assertEquals( [], $attributes ); |
|
222 | + $this->assertEquals([], $attributes); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | */ |
229 | 229 | protected function getServiceItem() |
230 | 230 | { |
231 | - $manager = \Aimeos\MShop\Service\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
232 | - return $manager->findItem( 'unitcode' ); |
|
231 | + $manager = \Aimeos\MShop\Service\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
232 | + return $manager->findItem('unitcode'); |
|
233 | 233 | } |
234 | 234 | } |
@@ -20,161 +20,161 @@ |
||
20 | 20 | { |
21 | 21 | $this->context = \TestHelperFrontend::getContext(); |
22 | 22 | |
23 | - $this->stub = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Service\Standard' ) |
|
23 | + $this->stub = $this->getMockBuilder('\Aimeos\Controller\Frontend\Service\Standard') |
|
24 | 24 | ->disableOriginalConstructor() |
25 | 25 | ->getMock(); |
26 | 26 | |
27 | - $this->object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Service\Decorator\Base' ) |
|
28 | - ->setConstructorArgs( [$this->stub, $this->context] ) |
|
27 | + $this->object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Service\Decorator\Base') |
|
28 | + ->setConstructorArgs([$this->stub, $this->context]) |
|
29 | 29 | ->getMockForAbstractClass(); |
30 | 30 | } |
31 | 31 | |
32 | 32 | |
33 | 33 | protected function tearDown() |
34 | 34 | { |
35 | - unset( $this->context, $this->object, $this->stub ); |
|
35 | + unset($this->context, $this->object, $this->stub); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
39 | 39 | public function testConstructException() |
40 | 40 | { |
41 | - $stub = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Iface' )->getMock(); |
|
41 | + $stub = $this->getMockBuilder('\Aimeos\Controller\Frontend\Iface')->getMock(); |
|
42 | 42 | |
43 | - $this->setExpectedException( '\Aimeos\Controller\Frontend\Exception' ); |
|
43 | + $this->setExpectedException('\Aimeos\Controller\Frontend\Exception'); |
|
44 | 44 | |
45 | - $this->getMockBuilder( '\Aimeos\Controller\Frontend\Service\Decorator\Base' ) |
|
46 | - ->setConstructorArgs( [$stub, $this->context] ) |
|
45 | + $this->getMockBuilder('\Aimeos\Controller\Frontend\Service\Decorator\Base') |
|
46 | + ->setConstructorArgs([$stub, $this->context]) |
|
47 | 47 | ->getMockForAbstractClass(); |
48 | 48 | } |
49 | 49 | |
50 | 50 | |
51 | 51 | public function testCall() |
52 | 52 | { |
53 | - $stub = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Service\Standard' ) |
|
53 | + $stub = $this->getMockBuilder('\Aimeos\Controller\Frontend\Service\Standard') |
|
54 | 54 | ->disableOriginalConstructor() |
55 | - ->setMethods( ['invalid'] ) |
|
55 | + ->setMethods(['invalid']) |
|
56 | 56 | ->getMock(); |
57 | 57 | |
58 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Service\Decorator\Base' ) |
|
59 | - ->setConstructorArgs( [$stub, $this->context] ) |
|
58 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Service\Decorator\Base') |
|
59 | + ->setConstructorArgs([$stub, $this->context]) |
|
60 | 60 | ->getMockForAbstractClass(); |
61 | 61 | |
62 | - $stub->expects( $this->once() )->method( 'invalid' )->will( $this->returnValue( true ) ); |
|
62 | + $stub->expects($this->once())->method('invalid')->will($this->returnValue(true)); |
|
63 | 63 | |
64 | - $this->assertTrue( $object->invalid() ); |
|
64 | + $this->assertTrue($object->invalid()); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | |
68 | 68 | public function testCheckAttributes() |
69 | 69 | { |
70 | - $this->stub->expects( $this->once() )->method( 'checkAttributes' ) |
|
71 | - ->will( $this->returnValue( [] ) ); |
|
70 | + $this->stub->expects($this->once())->method('checkAttributes') |
|
71 | + ->will($this->returnValue([])); |
|
72 | 72 | |
73 | - $this->assertEquals( [], $this->object->checkAttributes( -1, [] ) ); |
|
73 | + $this->assertEquals([], $this->object->checkAttributes( -1, [] )); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | |
77 | 77 | public function testGetProvider() |
78 | 78 | { |
79 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
80 | - $provider = $manager->getProvider( $manager->findItem( 'unitcode', [], 'service', 'delivery' ) ); |
|
79 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
80 | + $provider = $manager->getProvider($manager->findItem('unitcode', [], 'service', 'delivery')); |
|
81 | 81 | |
82 | - $this->stub->expects( $this->once() )->method( 'getProvider' ) |
|
83 | - ->will( $this->returnValue( $provider ) ); |
|
82 | + $this->stub->expects($this->once())->method('getProvider') |
|
83 | + ->will($this->returnValue($provider)); |
|
84 | 84 | |
85 | - $this->assertSame( $provider, $this->object->getProvider( -1 ) ); |
|
85 | + $this->assertSame($provider, $this->object->getProvider( -1 )); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | |
89 | 89 | public function testGetProviders() |
90 | 90 | { |
91 | - $this->stub->expects( $this->once() )->method( 'getProviders' ) |
|
92 | - ->will( $this->returnValue( [] ) ); |
|
91 | + $this->stub->expects($this->once())->method('getProviders') |
|
92 | + ->will($this->returnValue([])); |
|
93 | 93 | |
94 | - $this->assertEquals( [], $this->object->getProviders( 'payment' ) ); |
|
94 | + $this->assertEquals([], $this->object->getProviders('payment')); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | |
98 | 98 | public function testProcess() |
99 | 99 | { |
100 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'order' )->createItem(); |
|
100 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'order')->createItem(); |
|
101 | 101 | |
102 | - $this->stub->expects( $this->once() )->method( 'process' ) |
|
103 | - ->will( $this->returnValue( new \Aimeos\MShop\Common\Item\Helper\Form\Standard() ) ); |
|
102 | + $this->stub->expects($this->once())->method('process') |
|
103 | + ->will($this->returnValue(new \Aimeos\MShop\Common\Item\Helper\Form\Standard())); |
|
104 | 104 | |
105 | - $this->assertInstanceOf( 'Aimeos\MShop\Common\Item\Helper\Form\Iface', $this->object->process( $item, -1, [], [] ) ); |
|
105 | + $this->assertInstanceOf('Aimeos\MShop\Common\Item\Helper\Form\Iface', $this->object->process($item, -1, [], [])); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
109 | 109 | public function testUpdateSync() |
110 | 110 | { |
111 | - $response = $this->getMockBuilder( '\Psr\Http\Message\ResponseInterface' )->getMock(); |
|
112 | - $request = $this->getMockBuilder( '\Psr\Http\Message\ServerRequestInterface' )->getMock(); |
|
113 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'order' )->createItem(); |
|
111 | + $response = $this->getMockBuilder('\Psr\Http\Message\ResponseInterface')->getMock(); |
|
112 | + $request = $this->getMockBuilder('\Psr\Http\Message\ServerRequestInterface')->getMock(); |
|
113 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'order')->createItem(); |
|
114 | 114 | |
115 | - $this->stub->expects( $this->once() )->method( 'updateSync' ) |
|
116 | - ->will( $this->returnValue( $item ) ); |
|
115 | + $this->stub->expects($this->once())->method('updateSync') |
|
116 | + ->will($this->returnValue($item)); |
|
117 | 117 | |
118 | - $this->assertInstanceOf( 'Aimeos\MShop\Order\Item\Iface', $this->object->updateSync( $request, $response, [], 'test', -1 ) ); |
|
118 | + $this->assertInstanceOf('Aimeos\MShop\Order\Item\Iface', $this->object->updateSync($request, $response, [], 'test', -1)); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | |
122 | 122 | public function testGetServices() |
123 | 123 | { |
124 | - $basket = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base' )->createItem(); |
|
124 | + $basket = \Aimeos\MShop\Factory::createManager($this->context, 'order/base')->createItem(); |
|
125 | 125 | |
126 | - $this->stub->expects( $this->once() )->method( 'getServices' ) |
|
127 | - ->will( $this->returnValue( [] ) ); |
|
126 | + $this->stub->expects($this->once())->method('getServices') |
|
127 | + ->will($this->returnValue([])); |
|
128 | 128 | |
129 | - $this->assertEquals( [], $this->object->getServices( 'payment', $basket ) ); |
|
129 | + $this->assertEquals([], $this->object->getServices('payment', $basket)); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | |
133 | 133 | public function testGetServiceAttributes() |
134 | 134 | { |
135 | - $basket = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base' )->createItem(); |
|
135 | + $basket = \Aimeos\MShop\Factory::createManager($this->context, 'order/base')->createItem(); |
|
136 | 136 | |
137 | - $this->stub->expects( $this->once() )->method( 'getServiceAttributes' ) |
|
138 | - ->will( $this->returnValue( [] ) ); |
|
137 | + $this->stub->expects($this->once())->method('getServiceAttributes') |
|
138 | + ->will($this->returnValue([])); |
|
139 | 139 | |
140 | - $this->assertEquals( [], $this->object->getServiceAttributes( 'payment', -1, $basket ) ); |
|
140 | + $this->assertEquals([], $this->object->getServiceAttributes('payment', -1, $basket)); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
144 | 144 | public function testGetServicePrice() |
145 | 145 | { |
146 | - $priceItem = \Aimeos\MShop\Factory::createManager( $this->context, 'price' )->createItem(); |
|
147 | - $basket = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base' )->createItem(); |
|
146 | + $priceItem = \Aimeos\MShop\Factory::createManager($this->context, 'price')->createItem(); |
|
147 | + $basket = \Aimeos\MShop\Factory::createManager($this->context, 'order/base')->createItem(); |
|
148 | 148 | |
149 | - $this->stub->expects( $this->once() )->method( 'getServicePrice' ) |
|
150 | - ->will( $this->returnValue( $priceItem ) ); |
|
149 | + $this->stub->expects($this->once())->method('getServicePrice') |
|
150 | + ->will($this->returnValue($priceItem)); |
|
151 | 151 | |
152 | - $this->assertInstanceOf( '\Aimeos\MShop\Price\Item\Iface', $this->object->getServicePrice( 'payment', -1, $basket ) ); |
|
152 | + $this->assertInstanceOf('\Aimeos\MShop\Price\Item\Iface', $this->object->getServicePrice('payment', -1, $basket)); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | |
156 | 156 | public function testCheckServiceAttributes() |
157 | 157 | { |
158 | - $this->stub->expects( $this->once() )->method( 'checkServiceAttributes' ) |
|
159 | - ->will( $this->returnValue( [] ) ); |
|
158 | + $this->stub->expects($this->once())->method('checkServiceAttributes') |
|
159 | + ->will($this->returnValue([])); |
|
160 | 160 | |
161 | - $this->assertEquals( [], $this->object->checkServiceAttributes( 'payment', -1, [] ) ); |
|
161 | + $this->assertEquals([], $this->object->checkServiceAttributes('payment', -1, [])); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | |
165 | 165 | public function testGetController() |
166 | 166 | { |
167 | - $result = $this->access( 'getController' )->invokeArgs( $this->object, [] ); |
|
167 | + $result = $this->access('getController')->invokeArgs($this->object, []); |
|
168 | 168 | |
169 | - $this->assertSame( $this->stub, $result ); |
|
169 | + $this->assertSame($this->stub, $result); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | |
173 | - protected function access( $name ) |
|
173 | + protected function access($name) |
|
174 | 174 | { |
175 | - $class = new \ReflectionClass( '\Aimeos\Controller\Frontend\Service\Decorator\Base' ); |
|
176 | - $method = $class->getMethod( $name ); |
|
177 | - $method->setAccessible( true ); |
|
175 | + $class = new \ReflectionClass('\Aimeos\Controller\Frontend\Service\Decorator\Base'); |
|
176 | + $method = $class->getMethod($name); |
|
177 | + $method->setAccessible(true); |
|
178 | 178 | |
179 | 179 | return $method; |
180 | 180 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param string[] $attributes List of attribute codes as keys and strings entered by the customer as value |
31 | 31 | * @return string[] List of attributes codes as keys and error messages as values for invalid or missing values |
32 | 32 | */ |
33 | - public function checkAttributes( $serviceId, array $attributes ); |
|
33 | + public function checkAttributes($serviceId, array $attributes); |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Returns the service item for the given ID |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param array $ref List of domains for which the items referenced by the services should be fetched too |
40 | 40 | * @return \Aimeos\MShop\Service\Provider\Iface Service provider object |
41 | 41 | */ |
42 | - public function getProvider( $serviceId, $ref = ['media', 'price', 'text'] ); |
|
42 | + public function getProvider($serviceId, $ref = ['media', 'price', 'text']); |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * Returns the service providers for the given type |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param array $ref List of domains for which the items referenced by the services should be fetched too |
49 | 49 | * @return \Aimeos\MShop\Service\Provider\Iface[] List of service IDs as keys and service provider objects as values |
50 | 50 | */ |
51 | - public function getProviders( $type = null, $ref = ['media', 'price', 'text'] ); |
|
51 | + public function getProviders($type = null, $ref = ['media', 'price', 'text']); |
|
52 | 52 | |
53 | 53 | /** |
54 | 54 | * Processes the service for the given order, e.g. payment and delivery services |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @return \Aimeos\MShop\Common\Item\Helper\Form\Iface|null Form object with URL, parameters, etc. |
62 | 62 | * or null if no form data is required |
63 | 63 | */ |
64 | - public function process( \Aimeos\MShop\Order\Item\Iface $orderItem, $serviceId, array $urls, array $params ); |
|
64 | + public function process(\Aimeos\MShop\Order\Item\Iface $orderItem, $serviceId, array $urls, array $params); |
|
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Updates the payment or delivery status for the given request |
@@ -74,5 +74,5 @@ discard block |
||
74 | 74 | * @param string $orderid Unique ID of the order whose payment status should be updated |
75 | 75 | * @return \Aimeos\MShop\Order\Item\Iface $orderItem Order item that has been updated |
76 | 76 | */ |
77 | - public function updateSync( ServerRequestInterface $request, ResponseInterface $response, array $urls, $code, $orderid ); |
|
77 | + public function updateSync(ServerRequestInterface $request, ResponseInterface $response, array $urls, $code, $orderid); |
|
78 | 78 | } |
@@ -41,14 +41,14 @@ discard block |
||
41 | 41 | * @param string $stocktype Unique code of the stock type to deliver the products from |
42 | 42 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
43 | 43 | */ |
44 | - public function addProduct( $prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [], |
|
44 | + public function addProduct($prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [], |
|
45 | 45 | array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [], |
46 | - $stocktype = 'default' ) |
|
46 | + $stocktype = 'default') |
|
47 | 47 | { |
48 | 48 | $context = $this->getContext(); |
49 | - $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
49 | + $productManager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
50 | 50 | |
51 | - if( $productManager->getItem( $prodid, [], true )->getType() !== 'bundle' ) |
|
51 | + if ($productManager->getItem($prodid, [], true)->getType() !== 'bundle') |
|
52 | 52 | { |
53 | 53 | return $this->getController()->addProduct( |
54 | 54 | $prodid, $quantity, $options, $variantAttributeIds, $configAttributeIds, |
@@ -57,29 +57,29 @@ discard block |
||
57 | 57 | } |
58 | 58 | |
59 | 59 | $attributeMap = [ |
60 | - 'custom' => array_keys( $customAttributeValues ), |
|
60 | + 'custom' => array_keys($customAttributeValues), |
|
61 | 61 | 'config' => $configAttributeIds, |
62 | 62 | 'hidden' => $hiddenAttributeIds, |
63 | 63 | ]; |
64 | - $this->checkListRef( $prodid, 'attribute', $attributeMap ); |
|
64 | + $this->checkListRef($prodid, 'attribute', $attributeMap); |
|
65 | 65 | |
66 | 66 | |
67 | - $productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ), true ); |
|
68 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
67 | + $productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text'), true); |
|
68 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
69 | 69 | |
70 | - $orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem(); |
|
71 | - $orderBaseProductItem->copyFrom( $productItem )->setQuantity( $quantity )->setStockType( $stocktype ); |
|
70 | + $orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem(); |
|
71 | + $orderBaseProductItem->copyFrom($productItem)->setQuantity($quantity)->setStockType($stocktype); |
|
72 | 72 | |
73 | - $this->addBundleProducts( $orderBaseProductItem, $productItem, $variantAttributeIds, $stocktype ); |
|
73 | + $this->addBundleProducts($orderBaseProductItem, $productItem, $variantAttributeIds, $stocktype); |
|
74 | 74 | |
75 | - $attr = $this->getOrderProductAttributes( 'custom', array_keys( $customAttributeValues ), $customAttributeValues ); |
|
76 | - $attr = array_merge( $attr, $this->getOrderProductAttributes( 'config', $configAttributeIds ) ); |
|
77 | - $attr = array_merge( $attr, $this->getOrderProductAttributes( 'hidden', $hiddenAttributeIds ) ); |
|
75 | + $attr = $this->getOrderProductAttributes('custom', array_keys($customAttributeValues), $customAttributeValues); |
|
76 | + $attr = array_merge($attr, $this->getOrderProductAttributes('config', $configAttributeIds)); |
|
77 | + $attr = array_merge($attr, $this->getOrderProductAttributes('hidden', $hiddenAttributeIds)); |
|
78 | 78 | |
79 | - $orderBaseProductItem->setAttributes( $attr ); |
|
80 | - $orderBaseProductItem->setPrice( $this->calcPrice( $orderBaseProductItem, $prices, $quantity ) ); |
|
79 | + $orderBaseProductItem->setAttributes($attr); |
|
80 | + $orderBaseProductItem->setPrice($this->calcPrice($orderBaseProductItem, $prices, $quantity)); |
|
81 | 81 | |
82 | - $this->getController()->get()->addProduct( $orderBaseProductItem ); |
|
82 | + $this->getController()->get()->addProduct($orderBaseProductItem); |
|
83 | 83 | $this->getController()->save(); |
84 | 84 | } |
85 | 85 | |
@@ -92,43 +92,43 @@ discard block |
||
92 | 92 | * @param array $variantAttributeIds List of product variant attribute IDs |
93 | 93 | * @param string $stocktype |
94 | 94 | */ |
95 | - protected function addBundleProducts( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
96 | - \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $stocktype ) |
|
95 | + protected function addBundleProducts(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
96 | + \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $stocktype) |
|
97 | 97 | { |
98 | 98 | $quantity = $orderBaseProductItem->getQuantity(); |
99 | 99 | $products = $subProductIds = $orderProducts = []; |
100 | - $orderProductManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product' ); |
|
100 | + $orderProductManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product'); |
|
101 | 101 | |
102 | - foreach( $productItem->getRefItems( 'product', null, 'default' ) as $item ) { |
|
102 | + foreach ($productItem->getRefItems('product', null, 'default') as $item) { |
|
103 | 103 | $subProductIds[] = $item->getId(); |
104 | 104 | } |
105 | 105 | |
106 | - if( count( $subProductIds ) > 0 ) |
|
106 | + if (count($subProductIds) > 0) |
|
107 | 107 | { |
108 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
108 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
109 | 109 | |
110 | - $search = $productManager->createSearch( true ); |
|
110 | + $search = $productManager->createSearch(true); |
|
111 | 111 | $expr = array( |
112 | - $search->compare( '==', 'product.id', $subProductIds ), |
|
112 | + $search->compare('==', 'product.id', $subProductIds), |
|
113 | 113 | $search->getConditions(), |
114 | 114 | ); |
115 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
115 | + $search->setConditions($search->combine('&&', $expr)); |
|
116 | 116 | |
117 | - $products = $productManager->searchItems( $search, array( 'attribute', 'media', 'price', 'text' ) ); |
|
117 | + $products = $productManager->searchItems($search, array('attribute', 'media', 'price', 'text')); |
|
118 | 118 | } |
119 | 119 | |
120 | - foreach( $products as $product ) |
|
120 | + foreach ($products as $product) |
|
121 | 121 | { |
122 | - $prices = $product->getRefItems( 'price', 'default', 'default' ); |
|
122 | + $prices = $product->getRefItems('price', 'default', 'default'); |
|
123 | 123 | |
124 | 124 | $orderProduct = $orderProductManager->createItem(); |
125 | - $orderProduct->copyFrom( $product ); |
|
126 | - $orderProduct->setStockType( $stocktype ); |
|
127 | - $orderProduct->setPrice( $this->calcPrice( $orderProduct, $prices, $quantity ) ); |
|
125 | + $orderProduct->copyFrom($product); |
|
126 | + $orderProduct->setStockType($stocktype); |
|
127 | + $orderProduct->setPrice($this->calcPrice($orderProduct, $prices, $quantity)); |
|
128 | 128 | |
129 | 129 | $orderProducts[] = $orderProduct; |
130 | 130 | } |
131 | 131 | |
132 | - $orderBaseProductItem->setProducts( $orderProducts ); |
|
132 | + $orderBaseProductItem->setProducts($orderProducts); |
|
133 | 133 | } |
134 | 134 | } |
@@ -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,301 +132,301 @@ discard block |
||
132 | 132 | public function testAddDeleteProduct() |
133 | 133 | { |
134 | 134 | $basket = $this->object->get(); |
135 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' ); |
|
135 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC'); |
|
136 | 136 | |
137 | - $this->object->addProduct( $item->getId(), 2, [], [], [], [], [], 'default' ); |
|
138 | - $item2 = $this->object->get()->getProduct( 0 ); |
|
139 | - $this->object->deleteProduct( 0 ); |
|
137 | + $this->object->addProduct($item->getId(), 2, [], [], [], [], [], 'default'); |
|
138 | + $item2 = $this->object->get()->getProduct(0); |
|
139 | + $this->object->deleteProduct(0); |
|
140 | 140 | |
141 | - $this->assertEquals( 0, count( $basket->getProducts() ) ); |
|
142 | - $this->assertEquals( 'CNC', $item2->getProductCode() ); |
|
141 | + $this->assertEquals(0, count($basket->getProducts())); |
|
142 | + $this->assertEquals('CNC', $item2->getProductCode()); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | |
146 | 146 | public function testAddProductCustomAttribute() |
147 | 147 | { |
148 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
148 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
149 | 149 | |
150 | 150 | $search = $attributeManager->createSearch(); |
151 | 151 | $expr = array( |
152 | - $search->compare( '==', 'attribute.code', 'custom' ), |
|
153 | - $search->compare( '==', 'attribute.type.code', 'date' ), |
|
152 | + $search->compare('==', 'attribute.code', 'custom'), |
|
153 | + $search->compare('==', 'attribute.type.code', 'date'), |
|
154 | 154 | ); |
155 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
155 | + $search->setConditions($search->combine('&&', $expr)); |
|
156 | 156 | |
157 | - $attributes = $attributeManager->searchItems( $search ); |
|
157 | + $attributes = $attributeManager->searchItems($search); |
|
158 | 158 | |
159 | - if( ( $attrItem = reset( $attributes ) ) === false ) { |
|
160 | - throw new \RuntimeException( 'Attribute not found' ); |
|
159 | + if (($attrItem = reset($attributes)) === false) { |
|
160 | + throw new \RuntimeException('Attribute not found'); |
|
161 | 161 | } |
162 | 162 | |
163 | - $attrValues = array( $attrItem->getId() => '2000-01-01' ); |
|
163 | + $attrValues = array($attrItem->getId() => '2000-01-01'); |
|
164 | 164 | |
165 | - $this->object->addProduct( self::$testItem->getId(), 1, [], [], [], [], $attrValues ); |
|
165 | + $this->object->addProduct(self::$testItem->getId(), 1, [], [], [], [], $attrValues); |
|
166 | 166 | $basket = $this->object->get(); |
167 | 167 | |
168 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
169 | - $this->assertEquals( '2000-01-01', $basket->getProduct( 0 )->getAttribute( 'date', 'custom' ) ); |
|
168 | + $this->assertEquals(1, count($basket->getProducts())); |
|
169 | + $this->assertEquals('2000-01-01', $basket->getProduct(0)->getAttribute('date', 'custom')); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | |
173 | 173 | public function testAddProductCustomPrice() |
174 | 174 | { |
175 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
175 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
176 | 176 | |
177 | 177 | $search = $attributeManager->createSearch(); |
178 | 178 | $expr = array( |
179 | - $search->compare( '==', 'attribute.code', 'custom' ), |
|
180 | - $search->compare( '==', 'attribute.type.code', 'price' ), |
|
179 | + $search->compare('==', 'attribute.code', 'custom'), |
|
180 | + $search->compare('==', 'attribute.type.code', 'price'), |
|
181 | 181 | ); |
182 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
182 | + $search->setConditions($search->combine('&&', $expr)); |
|
183 | 183 | |
184 | - $attributes = $attributeManager->searchItems( $search ); |
|
184 | + $attributes = $attributeManager->searchItems($search); |
|
185 | 185 | |
186 | - if( ( $attrItem = reset( $attributes ) ) === false ) { |
|
187 | - throw new \RuntimeException( 'Attribute not found' ); |
|
186 | + if (($attrItem = reset($attributes)) === false) { |
|
187 | + throw new \RuntimeException('Attribute not found'); |
|
188 | 188 | } |
189 | 189 | |
190 | - $attrValues = array( $attrItem->getId() => '0.01' ); |
|
190 | + $attrValues = array($attrItem->getId() => '0.01'); |
|
191 | 191 | |
192 | - $this->object->addProduct( self::$testItem->getId(), 1, [], [], [], [], $attrValues ); |
|
192 | + $this->object->addProduct(self::$testItem->getId(), 1, [], [], [], [], $attrValues); |
|
193 | 193 | $basket = $this->object->get(); |
194 | 194 | |
195 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
196 | - $this->assertEquals( '0.01', $basket->getProduct( 0 )->getPrice()->getValue() ); |
|
195 | + $this->assertEquals(1, count($basket->getProducts())); |
|
196 | + $this->assertEquals('0.01', $basket->getProduct(0)->getPrice()->getValue()); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | |
200 | 200 | public function testAddProductCustomPriceException() |
201 | 201 | { |
202 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
202 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
203 | 203 | |
204 | 204 | $search = $attributeManager->createSearch(); |
205 | 205 | $expr = array( |
206 | - $search->compare( '==', 'attribute.code', 'custom' ), |
|
207 | - $search->compare( '==', 'attribute.type.code', 'price' ), |
|
206 | + $search->compare('==', 'attribute.code', 'custom'), |
|
207 | + $search->compare('==', 'attribute.type.code', 'price'), |
|
208 | 208 | ); |
209 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
209 | + $search->setConditions($search->combine('&&', $expr)); |
|
210 | 210 | |
211 | - $attributes = $attributeManager->searchItems( $search ); |
|
211 | + $attributes = $attributeManager->searchItems($search); |
|
212 | 212 | |
213 | - if( ( $attrItem = reset( $attributes ) ) === false ) { |
|
214 | - throw new \RuntimeException( 'Attribute not found' ); |
|
213 | + if (($attrItem = reset($attributes)) === false) { |
|
214 | + throw new \RuntimeException('Attribute not found'); |
|
215 | 215 | } |
216 | 216 | |
217 | - $attrValues = array( $attrItem->getId() => ',' ); |
|
217 | + $attrValues = array($attrItem->getId() => ','); |
|
218 | 218 | |
219 | - $this->setExpectedException( '\Aimeos\Controller\Frontend\Basket\Exception' ); |
|
220 | - $this->object->addProduct( self::$testItem->getId(), 1, [], [], [], [], $attrValues ); |
|
219 | + $this->setExpectedException('\Aimeos\Controller\Frontend\Basket\Exception'); |
|
220 | + $this->object->addProduct(self::$testItem->getId(), 1, [], [], [], [], $attrValues); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | |
224 | 224 | public function testAddProductAttributeNotAssigned() |
225 | 225 | { |
226 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
226 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
227 | 227 | |
228 | 228 | $search = $attributeManager->createSearch(); |
229 | 229 | $expr = array( |
230 | - $search->compare( '==', 'attribute.code', '30' ), |
|
231 | - $search->compare( '==', 'attribute.type.code', 'width' ), |
|
230 | + $search->compare('==', 'attribute.code', '30'), |
|
231 | + $search->compare('==', 'attribute.type.code', 'width'), |
|
232 | 232 | ); |
233 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
233 | + $search->setConditions($search->combine('&&', $expr)); |
|
234 | 234 | |
235 | - $attribute = $attributeManager->searchItems( $search ); |
|
235 | + $attribute = $attributeManager->searchItems($search); |
|
236 | 236 | |
237 | - if( empty( $attribute ) ) { |
|
238 | - throw new \RuntimeException( 'Attribute not found' ); |
|
237 | + if (empty($attribute)) { |
|
238 | + throw new \RuntimeException('Attribute not found'); |
|
239 | 239 | } |
240 | 240 | |
241 | - $hiddenAttrIds = array_keys( $attribute ); |
|
242 | - $configAttrIds = array_keys( $attribute ); |
|
241 | + $hiddenAttrIds = array_keys($attribute); |
|
242 | + $configAttrIds = array_keys($attribute); |
|
243 | 243 | |
244 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
245 | - $this->object->addProduct( self::$testItem->getId(), 1, [], [], $configAttrIds, $hiddenAttrIds ); |
|
244 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
245 | + $this->object->addProduct(self::$testItem->getId(), 1, [], [], $configAttrIds, $hiddenAttrIds); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | |
249 | 249 | public function testAddProductNegativeQuantityException() |
250 | 250 | { |
251 | - $this->setExpectedException( '\\Aimeos\\MShop\\Order\\Exception' ); |
|
252 | - $this->object->addProduct( self::$testItem->getId(), -1 ); |
|
251 | + $this->setExpectedException('\\Aimeos\\MShop\\Order\\Exception'); |
|
252 | + $this->object->addProduct(self::$testItem->getId(), -1); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | |
256 | 256 | public function testAddProductNoPriceException() |
257 | 257 | { |
258 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'MNOP' ); |
|
258 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('MNOP'); |
|
259 | 259 | |
260 | - $this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' ); |
|
261 | - $this->object->addProduct( $item->getId(), 1 ); |
|
260 | + $this->setExpectedException('\\Aimeos\\MShop\\Price\\Exception'); |
|
261 | + $this->object->addProduct($item->getId(), 1); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | |
265 | 265 | public function testAddProductConfigAttributeException() |
266 | 266 | { |
267 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
268 | - $this->object->addProduct( self::$testItem->getId(), 1, [], [], array( -1 ) ); |
|
267 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
268 | + $this->object->addProduct(self::$testItem->getId(), 1, [], [], array( -1 )); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | |
272 | 272 | public function testAddProductLowQuantityPriceException() |
273 | 273 | { |
274 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'IJKL' ); |
|
274 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('IJKL'); |
|
275 | 275 | |
276 | - $this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' ); |
|
277 | - $this->object->addProduct( $item->getId(), 1 ); |
|
276 | + $this->setExpectedException('\\Aimeos\\MShop\\Price\\Exception'); |
|
277 | + $this->object->addProduct($item->getId(), 1); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | |
281 | 281 | public function testAddProductHigherQuantities() |
282 | 282 | { |
283 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'IJKL' ); |
|
283 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('IJKL'); |
|
284 | 284 | |
285 | - $this->object->addProduct( $item->getId(), 2, [], [], [], [], [], 'unit_type3' ); |
|
285 | + $this->object->addProduct($item->getId(), 2, [], [], [], [], [], 'unit_type3'); |
|
286 | 286 | |
287 | - $this->assertEquals( 2, $this->object->get()->getProduct( 0 )->getQuantity() ); |
|
288 | - $this->assertEquals( 'IJKL', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
287 | + $this->assertEquals(2, $this->object->get()->getProduct(0)->getQuantity()); |
|
288 | + $this->assertEquals('IJKL', $this->object->get()->getProduct(0)->getProductCode()); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | |
292 | 292 | public function testDeleteProductFlagError() |
293 | 293 | { |
294 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
294 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
295 | 295 | |
296 | - $item = $this->object->get()->getProduct( 0 ); |
|
297 | - $item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ); |
|
296 | + $item = $this->object->get()->getProduct(0); |
|
297 | + $item->setFlags(\Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE); |
|
298 | 298 | |
299 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
300 | - $this->object->deleteProduct( 0 ); |
|
299 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
300 | + $this->object->deleteProduct(0); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | |
304 | 304 | public function testEditProduct() |
305 | 305 | { |
306 | - $this->object->addProduct( self::$testItem->getId(), 1 ); |
|
306 | + $this->object->addProduct(self::$testItem->getId(), 1); |
|
307 | 307 | |
308 | - $item = $this->object->get()->getProduct( 0 ); |
|
309 | - $this->assertEquals( 1, $item->getQuantity() ); |
|
308 | + $item = $this->object->get()->getProduct(0); |
|
309 | + $this->assertEquals(1, $item->getQuantity()); |
|
310 | 310 | |
311 | - $this->object->editProduct( 0, 4 ); |
|
311 | + $this->object->editProduct(0, 4); |
|
312 | 312 | |
313 | - $item = $this->object->get()->getProduct( 0 ); |
|
314 | - $this->assertEquals( 4, $item->getQuantity() ); |
|
315 | - $this->assertEquals( 'U:TESTP', $item->getProductCode() ); |
|
313 | + $item = $this->object->get()->getProduct(0); |
|
314 | + $this->assertEquals(4, $item->getQuantity()); |
|
315 | + $this->assertEquals('U:TESTP', $item->getProductCode()); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | |
319 | 319 | public function testEditProductAttributes() |
320 | 320 | { |
321 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
321 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
322 | 322 | |
323 | 323 | $search = $attributeManager->createSearch(); |
324 | 324 | $conditions = array( |
325 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
326 | - $search->combine( '||', array( |
|
327 | - $search->combine( '&&', array( |
|
328 | - $search->compare( '==', 'attribute.code', 'xs' ), |
|
329 | - $search->compare( '==', 'attribute.type.code', 'size' ), |
|
330 | - ) ), |
|
331 | - $search->combine( '&&', array( |
|
332 | - $search->compare( '==', 'attribute.code', 'white' ), |
|
333 | - $search->compare( '==', 'attribute.type.code', 'color' ), |
|
334 | - ) ), |
|
335 | - ) ) |
|
325 | + $search->compare('==', 'attribute.domain', 'product'), |
|
326 | + $search->combine('||', array( |
|
327 | + $search->combine('&&', array( |
|
328 | + $search->compare('==', 'attribute.code', 'xs'), |
|
329 | + $search->compare('==', 'attribute.type.code', 'size'), |
|
330 | + )), |
|
331 | + $search->combine('&&', array( |
|
332 | + $search->compare('==', 'attribute.code', 'white'), |
|
333 | + $search->compare('==', 'attribute.type.code', 'color'), |
|
334 | + )), |
|
335 | + )) |
|
336 | 336 | ); |
337 | - $search->setConditions( $search->combine( '&&', $conditions ) ); |
|
338 | - $attributes = $attributeManager->searchItems( $search ); |
|
337 | + $search->setConditions($search->combine('&&', $conditions)); |
|
338 | + $attributes = $attributeManager->searchItems($search); |
|
339 | 339 | |
340 | - if( ( $attribute = reset( $attributes ) ) === false ) { |
|
341 | - throw new \RuntimeException( 'No attributes available' ); |
|
340 | + if (($attribute = reset($attributes)) === false) { |
|
341 | + throw new \RuntimeException('No attributes available'); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | |
345 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TESTP' ); |
|
345 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TESTP'); |
|
346 | 346 | |
347 | - $this->object->addProduct( $item->getId(), 1, [], [], array_keys( $attributes ) ); |
|
348 | - $this->object->editProduct( 0, 4 ); |
|
347 | + $this->object->addProduct($item->getId(), 1, [], [], array_keys($attributes)); |
|
348 | + $this->object->editProduct(0, 4); |
|
349 | 349 | |
350 | - $item = $this->object->get()->getProduct( 0 ); |
|
351 | - $this->assertEquals( 2, count( $item->getAttributes() ) ); |
|
352 | - $this->assertEquals( 4, $item->getQuantity() ); |
|
350 | + $item = $this->object->get()->getProduct(0); |
|
351 | + $this->assertEquals(2, count($item->getAttributes())); |
|
352 | + $this->assertEquals(4, $item->getQuantity()); |
|
353 | 353 | |
354 | 354 | |
355 | - $this->object->editProduct( 0, 3, [], array( $attribute->getType() ) ); |
|
355 | + $this->object->editProduct(0, 3, [], array($attribute->getType())); |
|
356 | 356 | |
357 | - $item = $this->object->get()->getProduct( 0 ); |
|
358 | - $this->assertEquals( 3, $item->getQuantity() ); |
|
359 | - $this->assertEquals( 1, count( $item->getAttributes() ) ); |
|
360 | - $this->assertEquals( 'U:TESTP', $item->getProductCode() ); |
|
357 | + $item = $this->object->get()->getProduct(0); |
|
358 | + $this->assertEquals(3, $item->getQuantity()); |
|
359 | + $this->assertEquals(1, count($item->getAttributes())); |
|
360 | + $this->assertEquals('U:TESTP', $item->getProductCode()); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | |
364 | 364 | public function testEditProductFlagError() |
365 | 365 | { |
366 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
366 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
367 | 367 | |
368 | - $item = $this->object->get()->getProduct( 0 ); |
|
369 | - $item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ); |
|
368 | + $item = $this->object->get()->getProduct(0); |
|
369 | + $item->setFlags(\Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE); |
|
370 | 370 | |
371 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
372 | - $this->object->editProduct( 0, 4 ); |
|
371 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
372 | + $this->object->editProduct(0, 4); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | |
376 | 376 | public function testAddCoupon() |
377 | 377 | { |
378 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
379 | - $this->object->addCoupon( 'GHIJ' ); |
|
378 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
379 | + $this->object->addCoupon('GHIJ'); |
|
380 | 380 | |
381 | 381 | $basket = $this->object->get(); |
382 | 382 | |
383 | - $this->assertEquals( 1, count( $basket->getCoupons() ) ); |
|
383 | + $this->assertEquals(1, count($basket->getCoupons())); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | |
387 | 387 | public function testAddCouponInvalidCode() |
388 | 388 | { |
389 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
390 | - $this->object->addCoupon( 'invalid' ); |
|
389 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
390 | + $this->object->addCoupon('invalid'); |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | |
394 | 394 | public function testAddCouponMissingRequirements() |
395 | 395 | { |
396 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
397 | - $this->object->addCoupon( 'OPQR' ); |
|
396 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
397 | + $this->object->addCoupon('OPQR'); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | |
401 | 401 | public function testDeleteCoupon() |
402 | 402 | { |
403 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
404 | - $this->object->addCoupon( '90AB' ); |
|
405 | - $this->object->deleteCoupon( '90AB' ); |
|
403 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
404 | + $this->object->addCoupon('90AB'); |
|
405 | + $this->object->deleteCoupon('90AB'); |
|
406 | 406 | |
407 | 407 | $basket = $this->object->get(); |
408 | 408 | |
409 | - $this->assertEquals( 0, count( $basket->getCoupons() ) ); |
|
409 | + $this->assertEquals(0, count($basket->getCoupons())); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | |
413 | 413 | public function testSetAddressDelete() |
414 | 414 | { |
415 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null ); |
|
415 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null); |
|
416 | 416 | |
417 | - $this->setExpectedException( '\Aimeos\MShop\Order\Exception' ); |
|
418 | - $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
417 | + $this->setExpectedException('\Aimeos\MShop\Order\Exception'); |
|
418 | + $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | |
422 | 422 | public function testSetBillingAddressByItem() |
423 | 423 | { |
424 | - $item = $this->getAddress( 'Example company' ); |
|
424 | + $item = $this->getAddress('Example company'); |
|
425 | 425 | |
426 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item ); |
|
426 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item); |
|
427 | 427 | |
428 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
429 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
428 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
429 | + $this->assertEquals('Example company', $address->getCompany()); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | |
@@ -454,37 +454,37 @@ discard block |
||
454 | 454 | 'order.base.address.flag' => 0, |
455 | 455 | ); |
456 | 456 | |
457 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture ); |
|
457 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture); |
|
458 | 458 | |
459 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
460 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
461 | - $this->assertEquals( 'Dr.', $address->getTitle() ); |
|
462 | - $this->assertEquals( 'firstunit', $address->getFirstname() ); |
|
459 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
460 | + $this->assertEquals('Example company', $address->getCompany()); |
|
461 | + $this->assertEquals('Dr.', $address->getTitle()); |
|
462 | + $this->assertEquals('firstunit', $address->getFirstname()); |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | |
466 | 466 | public function testSetBillingAddressByArrayError() |
467 | 467 | { |
468 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
469 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array( 'error' => false ) ); |
|
468 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
469 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array('error' => false)); |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | |
473 | 473 | public function testSetBillingAddressParameterError() |
474 | 474 | { |
475 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
476 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error' ); |
|
475 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
476 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error'); |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | |
480 | 480 | public function testSetDeliveryAddressByItem() |
481 | 481 | { |
482 | - $item = $this->getAddress( 'Example company' ); |
|
482 | + $item = $this->getAddress('Example company'); |
|
483 | 483 | |
484 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item ); |
|
484 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item); |
|
485 | 485 | |
486 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY ); |
|
487 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
486 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY); |
|
487 | + $this->assertEquals('Example company', $address->getCompany()); |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | |
@@ -511,119 +511,119 @@ discard block |
||
511 | 511 | 'order.base.address.website' => 'www.example.com', |
512 | 512 | 'order.base.address.flag' => 0, |
513 | 513 | ); |
514 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture ); |
|
514 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture); |
|
515 | 515 | |
516 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY ); |
|
517 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
518 | - $this->assertEquals( 'Dr.', $address->getTitle() ); |
|
519 | - $this->assertEquals( 'firstunit', $address->getFirstname() ); |
|
516 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY); |
|
517 | + $this->assertEquals('Example company', $address->getCompany()); |
|
518 | + $this->assertEquals('Dr.', $address->getTitle()); |
|
519 | + $this->assertEquals('firstunit', $address->getFirstname()); |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | |
523 | 523 | public function testSetDeliveryAddressByArrayError() |
524 | 524 | { |
525 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
526 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array( 'error' => false ) ); |
|
525 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
526 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array('error' => false)); |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | |
530 | 530 | public function testSetDeliveryAddressTypeError() |
531 | 531 | { |
532 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
533 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error' ); |
|
532 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
533 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error'); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | |
537 | 537 | public function testSetServicePayment() |
538 | 538 | { |
539 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
540 | - $service = $manager->findItem( 'unitpaymentcode', [], 'service', 'payment' ); |
|
539 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
540 | + $service = $manager->findItem('unitpaymentcode', [], 'service', 'payment'); |
|
541 | 541 | |
542 | - $this->object->setService( 'payment', $service->getId(), [] ); |
|
543 | - $this->assertEquals( 'unitpaymentcode', $this->object->get()->getService( 'payment' )->getCode() ); |
|
542 | + $this->object->setService('payment', $service->getId(), []); |
|
543 | + $this->assertEquals('unitpaymentcode', $this->object->get()->getService('payment')->getCode()); |
|
544 | 544 | |
545 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
546 | - $this->object->setService( 'payment', $service->getId(), array( 'prepay' => true ) ); |
|
545 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
546 | + $this->object->setService('payment', $service->getId(), array('prepay' => true)); |
|
547 | 547 | } |
548 | 548 | |
549 | 549 | |
550 | 550 | public function testSetDeliveryOption() |
551 | 551 | { |
552 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
553 | - $service = $manager->findItem( 'unitcode', [], 'service', 'delivery' ); |
|
552 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
553 | + $service = $manager->findItem('unitcode', [], 'service', 'delivery'); |
|
554 | 554 | |
555 | - $this->object->setService( 'delivery', $service->getId(), [] ); |
|
556 | - $this->assertEquals( 'unitcode', $this->object->get()->getService( 'delivery' )->getCode() ); |
|
555 | + $this->object->setService('delivery', $service->getId(), []); |
|
556 | + $this->assertEquals('unitcode', $this->object->get()->getService('delivery')->getCode()); |
|
557 | 557 | |
558 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
559 | - $this->object->setService( 'delivery', $service->getId(), array( 'fast shipping' => true, 'air shipping' => false ) ); |
|
558 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
559 | + $this->object->setService('delivery', $service->getId(), array('fast shipping' => true, 'air shipping' => false)); |
|
560 | 560 | } |
561 | 561 | |
562 | 562 | |
563 | 563 | public function testCheckLocale() |
564 | 564 | { |
565 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
566 | - $payment = $manager->findItem( 'unitpaymentcode', [], 'service', 'payment' ); |
|
567 | - $delivery = $manager->findItem( 'unitcode', [], 'service', 'delivery' ); |
|
565 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
566 | + $payment = $manager->findItem('unitpaymentcode', [], 'service', 'payment'); |
|
567 | + $delivery = $manager->findItem('unitcode', [], 'service', 'delivery'); |
|
568 | 568 | |
569 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
570 | - $this->object->addCoupon( 'OPQR' ); |
|
569 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
570 | + $this->object->addCoupon('OPQR'); |
|
571 | 571 | |
572 | - $this->object->setService( 'payment', $payment->getId() ); |
|
573 | - $this->object->setService( 'delivery', $delivery->getId() ); |
|
572 | + $this->object->setService('payment', $payment->getId()); |
|
573 | + $this->object->setService('delivery', $delivery->getId()); |
|
574 | 574 | |
575 | 575 | $basket = $this->object->get(); |
576 | 576 | $price = $basket->getPrice(); |
577 | 577 | |
578 | - foreach( $basket->getProducts() as $product ) |
|
578 | + foreach ($basket->getProducts() as $product) |
|
579 | 579 | { |
580 | - $this->assertEquals( 2, $product->getQuantity() ); |
|
581 | - $product->getPrice()->setCurrencyId( 'CHF' ); |
|
580 | + $this->assertEquals(2, $product->getQuantity()); |
|
581 | + $product->getPrice()->setCurrencyId('CHF'); |
|
582 | 582 | } |
583 | 583 | |
584 | - $basket->getService( 'delivery' )->getPrice()->setCurrencyId( 'CHF' ); |
|
585 | - $basket->getService( 'payment' )->getPrice()->setCurrencyId( 'CHF' ); |
|
586 | - $basket->getLocale()->setCurrencyId( 'CHF' ); |
|
587 | - $price->setCurrencyId( 'CHF' ); |
|
584 | + $basket->getService('delivery')->getPrice()->setCurrencyId('CHF'); |
|
585 | + $basket->getService('payment')->getPrice()->setCurrencyId('CHF'); |
|
586 | + $basket->getLocale()->setCurrencyId('CHF'); |
|
587 | + $price->setCurrencyId('CHF'); |
|
588 | 588 | |
589 | - $this->context->getLocale()->setCurrencyId( 'CHF' ); |
|
590 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress( 'Example company' ) ); |
|
589 | + $this->context->getLocale()->setCurrencyId('CHF'); |
|
590 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress('Example company')); |
|
591 | 591 | |
592 | - $this->context->getSession()->set( 'aimeos/basket/currency', 'CHF' ); |
|
593 | - $this->context->getLocale()->setCurrencyId( 'EUR' ); |
|
592 | + $this->context->getSession()->set('aimeos/basket/currency', 'CHF'); |
|
593 | + $this->context->getLocale()->setCurrencyId('EUR'); |
|
594 | 594 | |
595 | - $this->context->getSession()->set( 'aimeos/basket/content-unittest-en-EUR-', null ); |
|
595 | + $this->context->getSession()->set('aimeos/basket/content-unittest-en-EUR-', null); |
|
596 | 596 | |
597 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
597 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
598 | 598 | $basket = $object->get(); |
599 | 599 | |
600 | - foreach( $basket->getProducts() as $product ) |
|
600 | + foreach ($basket->getProducts() as $product) |
|
601 | 601 | { |
602 | - $this->assertEquals( 'EUR', $product->getPrice()->getCurrencyId() ); |
|
603 | - $this->assertEquals( 2, $product->getQuantity() ); |
|
602 | + $this->assertEquals('EUR', $product->getPrice()->getCurrencyId()); |
|
603 | + $this->assertEquals(2, $product->getQuantity()); |
|
604 | 604 | } |
605 | 605 | |
606 | - $this->assertEquals( 'EUR', $basket->getService( 'payment' )->getPrice()->getCurrencyId() ); |
|
607 | - $this->assertEquals( 'EUR', $basket->getService( 'delivery' )->getPrice()->getCurrencyId() ); |
|
608 | - $this->assertEquals( 'EUR', $basket->getLocale()->getCurrencyId() ); |
|
609 | - $this->assertEquals( 'EUR', $basket->getPrice()->getCurrencyId() ); |
|
606 | + $this->assertEquals('EUR', $basket->getService('payment')->getPrice()->getCurrencyId()); |
|
607 | + $this->assertEquals('EUR', $basket->getService('delivery')->getPrice()->getCurrencyId()); |
|
608 | + $this->assertEquals('EUR', $basket->getLocale()->getCurrencyId()); |
|
609 | + $this->assertEquals('EUR', $basket->getPrice()->getCurrencyId()); |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | |
613 | 613 | /** |
614 | 614 | * @param string $company |
615 | 615 | */ |
616 | - protected function getAddress( $company ) |
|
616 | + protected function getAddress($company) |
|
617 | 617 | { |
618 | - $customer = \Aimeos\MShop\Customer\Manager\Factory::createManager( \TestHelperFrontend::getContext(), 'Standard' ); |
|
619 | - $addressManager = $customer->getSubManager( 'address', 'Standard' ); |
|
618 | + $customer = \Aimeos\MShop\Customer\Manager\Factory::createManager(\TestHelperFrontend::getContext(), 'Standard'); |
|
619 | + $addressManager = $customer->getSubManager('address', 'Standard'); |
|
620 | 620 | |
621 | 621 | $search = $addressManager->createSearch(); |
622 | - $search->setConditions( $search->compare( '==', 'customer.address.company', $company ) ); |
|
623 | - $items = $addressManager->searchItems( $search ); |
|
622 | + $search->setConditions($search->compare('==', 'customer.address.company', $company)); |
|
623 | + $items = $addressManager->searchItems($search); |
|
624 | 624 | |
625 | - if( ( $item = reset( $items ) ) === false ) { |
|
626 | - throw new \RuntimeException( sprintf( 'No address item with company "%1$s" found', $company ) ); |
|
625 | + if (($item = reset($items)) === false) { |
|
626 | + throw new \RuntimeException(sprintf('No address item with company "%1$s" found', $company)); |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | return $item; |
@@ -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,17 +82,17 @@ 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' ); |
|
90 | - $item = $manager->getItem( $id, [], true ); |
|
89 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer'); |
|
90 | + $item = $manager->getItem($id, [], true); |
|
91 | 91 | |
92 | - unset( $values['customer.id'] ); |
|
93 | - $item->fromArray( $values ); |
|
92 | + unset($values['customer.id']); |
|
93 | + $item->fromArray($values); |
|
94 | 94 | |
95 | - $manager->saveItem( $item ); |
|
95 | + $manager->saveItem($item); |
|
96 | 96 | |
97 | 97 | return $item; |
98 | 98 | } |
@@ -106,17 +106,17 @@ discard block |
||
106 | 106 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item including the referenced domains items |
107 | 107 | * @since 2017.04 |
108 | 108 | */ |
109 | - public function getItem( $id = null, array $domains = [] ) |
|
109 | + public function getItem($id = null, array $domains = []) |
|
110 | 110 | { |
111 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' ); |
|
111 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer'); |
|
112 | 112 | |
113 | - if( $id == null ) { |
|
114 | - return $manager->getItem( $this->getContext()->getUserId(), $domains, true ); |
|
113 | + if ($id == null) { |
|
114 | + return $manager->getItem($this->getContext()->getUserId(), $domains, true); |
|
115 | 115 | } |
116 | 116 | |
117 | - $this->checkUser( $id ); |
|
117 | + $this->checkUser($id); |
|
118 | 118 | |
119 | - return $manager->getItem( $id, $domains, true ); |
|
119 | + return $manager->getItem($id, $domains, true); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item including the referenced domains items |
131 | 131 | * @since 2017.04 |
132 | 132 | */ |
133 | - public function findItem( $code, array $domains = [] ) |
|
133 | + public function findItem($code, array $domains = []) |
|
134 | 134 | { |
135 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' )->findItem( $code, $domains ); |
|
135 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer')->findItem($code, $domains); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @param \Aimeos\MShop\Customer\Item\Iface Customer item |
143 | 143 | */ |
144 | - public function saveItem( \Aimeos\MShop\Customer\Item\Iface $item ) |
|
144 | + public function saveItem(\Aimeos\MShop\Customer\Item\Iface $item) |
|
145 | 145 | { |
146 | - \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' )->saveItem( $item ); |
|
146 | + \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer')->saveItem($item); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | |
@@ -154,17 +154,17 @@ discard block |
||
154 | 154 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
155 | 155 | * @since 2017.04 |
156 | 156 | */ |
157 | - public function addAddressItem( array $values ) |
|
157 | + public function addAddressItem(array $values) |
|
158 | 158 | { |
159 | 159 | $context = $this->getContext(); |
160 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/address' ); |
|
160 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/address'); |
|
161 | 161 | |
162 | 162 | $item = $manager->createItem(); |
163 | - $item->fromArray( $values ); |
|
164 | - $item->setId( null ); |
|
165 | - $item->setParentId( $context->getUserId() ); |
|
163 | + $item->fromArray($values); |
|
164 | + $item->setId(null); |
|
165 | + $item->setParentId($context->getUserId()); |
|
166 | 166 | |
167 | - $manager->saveItem( $item ); |
|
167 | + $manager->saveItem($item); |
|
168 | 168 | |
169 | 169 | return $item; |
170 | 170 | } |
@@ -175,16 +175,16 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
177 | 177 | */ |
178 | - public function createAddressItem( array $values = [] ) |
|
178 | + public function createAddressItem(array $values = []) |
|
179 | 179 | { |
180 | 180 | $context = $this->getContext(); |
181 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/address' ); |
|
181 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/address'); |
|
182 | 182 | |
183 | 183 | $item = $manager->createItem(); |
184 | - $item->fromArray( $values ); |
|
185 | - $item->setId( null ); |
|
184 | + $item->fromArray($values); |
|
185 | + $item->setId(null); |
|
186 | 186 | |
187 | - $item->setParentId( $context->getUserId() ); |
|
187 | + $item->setParentId($context->getUserId()); |
|
188 | 188 | |
189 | 189 | return $item; |
190 | 190 | } |
@@ -196,13 +196,13 @@ discard block |
||
196 | 196 | * @param string $id Unique customer address ID |
197 | 197 | * @since 2017.04 |
198 | 198 | */ |
199 | - public function deleteAddressItem( $id ) |
|
199 | + public function deleteAddressItem($id) |
|
200 | 200 | { |
201 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/address' ); |
|
201 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/address'); |
|
202 | 202 | |
203 | - $this->checkUser( $manager->getItem( $id, [], true )->getParentId() ); |
|
203 | + $this->checkUser($manager->getItem($id, [], true)->getParentId()); |
|
204 | 204 | |
205 | - $manager->deleteItem( $id ); |
|
205 | + $manager->deleteItem($id); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | |
@@ -214,17 +214,17 @@ discard block |
||
214 | 214 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
215 | 215 | * @since 2017.04 |
216 | 216 | */ |
217 | - public function editAddressItem( $id, array $values ) |
|
217 | + public function editAddressItem($id, array $values) |
|
218 | 218 | { |
219 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/address' ); |
|
219 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/address'); |
|
220 | 220 | |
221 | - $item = $manager->getItem( $id, [], true ); |
|
222 | - $this->checkUser( $item->getParentId() ); |
|
221 | + $item = $manager->getItem($id, [], true); |
|
222 | + $this->checkUser($item->getParentId()); |
|
223 | 223 | |
224 | - unset( $values['customer.address.id'] ); |
|
225 | - $item->fromArray( $values ); |
|
224 | + unset($values['customer.address.id']); |
|
225 | + $item->fromArray($values); |
|
226 | 226 | |
227 | - $manager->saveItem( $item ); |
|
227 | + $manager->saveItem($item); |
|
228 | 228 | |
229 | 229 | return $item; |
230 | 230 | } |
@@ -237,12 +237,12 @@ discard block |
||
237 | 237 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
238 | 238 | * @since 2017.04 |
239 | 239 | */ |
240 | - public function getAddressItem( $id ) |
|
240 | + public function getAddressItem($id) |
|
241 | 241 | { |
242 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/address' ); |
|
242 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/address'); |
|
243 | 243 | |
244 | - $item = $manager->getItem( $id ); |
|
245 | - $this->checkUser( $item->getParentId() ); |
|
244 | + $item = $manager->getItem($id); |
|
245 | + $this->checkUser($item->getParentId()); |
|
246 | 246 | |
247 | 247 | return $item; |
248 | 248 | } |
@@ -253,9 +253,9 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @param \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
255 | 255 | */ |
256 | - public function saveAddressItem( \Aimeos\MShop\Customer\Item\Address\Iface $item ) |
|
256 | + public function saveAddressItem(\Aimeos\MShop\Customer\Item\Address\Iface $item) |
|
257 | 257 | { |
258 | - \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/address' )->saveItem( $item ); |
|
258 | + \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/address')->saveItem($item); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | |
@@ -266,32 +266,32 @@ discard block |
||
266 | 266 | * @return \Aimeos\MShop\Common\Item\Lists\Iface Customer lists item |
267 | 267 | * @since 2017.06 |
268 | 268 | */ |
269 | - public function addListItem( array $values ) |
|
269 | + public function addListItem(array $values) |
|
270 | 270 | { |
271 | 271 | $context = $this->getContext(); |
272 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists' ); |
|
272 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists'); |
|
273 | 273 | |
274 | - if( !isset( $values['customer.lists.typeid'] ) ) |
|
274 | + if (!isset($values['customer.lists.typeid'])) |
|
275 | 275 | { |
276 | - if( !isset( $values['customer.lists.type'] ) ) { |
|
277 | - throw new \Aimeos\Controller\Frontend\Customer\Exception( sprintf( 'No customer lists type code' ) ); |
|
276 | + if (!isset($values['customer.lists.type'])) { |
|
277 | + throw new \Aimeos\Controller\Frontend\Customer\Exception(sprintf('No customer lists type code')); |
|
278 | 278 | } |
279 | 279 | |
280 | - if( !isset( $values['customer.lists.domain'] ) ) { |
|
281 | - throw new \Aimeos\Controller\Frontend\Customer\Exception( sprintf( 'No customer lists domain' ) ); |
|
280 | + if (!isset($values['customer.lists.domain'])) { |
|
281 | + throw new \Aimeos\Controller\Frontend\Customer\Exception(sprintf('No customer lists domain')); |
|
282 | 282 | } |
283 | 283 | |
284 | - $typeManager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists/type' ); |
|
285 | - $typeItem = $typeManager->findItem( $values['customer.lists.type'], [], $values['customer.lists.domain'] ); |
|
284 | + $typeManager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists/type'); |
|
285 | + $typeItem = $typeManager->findItem($values['customer.lists.type'], [], $values['customer.lists.domain']); |
|
286 | 286 | $values['customer.lists.typeid'] = $typeItem->getId(); |
287 | 287 | } |
288 | 288 | |
289 | 289 | $item = $manager->createItem(); |
290 | - $item->fromArray( $values ); |
|
291 | - $item->setId( null ); |
|
292 | - $item->setParentId( $context->getUserId() ); |
|
290 | + $item->fromArray($values); |
|
291 | + $item->setId(null); |
|
292 | + $item->setParentId($context->getUserId()); |
|
293 | 293 | |
294 | - $manager->saveItem( $item ); |
|
294 | + $manager->saveItem($item); |
|
295 | 295 | |
296 | 296 | return $item; |
297 | 297 | } |
@@ -306,10 +306,10 @@ discard block |
||
306 | 306 | public function createListsFilter() |
307 | 307 | { |
308 | 308 | $context = $this->getContext(); |
309 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists' ); |
|
309 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists'); |
|
310 | 310 | |
311 | 311 | $filter = $manager->createSearch(); |
312 | - $filter->setConditions( $filter->compare( '==', 'customer.lists.parentid', $context->getUserId() ) ); |
|
312 | + $filter->setConditions($filter->compare('==', 'customer.lists.parentid', $context->getUserId())); |
|
313 | 313 | |
314 | 314 | return $filter; |
315 | 315 | } |
@@ -321,13 +321,13 @@ discard block |
||
321 | 321 | * @param string $id Unique customer address ID |
322 | 322 | * @since 2017.06 |
323 | 323 | */ |
324 | - public function deleteListItem( $id ) |
|
324 | + public function deleteListItem($id) |
|
325 | 325 | { |
326 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/lists' ); |
|
326 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/lists'); |
|
327 | 327 | |
328 | - $this->checkUser( $manager->getItem( $id )->getParentId() ); |
|
328 | + $this->checkUser($manager->getItem($id)->getParentId()); |
|
329 | 329 | |
330 | - $manager->deleteItem( $id ); |
|
330 | + $manager->deleteItem($id); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | |
@@ -339,33 +339,33 @@ discard block |
||
339 | 339 | * @return \Aimeos\MShop\Common\Item\Lists\Iface Customer lists item |
340 | 340 | * @since 2017.06 |
341 | 341 | */ |
342 | - public function editListItem( $id, array $values ) |
|
342 | + public function editListItem($id, array $values) |
|
343 | 343 | { |
344 | 344 | $context = $this->getContext(); |
345 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists' ); |
|
345 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists'); |
|
346 | 346 | |
347 | - $item = $manager->getItem( $id, [], true ); |
|
348 | - $this->checkUser( $item->getParentId() ); |
|
347 | + $item = $manager->getItem($id, [], true); |
|
348 | + $this->checkUser($item->getParentId()); |
|
349 | 349 | |
350 | - if( !isset( $values['customer.lists.typeid'] ) ) |
|
350 | + if (!isset($values['customer.lists.typeid'])) |
|
351 | 351 | { |
352 | - if( !isset( $values['customer.lists.type'] ) ) { |
|
353 | - throw new \Aimeos\Controller\Frontend\Customer\Exception( sprintf( 'No customer lists type code' ) ); |
|
352 | + if (!isset($values['customer.lists.type'])) { |
|
353 | + throw new \Aimeos\Controller\Frontend\Customer\Exception(sprintf('No customer lists type code')); |
|
354 | 354 | } |
355 | 355 | |
356 | - if( !isset( $values['customer.lists.domain'] ) ) { |
|
357 | - throw new \Aimeos\Controller\Frontend\Customer\Exception( sprintf( 'No customer lists domain' ) ); |
|
356 | + if (!isset($values['customer.lists.domain'])) { |
|
357 | + throw new \Aimeos\Controller\Frontend\Customer\Exception(sprintf('No customer lists domain')); |
|
358 | 358 | } |
359 | 359 | |
360 | - $typeManager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists/type' ); |
|
361 | - $typeItem = $typeManager->findItem( $values['customer.lists.type'], [], $values['customer.lists.domain'] ); |
|
360 | + $typeManager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists/type'); |
|
361 | + $typeItem = $typeManager->findItem($values['customer.lists.type'], [], $values['customer.lists.domain']); |
|
362 | 362 | $values['customer.lists.typeid'] = $typeItem->getId(); |
363 | 363 | } |
364 | 364 | |
365 | - unset( $values['customer.lists.id'] ); |
|
366 | - $item->fromArray( $values ); |
|
365 | + unset($values['customer.lists.id']); |
|
366 | + $item->fromArray($values); |
|
367 | 367 | |
368 | - $manager->saveItem( $item ); |
|
368 | + $manager->saveItem($item); |
|
369 | 369 | |
370 | 370 | return $item; |
371 | 371 | } |
@@ -378,12 +378,12 @@ discard block |
||
378 | 378 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
379 | 379 | * @since 2017.06 |
380 | 380 | */ |
381 | - public function getListItem( $id ) |
|
381 | + public function getListItem($id) |
|
382 | 382 | { |
383 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/lists' ); |
|
384 | - $item = $manager->getItem( $id ); |
|
383 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/lists'); |
|
384 | + $item = $manager->getItem($id); |
|
385 | 385 | |
386 | - $this->checkUser( $item->getParentId() ); |
|
386 | + $this->checkUser($item->getParentId()); |
|
387 | 387 | |
388 | 388 | return $item; |
389 | 389 | } |
@@ -397,11 +397,11 @@ discard block |
||
397 | 397 | * @return \Aimeos\MShop\Common\Item\Lists\Iface[] Customer list items |
398 | 398 | * @since 2017.06 |
399 | 399 | */ |
400 | - public function searchListItems( \Aimeos\MW\Criteria\Iface $filter, &$total = null ) |
|
400 | + public function searchListItems(\Aimeos\MW\Criteria\Iface $filter, &$total = null) |
|
401 | 401 | { |
402 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/lists' ); |
|
402 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/lists'); |
|
403 | 403 | |
404 | - return $manager->searchItems( $filter, [], $total ); |
|
404 | + return $manager->searchItems($filter, [], $total); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | |
@@ -411,12 +411,12 @@ discard block |
||
411 | 411 | * @param string $id Unique customer ID |
412 | 412 | * @throws \Aimeos\Controller\Frontend\Customer\Exception If access isn't allowed |
413 | 413 | */ |
414 | - protected function checkUser( $id ) |
|
414 | + protected function checkUser($id) |
|
415 | 415 | { |
416 | - if( $id != $this->getContext()->getUserId() ) |
|
416 | + if ($id != $this->getContext()->getUserId()) |
|
417 | 417 | { |
418 | - $msg = sprintf( 'Not allowed to access customer data for ID "%1$s"', $id ); |
|
419 | - throw new \Aimeos\Controller\Frontend\Customer\Exception( $msg ); |
|
418 | + $msg = sprintf('Not allowed to access customer data for ID "%1$s"', $id); |
|
419 | + throw new \Aimeos\Controller\Frontend\Customer\Exception($msg); |
|
420 | 420 | } |
421 | 421 | } |
422 | 422 | } |