@@ -29,12 +29,12 @@ discard block |
||
29 | 29 | * @param string $type Arbitrary order type (max. eight chars) |
30 | 30 | * @return \Aimeos\MShop\Order\Item\Iface Created order object |
31 | 31 | */ |
32 | - public function addItem( $baseId, $type ) |
|
32 | + public function addItem($baseId, $type) |
|
33 | 33 | { |
34 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order' ); |
|
34 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order'); |
|
35 | 35 | |
36 | - $item = $manager->createItem()->setBaseId( $baseId )->setType( $type ); |
|
37 | - $manager->saveItem( $item ); |
|
36 | + $item = $manager->createItem()->setBaseId($baseId)->setType($type); |
|
37 | + $manager->saveItem($item); |
|
38 | 38 | |
39 | 39 | return $item; |
40 | 40 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function createFilter() |
49 | 49 | { |
50 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order' )->createSearch( true ); |
|
50 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'order')->createSearch(true); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -57,26 +57,26 @@ discard block |
||
57 | 57 | * @param string $id Unique order ID |
58 | 58 | * @return \Aimeos\MShop\Order\Item\Iface Order object |
59 | 59 | */ |
60 | - public function getItem( $id ) |
|
60 | + public function getItem($id) |
|
61 | 61 | { |
62 | 62 | $context = $this->getContext(); |
63 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'order' ); |
|
63 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'order'); |
|
64 | 64 | |
65 | - $search = $manager->createSearch( true ); |
|
65 | + $search = $manager->createSearch(true); |
|
66 | 66 | $expr = [ |
67 | - $search->compare( '==', 'order.id', $id ), |
|
68 | - $search->compare( '==', 'order.base.customerid', $context->getUserId() ), |
|
67 | + $search->compare('==', 'order.id', $id), |
|
68 | + $search->compare('==', 'order.base.customerid', $context->getUserId()), |
|
69 | 69 | $search->getConditions(), |
70 | 70 | ]; |
71 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
71 | + $search->setConditions($search->combine('&&', $expr)); |
|
72 | 72 | |
73 | - $items = $manager->searchItems( $search ); |
|
73 | + $items = $manager->searchItems($search); |
|
74 | 74 | |
75 | - if( ( $item = reset( $items ) ) !== false ) { |
|
75 | + if (($item = reset($items)) !== false) { |
|
76 | 76 | return $item; |
77 | 77 | } |
78 | 78 | |
79 | - throw new \Aimeos\Controller\Frontend\Order\Exception( sprintf( 'No order item for ID "%1$s" found', $id ) ); |
|
79 | + throw new \Aimeos\Controller\Frontend\Order\Exception(sprintf('No order item for ID "%1$s" found', $id)); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -87,18 +87,18 @@ discard block |
||
87 | 87 | * @param integer|null &$total Variable that will contain the total number of available items |
88 | 88 | * @return \Aimeos\MShop\Order\Item\Iface[] Associative list of IDs as keys and order objects as values |
89 | 89 | */ |
90 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, &$total = null ) |
|
90 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, &$total = null) |
|
91 | 91 | { |
92 | 92 | $context = $this->getContext(); |
93 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'order' ); |
|
93 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'order'); |
|
94 | 94 | |
95 | 95 | $expr = [ |
96 | 96 | $filter->getConditions(), |
97 | - $filter->compare( '==', 'order.base.customerid', $context->getUserId() ), |
|
97 | + $filter->compare('==', 'order.base.customerid', $context->getUserId()), |
|
98 | 98 | ]; |
99 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
99 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
100 | 100 | |
101 | - return $manager->searchItems( $filter, [], $total ); |
|
101 | + return $manager->searchItems($filter, [], $total); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @param \Aimeos\MShop\Order\Item\Iface $orderItem Order item object |
122 | 122 | */ |
123 | - public function block( \Aimeos\MShop\Order\Item\Iface $orderItem ) |
|
123 | + public function block(\Aimeos\MShop\Order\Item\Iface $orderItem) |
|
124 | 124 | { |
125 | - \Aimeos\Controller\Common\Order\Factory::createController( $this->getContext() )->block( $orderItem ); |
|
125 | + \Aimeos\Controller\Common\Order\Factory::createController($this->getContext())->block($orderItem); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @param \Aimeos\MShop\Order\Item\Iface $orderItem Order item object |
146 | 146 | */ |
147 | - public function unblock( \Aimeos\MShop\Order\Item\Iface $orderItem ) |
|
147 | + public function unblock(\Aimeos\MShop\Order\Item\Iface $orderItem) |
|
148 | 148 | { |
149 | - \Aimeos\Controller\Common\Order\Factory::createController( $this->getContext() )->unblock( $orderItem ); |
|
149 | + \Aimeos\Controller\Common\Order\Factory::createController($this->getContext())->unblock($orderItem); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | |
@@ -164,9 +164,9 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @param \Aimeos\MShop\Order\Item\Iface $orderItem Order item object |
166 | 166 | */ |
167 | - public function update( \Aimeos\MShop\Order\Item\Iface $orderItem ) |
|
167 | + public function update(\Aimeos\MShop\Order\Item\Iface $orderItem) |
|
168 | 168 | { |
169 | - \Aimeos\Controller\Common\Order\Factory::createController( $this->getContext() )->update( $orderItem ); |
|
169 | + \Aimeos\Controller\Common\Order\Factory::createController($this->getContext())->update($orderItem); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | |
@@ -181,22 +181,22 @@ discard block |
||
181 | 181 | * @return \Aimeos\MShop\Order\Item\Iface Order item that belongs to the stored basket |
182 | 182 | * @deprecated 2017.04 Use store() from basket controller instead |
183 | 183 | */ |
184 | - public function store( \Aimeos\MShop\Order\Item\Base\Iface $basket ) |
|
184 | + public function store(\Aimeos\MShop\Order\Item\Base\Iface $basket) |
|
185 | 185 | { |
186 | 186 | $context = $this->getContext(); |
187 | 187 | |
188 | - $orderManager = \Aimeos\MShop\Factory::createManager( $context, 'order' ); |
|
189 | - $orderBaseManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' ); |
|
188 | + $orderManager = \Aimeos\MShop\Factory::createManager($context, 'order'); |
|
189 | + $orderBaseManager = \Aimeos\MShop\Factory::createManager($context, 'order/base'); |
|
190 | 190 | |
191 | 191 | |
192 | 192 | $orderBaseManager->begin(); |
193 | - $orderBaseManager->store( $basket ); |
|
193 | + $orderBaseManager->store($basket); |
|
194 | 194 | $orderBaseManager->commit(); |
195 | 195 | |
196 | 196 | $orderItem = $orderManager->createItem(); |
197 | - $orderItem->setBaseId( $basket->getId() ); |
|
198 | - $orderItem->setType( \Aimeos\MShop\Order\Item\Base::TYPE_WEB ); |
|
199 | - $orderManager->saveItem( $orderItem ); |
|
197 | + $orderItem->setBaseId($basket->getId()); |
|
198 | + $orderItem->setType(\Aimeos\MShop\Order\Item\Base::TYPE_WEB); |
|
199 | + $orderManager->saveItem($orderItem); |
|
200 | 200 | |
201 | 201 | |
202 | 202 | return $orderItem; |
@@ -18,175 +18,175 @@ |
||
18 | 18 | |
19 | 19 | protected function setUp() |
20 | 20 | { |
21 | - \Aimeos\MShop\Factory::setCache( true ); |
|
21 | + \Aimeos\MShop\Factory::setCache(true); |
|
22 | 22 | |
23 | 23 | $this->context = \TestHelperFrontend::getContext(); |
24 | - $this->object = new \Aimeos\Controller\Frontend\Order\Standard( $this->context ); |
|
24 | + $this->object = new \Aimeos\Controller\Frontend\Order\Standard($this->context); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | |
28 | 28 | protected function tearDown() |
29 | 29 | { |
30 | - unset( $this->object, $this->context ); |
|
30 | + unset($this->object, $this->context); |
|
31 | 31 | |
32 | - \Aimeos\MShop\Factory::setCache( false ); |
|
32 | + \Aimeos\MShop\Factory::setCache(false); |
|
33 | 33 | \Aimeos\MShop\Factory::clear(); |
34 | 34 | } |
35 | 35 | |
36 | 36 | |
37 | 37 | public function testAddItem() |
38 | 38 | { |
39 | - $manager = $this->getMockBuilder( '\\Aimeos\\MShop\\Order\\Manager\\Standard' ) |
|
40 | - ->setConstructorArgs( [$this->context] ) |
|
41 | - ->setMethods( ['saveItem'] ) |
|
39 | + $manager = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Standard') |
|
40 | + ->setConstructorArgs([$this->context]) |
|
41 | + ->setMethods(['saveItem']) |
|
42 | 42 | ->getMock(); |
43 | 43 | |
44 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'order', $manager ); |
|
44 | + \Aimeos\MShop\Factory::injectManager($this->context, 'order', $manager); |
|
45 | 45 | |
46 | - $manager->expects( $this->once() )->method( 'saveItem' ); |
|
46 | + $manager->expects($this->once())->method('saveItem'); |
|
47 | 47 | |
48 | - $this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Iface', $this->object->addItem( -1, 'test' ) ); |
|
48 | + $this->assertInstanceOf('\Aimeos\MShop\Order\Item\Iface', $this->object->addItem( -1, 'test' )); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
52 | 52 | public function testCreateFilter() |
53 | 53 | { |
54 | - $this->assertInstanceOf( '\Aimeos\MW\Criteria\Iface', $this->object->createFilter() ); |
|
54 | + $this->assertInstanceOf('\Aimeos\MW\Criteria\Iface', $this->object->createFilter()); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
58 | 58 | public function testGetItem() |
59 | 59 | { |
60 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' ); |
|
61 | - $customerItem = $manager->findItem( 'UTC001' ); |
|
60 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer'); |
|
61 | + $customerItem = $manager->findItem('UTC001'); |
|
62 | 62 | |
63 | - $this->context->setUserId( $customerItem->getId() ); |
|
63 | + $this->context->setUserId($customerItem->getId()); |
|
64 | 64 | |
65 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'order' ); |
|
66 | - $search = $manager->createSearch()->setSlice( 0, 1 ); |
|
67 | - $search->setConditions( $search->compare( '==', 'order.base.customerid', $customerItem->getId() ) ); |
|
68 | - $result = $manager->searchItems( $search ); |
|
65 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'order'); |
|
66 | + $search = $manager->createSearch()->setSlice(0, 1); |
|
67 | + $search->setConditions($search->compare('==', 'order.base.customerid', $customerItem->getId())); |
|
68 | + $result = $manager->searchItems($search); |
|
69 | 69 | |
70 | - if( ( $item = reset( $result ) ) === false ) { |
|
71 | - throw new \RuntimeException( 'No order item found' ); |
|
70 | + if (($item = reset($result)) === false) { |
|
71 | + throw new \RuntimeException('No order item found'); |
|
72 | 72 | } |
73 | 73 | |
74 | - $this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Iface', $this->object->getItem( $item->getId() ) ); |
|
74 | + $this->assertInstanceOf('\Aimeos\MShop\Order\Item\Iface', $this->object->getItem($item->getId())); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
78 | 78 | public function testGetItemException() |
79 | 79 | { |
80 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'order' ); |
|
81 | - $search = $manager->createSearch()->setSlice( 0, 1 ); |
|
82 | - $result = $manager->searchItems( $search ); |
|
80 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'order'); |
|
81 | + $search = $manager->createSearch()->setSlice(0, 1); |
|
82 | + $result = $manager->searchItems($search); |
|
83 | 83 | |
84 | - if( ( $item = reset( $result ) ) === false ) { |
|
85 | - throw new \RuntimeException( 'No order item found' ); |
|
84 | + if (($item = reset($result)) === false) { |
|
85 | + throw new \RuntimeException('No order item found'); |
|
86 | 86 | } |
87 | 87 | |
88 | - $this->setExpectedException( '\Aimeos\Controller\Frontend\Order\Exception' ); |
|
89 | - $this->object->getItem( $item->getId() ); |
|
88 | + $this->setExpectedException('\Aimeos\Controller\Frontend\Order\Exception'); |
|
89 | + $this->object->getItem($item->getId()); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | |
93 | 93 | public function testSearchItems() |
94 | 94 | { |
95 | - $this->assertGreaterThan( 1, $this->object->searchItems( $this->object->createFilter() ) ); |
|
95 | + $this->assertGreaterThan(1, $this->object->searchItems($this->object->createFilter())); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
99 | 99 | public function testStore() |
100 | 100 | { |
101 | 101 | $name = 'ControllerFrontendOrderStore'; |
102 | - $this->context->getConfig()->set( 'mshop/order/manager/name', $name ); |
|
102 | + $this->context->getConfig()->set('mshop/order/manager/name', $name); |
|
103 | 103 | |
104 | 104 | |
105 | - $orderManagerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Order\\Manager\\Standard' ) |
|
106 | - ->setMethods( array( 'saveItem', 'getSubManager' ) ) |
|
107 | - ->setConstructorArgs( array( $this->context ) ) |
|
105 | + $orderManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Standard') |
|
106 | + ->setMethods(array('saveItem', 'getSubManager')) |
|
107 | + ->setConstructorArgs(array($this->context)) |
|
108 | 108 | ->getMock(); |
109 | 109 | |
110 | - $orderBaseManagerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Order\\Manager\\Base\\Standard' ) |
|
111 | - ->setMethods( array( 'store' ) ) |
|
112 | - ->setConstructorArgs( array( $this->context ) ) |
|
110 | + $orderBaseManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Base\\Standard') |
|
111 | + ->setMethods(array('store')) |
|
112 | + ->setConstructorArgs(array($this->context)) |
|
113 | 113 | ->getMock(); |
114 | 114 | |
115 | - \Aimeos\MShop\Order\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Order\\Manager\\' . $name, $orderManagerStub ); |
|
115 | + \Aimeos\MShop\Order\Manager\Factory::injectManager('\\Aimeos\\MShop\\Order\\Manager\\' . $name, $orderManagerStub); |
|
116 | 116 | |
117 | 117 | |
118 | 118 | $orderBaseItem = $orderBaseManagerStub->createItem(); |
119 | - $orderBaseItem->setId( 1 ); |
|
119 | + $orderBaseItem->setId(1); |
|
120 | 120 | |
121 | 121 | |
122 | - $orderBaseManagerStub->expects( $this->once() )->method( 'store' ); |
|
122 | + $orderBaseManagerStub->expects($this->once())->method('store'); |
|
123 | 123 | |
124 | - $orderManagerStub->expects( $this->once() )->method( 'getSubManager' ) |
|
125 | - ->will( $this->returnValue( $orderBaseManagerStub ) ); |
|
124 | + $orderManagerStub->expects($this->once())->method('getSubManager') |
|
125 | + ->will($this->returnValue($orderBaseManagerStub)); |
|
126 | 126 | |
127 | - $orderManagerStub->expects( $this->once() )->method( 'saveItem' ); |
|
127 | + $orderManagerStub->expects($this->once())->method('saveItem'); |
|
128 | 128 | |
129 | 129 | |
130 | - $this->object->store( $orderBaseItem ); |
|
130 | + $this->object->store($orderBaseItem); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
134 | 134 | public function testBlock() |
135 | 135 | { |
136 | 136 | $name = 'ControllerFrontendOrderBlock'; |
137 | - $this->context->getConfig()->set( 'controller/common/order/name', $name ); |
|
137 | + $this->context->getConfig()->set('controller/common/order/name', $name); |
|
138 | 138 | |
139 | 139 | |
140 | - $orderCntlStub = $this->getMockBuilder( '\\Aimeos\\Controller\\Common\\Order\\Standard' ) |
|
141 | - ->setMethods( array( 'block' ) ) |
|
142 | - ->setConstructorArgs( array( $this->context ) ) |
|
140 | + $orderCntlStub = $this->getMockBuilder('\\Aimeos\\Controller\\Common\\Order\\Standard') |
|
141 | + ->setMethods(array('block')) |
|
142 | + ->setConstructorArgs(array($this->context)) |
|
143 | 143 | ->getMock(); |
144 | 144 | |
145 | - \Aimeos\Controller\Common\Order\Factory::injectController( '\\Aimeos\\Controller\\Common\\Order\\' . $name, $orderCntlStub ); |
|
145 | + \Aimeos\Controller\Common\Order\Factory::injectController('\\Aimeos\\Controller\\Common\\Order\\' . $name, $orderCntlStub); |
|
146 | 146 | |
147 | - $orderCntlStub->expects( $this->once() )->method( 'block' ); |
|
147 | + $orderCntlStub->expects($this->once())->method('block'); |
|
148 | 148 | |
149 | 149 | |
150 | - $this->object->block( \Aimeos\MShop\Factory::createManager( $this->context, 'order' )->createItem() ); |
|
150 | + $this->object->block(\Aimeos\MShop\Factory::createManager($this->context, 'order')->createItem()); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | |
154 | 154 | public function testUnblock() |
155 | 155 | { |
156 | 156 | $name = 'ControllerFrontendOrderUnblock'; |
157 | - $this->context->getConfig()->set( 'controller/common/order/name', $name ); |
|
157 | + $this->context->getConfig()->set('controller/common/order/name', $name); |
|
158 | 158 | |
159 | 159 | |
160 | - $orderCntlStub = $this->getMockBuilder( '\\Aimeos\\Controller\\Common\\Order\\Standard' ) |
|
161 | - ->setMethods( array( 'unblock' ) ) |
|
162 | - ->setConstructorArgs( array( $this->context ) ) |
|
160 | + $orderCntlStub = $this->getMockBuilder('\\Aimeos\\Controller\\Common\\Order\\Standard') |
|
161 | + ->setMethods(array('unblock')) |
|
162 | + ->setConstructorArgs(array($this->context)) |
|
163 | 163 | ->getMock(); |
164 | 164 | |
165 | - \Aimeos\Controller\Common\Order\Factory::injectController( '\\Aimeos\\Controller\\Common\\Order\\' . $name, $orderCntlStub ); |
|
165 | + \Aimeos\Controller\Common\Order\Factory::injectController('\\Aimeos\\Controller\\Common\\Order\\' . $name, $orderCntlStub); |
|
166 | 166 | |
167 | - $orderCntlStub->expects( $this->once() )->method( 'unblock' ); |
|
167 | + $orderCntlStub->expects($this->once())->method('unblock'); |
|
168 | 168 | |
169 | 169 | |
170 | - $this->object->unblock( \Aimeos\MShop\Factory::createManager( $this->context, 'order' )->createItem() ); |
|
170 | + $this->object->unblock(\Aimeos\MShop\Factory::createManager($this->context, 'order')->createItem()); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | |
174 | 174 | public function testUpdate() |
175 | 175 | { |
176 | 176 | $name = 'ControllerFrontendOrderUpdate'; |
177 | - $this->context->getConfig()->set( 'controller/common/order/name', $name ); |
|
177 | + $this->context->getConfig()->set('controller/common/order/name', $name); |
|
178 | 178 | |
179 | 179 | |
180 | - $orderCntlStub = $this->getMockBuilder( '\\Aimeos\\Controller\\Common\\Order\\Standard' ) |
|
181 | - ->setMethods( array( 'update' ) ) |
|
182 | - ->setConstructorArgs( array( $this->context ) ) |
|
180 | + $orderCntlStub = $this->getMockBuilder('\\Aimeos\\Controller\\Common\\Order\\Standard') |
|
181 | + ->setMethods(array('update')) |
|
182 | + ->setConstructorArgs(array($this->context)) |
|
183 | 183 | ->getMock(); |
184 | 184 | |
185 | - \Aimeos\Controller\Common\Order\Factory::injectController( '\\Aimeos\\Controller\\Common\\Order\\' . $name, $orderCntlStub ); |
|
185 | + \Aimeos\Controller\Common\Order\Factory::injectController('\\Aimeos\\Controller\\Common\\Order\\' . $name, $orderCntlStub); |
|
186 | 186 | |
187 | - $orderCntlStub->expects( $this->once() )->method( 'update' ); |
|
187 | + $orderCntlStub->expects($this->once())->method('update'); |
|
188 | 188 | |
189 | 189 | |
190 | - $this->object->update( \Aimeos\MShop\Factory::createManager( $this->context, 'order' )->createItem() ); |
|
190 | + $this->object->update(\Aimeos\MShop\Factory::createManager($this->context, 'order')->createItem()); |
|
191 | 191 | } |
192 | 192 | } |