Completed
Push — master ( b0e633...7bc86c )
by Aimeos
04:36
created
controller/jobs/src/Controller/Jobs/Subscription/Process/Renew/Standard.php 1 patch
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	public function getName()
30 30
 	{
31
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Subscription process renew' );
31
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Subscription process renew');
32 32
 	}
33 33
 
34 34
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function getDescription()
41 41
 	{
42
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Renews subscriptions at next date' );
42
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Renews subscriptions at next date');
43 43
 	}
44 44
 
45 45
 
@@ -54,62 +54,62 @@  discard block
 block discarded – undo
54 54
 		$config = $context->getConfig();
55 55
 		$logger = $context->getLogger();
56 56
 
57
-		$names = (array) $config->get( 'controller/common/subscription/process/processors', [] );
57
+		$names = (array) $config->get('controller/common/subscription/process/processors', []);
58 58
 
59
-		$date = date( 'Y-m-d' );
60
-		$processors = $this->getProcessors( $names );
61
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'subscription' );
59
+		$date = date('Y-m-d');
60
+		$processors = $this->getProcessors($names);
61
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'subscription');
62 62
 
63
-		$search = $manager->createSearch( true );
63
+		$search = $manager->createSearch(true);
64 64
 		$expr = [
65
-			$search->compare( '<', 'subscription.datenext', $date ),
66
-			$search->combine( '||', [
67
-				$search->compare( '==', 'subscription.dateend', null ),
68
-				$search->compare( '>', 'subscription.dateend', $date ),
69
-			] ),
65
+			$search->compare('<', 'subscription.datenext', $date),
66
+			$search->combine('||', [
67
+				$search->compare('==', 'subscription.dateend', null),
68
+				$search->compare('>', 'subscription.dateend', $date),
69
+			]),
70 70
 			$search->getConditions(),
71 71
 		];
72
-		$search->setConditions( $search->combine( '&&', $expr ) );
73
-		$search->setSortations( [$search->sort( '+', 'subscription.id' )] );
72
+		$search->setConditions($search->combine('&&', $expr));
73
+		$search->setSortations([$search->sort('+', 'subscription.id')]);
74 74
 
75 75
 		$start = 0;
76 76
 
77 77
 		do
78 78
 		{
79
-			$search->setSlice( $start, 100 );
80
-			$items = $manager->searchItems( $search );
79
+			$search->setSlice($start, 100);
80
+			$items = $manager->searchItems($search);
81 81
 
82
-			foreach( $items as $item )
82
+			foreach ($items as $item)
83 83
 			{
84 84
 				try
85 85
 				{
86
-					$context = $this->createContext( $item->getOrderBaseId() );
87
-					$newOrder = $this->createOrderBase( $context, $item );
88
-					$newInvoice = $this->createOrderInvoice( $context, $newOrder );
86
+					$context = $this->createContext($item->getOrderBaseId());
87
+					$newOrder = $this->createOrderBase($context, $item);
88
+					$newInvoice = $this->createOrderInvoice($context, $newOrder);
89 89
 
90
-					$this->createPayment( $context, $newOrder, $newInvoice );
90
+					$this->createPayment($context, $newOrder, $newInvoice);
91 91
 
92
-					foreach( $processors as $processor ) {
93
-						$processor->renew( $item, $newInvoice );
92
+					foreach ($processors as $processor) {
93
+						$processor->renew($item, $newInvoice);
94 94
 					}
95 95
 
96
-					$interval = new \DateInterval( $item->getInterval() );
97
-					$item->setDateNext( date_create( $item->getTimeCreated() )->add( $interval )->format( 'Y-m-d' ) );
96
+					$interval = new \DateInterval($item->getInterval());
97
+					$item->setDateNext(date_create($item->getTimeCreated())->add($interval)->format('Y-m-d'));
98 98
 
99
-					$manager->saveItem( $item );
99
+					$manager->saveItem($item);
100 100
 				}
101
-				catch( \Exception $e )
101
+				catch (\Exception $e)
102 102
 				{
103 103
 					$msg = 'Unable to process subscription with ID "%1$S": %2$s';
104
-					$logger->log( sprintf( $msg, $item->getId(), $e->getMessage() ) );
105
-					$logger->log( $e->getTraceAsString() );
104
+					$logger->log(sprintf($msg, $item->getId(), $e->getMessage()));
105
+					$logger->log($e->getTraceAsString());
106 106
 				}
107 107
 			}
108 108
 
109
-			$count = count( $items );
109
+			$count = count($items);
110 110
 			$start += $count;
111 111
 		}
112
-		while( $count === $search->getSliceSize() );
112
+		while ($count === $search->getSliceSize());
113 113
 	}
114 114
 
115 115
 
@@ -119,30 +119,30 @@  discard block
 block discarded – undo
119 119
 	 * @param string $baseId Unique order base ID
120 120
 	 * @return \Aimeos\MShop\Context\Item\Iface New context object
121 121
 	 */
122
-	protected function createContext( $baseId )
122
+	protected function createContext($baseId)
123 123
 	{
124 124
 		$context = clone $this->getContext();
125 125
 
126
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' );
127
-		$baseItem = $manager->getItem( $baseId );
126
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'order/base');
127
+		$baseItem = $manager->getItem($baseId);
128 128
 
129 129
 		$locale = $baseItem->getLocale();
130 130
 		$level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL;
131 131
 
132
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'locale' );
133
-		$locale = $manager->bootstrap( $baseItem->getSiteCode(), $locale->getLanguageId(), $locale->getCurrencyId(), false, $level );
132
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'locale');
133
+		$locale = $manager->bootstrap($baseItem->getSiteCode(), $locale->getLanguageId(), $locale->getCurrencyId(), false, $level);
134 134
 
135
-		$context->setLocale( $locale );
135
+		$context->setLocale($locale);
136 136
 
137 137
 		try
138 138
 		{
139
-			$manager = \Aimeos\MShop\Factory::createManager( $context, 'customer' );
140
-			$customerItem = $manager->getItem( $baseItem->getCustomerId(), ['customer/group'] );
139
+			$manager = \Aimeos\MShop\Factory::createManager($context, 'customer');
140
+			$customerItem = $manager->getItem($baseItem->getCustomerId(), ['customer/group']);
141 141
 
142
-			$context->setUserId( $baseItem->getCustomerId() );
143
-			$context->setGroupIds( $customerItem->getGroups() );
142
+			$context->setUserId($baseItem->getCustomerId());
143
+			$context->setGroupIds($customerItem->getGroups());
144 144
 		}
145
-		catch( \Exception $e ) {} // Subscription without account
145
+		catch (\Exception $e) {} // Subscription without account
146 146
 
147 147
 		return $context;
148 148
 	}
@@ -155,36 +155,36 @@  discard block
 block discarded – undo
155 155
 	 * @param \Aimeos\MShop\Subscription\Item\Iface $subscription Subscription item with order base ID and order product ID
156 156
 	 * @return \Aimeos\MShop\Order\Item\Base\Iface Complete order with product, addresses and services saved to the storage
157 157
 	 */
158
-	protected function createOrderBase( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Subscription\Item\Iface $subscription )
158
+	protected function createOrderBase(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Subscription\Item\Iface $subscription)
159 159
 	{
160
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' );
160
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'order/base');
161 161
 
162
-		$basket = $manager->load( $subscription->getOrderBaseId() );
162
+		$basket = $manager->load($subscription->getOrderBaseId());
163 163
 
164 164
 		$newBasket = $manager->createItem();
165
-		$newBasket->setCustomerId( $basket->getCustomerId() );
165
+		$newBasket->setCustomerId($basket->getCustomerId());
166 166
 
167
-		foreach( $basket->getProducts() as $orderProduct )
167
+		foreach ($basket->getProducts() as $orderProduct)
168 168
 		{
169
-			if( $orderProduct->getId() === $subscription->getOrderProductId() )
169
+			if ($orderProduct->getId() === $subscription->getOrderProductId())
170 170
 			{
171
-				$orderProduct->setId( null );
172
-				$newBasket->addProduct( $orderProduct );
171
+				$orderProduct->setId(null);
172
+				$newBasket->addProduct($orderProduct);
173 173
 			}
174 174
 		}
175 175
 
176
-		foreach( $basket->getAddresses() as $type => $orderAddress ) {
177
-			$newBasket->setAddress( $orderAddress, $type );
176
+		foreach ($basket->getAddresses() as $type => $orderAddress) {
177
+			$newBasket->setAddress($orderAddress, $type);
178 178
 		}
179 179
 
180
-		foreach( $basket->getServices() as $type => $orderServices )
180
+		foreach ($basket->getServices() as $type => $orderServices)
181 181
 		{
182
-			foreach( $orderServices as $orderService ) {
183
-				$newBasket->addService( $orderService, $type );
182
+			foreach ($orderServices as $orderService) {
183
+				$newBasket->addService($orderService, $type);
184 184
 			}
185 185
 		}
186 186
 
187
-		return $manager->store( $newBasket );
187
+		return $manager->store($newBasket);
188 188
 	}
189 189
 
190 190
 
@@ -195,15 +195,15 @@  discard block
 block discarded – undo
195 195
 	 * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Complete order with product, addresses and services saved to the storage
196 196
 	 * @return \Aimeos\MShop\Order\Item\Iface New invoice item associated to the order saved to the storage
197 197
 	 */
198
-	protected function createOrderInvoice( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket )
198
+	protected function createOrderInvoice(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket)
199 199
 	{
200
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'order' );
200
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'order');
201 201
 
202 202
 		$item = $manager->createItem();
203
-		$item->setBaseId( $basket->getId() );
204
-		$item->setType( 'subscription' );
203
+		$item->setBaseId($basket->getId());
204
+		$item->setType('subscription');
205 205
 
206
-		return $manager->saveItem( $item );
206
+		return $manager->saveItem($item);
207 207
 	}
208 208
 
209 209
 
@@ -214,17 +214,17 @@  discard block
 block discarded – undo
214 214
 	 * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Complete order with product, addresses and services
215 215
 	 * @param \Aimeos\MShop\Order\Item\Iface New invoice item associated to the order
216 216
 	 */
217
-	protected function createPayment( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket,
218
-		\Aimeos\MShop\Order\Item\Iface $invoice )
217
+	protected function createPayment(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket,
218
+		\Aimeos\MShop\Order\Item\Iface $invoice)
219 219
 	{
220
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'service' );
220
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'service');
221 221
 
222
-		foreach( $basket->getService( \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT ) as $service )
222
+		foreach ($basket->getService(\Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT) as $service)
223 223
 		{
224
-			$item = $manager->getItem( $service->getServiceId() );
225
-			$provider = $manager->getProvider( $item, 'payment' );
224
+			$item = $manager->getItem($service->getServiceId());
225
+			$provider = $manager->getProvider($item, 'payment');
226 226
 
227
-			$provider->repay( $invoice );
227
+			$provider->repay($invoice);
228 228
 		}
229 229
 	}
230 230
 }
Please login to merge, or discard this patch.
jobs/tests/Controller/Jobs/Subscription/Process/Renew/StandardTest.php 1 patch
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -21,62 +21,62 @@  discard block
 block discarded – undo
21 21
 		$this->aimeos = \TestHelperJobs::getAimeos();
22 22
 		$this->context = \TestHelperJobs::getContext();
23 23
 
24
-		$this->object = new \Aimeos\Controller\Jobs\Subscription\Process\Renew\Standard( $this->context, $this->aimeos );
24
+		$this->object = new \Aimeos\Controller\Jobs\Subscription\Process\Renew\Standard($this->context, $this->aimeos);
25 25
 
26
-		\Aimeos\MShop\Factory::setCache( true );
26
+		\Aimeos\MShop\Factory::setCache(true);
27 27
 	}
28 28
 
29 29
 
30 30
 	protected function tearDown()
31 31
 	{
32
-		\Aimeos\MShop\Factory::setCache( false );
32
+		\Aimeos\MShop\Factory::setCache(false);
33 33
 		\Aimeos\MShop\Factory::clear();
34 34
 
35
-		unset( $this->object, $this->context, $this->aimeos );
35
+		unset($this->object, $this->context, $this->aimeos);
36 36
 	}
37 37
 
38 38
 
39 39
 	public function testGetName()
40 40
 	{
41
-		$this->assertEquals( 'Subscription process renew', $this->object->getName() );
41
+		$this->assertEquals('Subscription process renew', $this->object->getName());
42 42
 	}
43 43
 
44 44
 
45 45
 	public function testGetDescription()
46 46
 	{
47
-		$this->assertEquals( 'Renews subscriptions at next date', $this->object->getDescription() );
47
+		$this->assertEquals('Renews subscriptions at next date', $this->object->getDescription());
48 48
 	}
49 49
 
50 50
 
51 51
 	public function testRun()
52 52
 	{
53
-		$this->context->getConfig()->set( 'controller/common/subscription/process/processors', ['cgroup'] );
53
+		$this->context->getConfig()->set('controller/common/subscription/process/processors', ['cgroup']);
54 54
 		$item = $this->getSubscription();
55 55
 
56
-		$object = $this->getMockBuilder( '\\Aimeos\\Controller\\Jobs\\Subscription\\Process\\Renew\\Standard' )
57
-			->setConstructorArgs( [$this->context, $this->aimeos] )
58
-			->setMethods( ['createOrderBase', 'createOrderInvoice', 'createPayment'] )
56
+		$object = $this->getMockBuilder('\\Aimeos\\Controller\\Jobs\\Subscription\\Process\\Renew\\Standard')
57
+			->setConstructorArgs([$this->context, $this->aimeos])
58
+			->setMethods(['createOrderBase', 'createOrderInvoice', 'createPayment'])
59 59
 			->getMock();
60 60
 
61
-		$managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Subscription\\Manager\\Standard' )
62
-			->setConstructorArgs( [$this->context] )
63
-			->setMethods( ['searchItems', 'saveItem'] )
61
+		$managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Subscription\\Manager\\Standard')
62
+			->setConstructorArgs([$this->context])
63
+			->setMethods(['searchItems', 'saveItem'])
64 64
 			->getMock();
65 65
 
66
-		\Aimeos\MShop\Factory::injectManager( $this->context, 'subscription', $managerStub );
66
+		\Aimeos\MShop\Factory::injectManager($this->context, 'subscription', $managerStub);
67 67
 
68
-		$object->expects( $this->once() )->method( 'createOrderBase' )
69
-			->will( $this->returnValue( $this->getOrderBaseItem( $item->getOrderBaseId() ) ) );
68
+		$object->expects($this->once())->method('createOrderBase')
69
+			->will($this->returnValue($this->getOrderBaseItem($item->getOrderBaseId())));
70 70
 
71
-		$object->expects( $this->once() )->method( 'createOrderInvoice' )
72
-			->will( $this->returnValue( $this->getOrderItem() ) );
71
+		$object->expects($this->once())->method('createOrderInvoice')
72
+			->will($this->returnValue($this->getOrderItem()));
73 73
 
74
-		$object->expects( $this->once() )->method( 'createPayment' );
74
+		$object->expects($this->once())->method('createPayment');
75 75
 
76
-		$managerStub->expects( $this->once() )->method( 'searchItems' )
77
-			->will( $this->returnValue( [$item] ) );
76
+		$managerStub->expects($this->once())->method('searchItems')
77
+			->will($this->returnValue([$item]));
78 78
 
79
-		$managerStub->expects( $this->once() )->method( 'saveItem' );
79
+		$managerStub->expects($this->once())->method('saveItem');
80 80
 
81 81
 		$object->run();
82 82
 	}
@@ -84,19 +84,19 @@  discard block
 block discarded – undo
84 84
 
85 85
 	public function testRunException()
86 86
 	{
87
-		$this->context->getConfig()->set( 'controller/common/subscription/process/processors', ['cgroup'] );
87
+		$this->context->getConfig()->set('controller/common/subscription/process/processors', ['cgroup']);
88 88
 
89
-		$managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Subscription\\Manager\\Standard' )
90
-			->setConstructorArgs( [$this->context] )
91
-			->setMethods( ['searchItems', 'saveItem'] )
89
+		$managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Subscription\\Manager\\Standard')
90
+			->setConstructorArgs([$this->context])
91
+			->setMethods(['searchItems', 'saveItem'])
92 92
 			->getMock();
93 93
 
94
-		\Aimeos\MShop\Factory::injectManager( $this->context, 'subscription', $managerStub );
94
+		\Aimeos\MShop\Factory::injectManager($this->context, 'subscription', $managerStub);
95 95
 
96
-		$managerStub->expects( $this->once() )->method( 'searchItems' )
97
-			->will( $this->returnValue( [$managerStub->createItem()] ) );
96
+		$managerStub->expects($this->once())->method('searchItems')
97
+			->will($this->returnValue([$managerStub->createItem()]));
98 98
 
99
-		$managerStub->expects( $this->never() )->method( 'saveItem' );
99
+		$managerStub->expects($this->never())->method('saveItem');
100 100
 
101 101
 		$this->object->run();
102 102
 	}
@@ -106,34 +106,34 @@  discard block
 block discarded – undo
106 106
 	{
107 107
 		$item = $this->getSubscription();
108 108
 
109
-		$managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Order\\Manager\\Base\\Standard' )
110
-			->setConstructorArgs( [$this->context] )
111
-			->setMethods( ['store'] )
109
+		$managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Base\\Standard')
110
+			->setConstructorArgs([$this->context])
111
+			->setMethods(['store'])
112 112
 			->getMock();
113 113
 
114
-		\Aimeos\MShop\Factory::injectManager( $this->context, 'order/base', $managerStub );
114
+		\Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $managerStub);
115 115
 
116
-		$managerStub->expects( $this->once() )->method( 'store' );
116
+		$managerStub->expects($this->once())->method('store');
117 117
 
118
-		$this->access( 'createOrderBase' )->invokeArgs( $this->object, [$this->context, $item] );
118
+		$this->access('createOrderBase')->invokeArgs($this->object, [$this->context, $item]);
119 119
 	}
120 120
 
121 121
 
122 122
 	public function testCreateOrderInvoice()
123 123
 	{
124 124
 		$item = $this->getSubscription();
125
-		$baseItem = $this->getOrderBaseItem( $item->getOrderBaseId() );
125
+		$baseItem = $this->getOrderBaseItem($item->getOrderBaseId());
126 126
 
127
-		$managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Order\\Manager\\Standard' )
128
-			->setConstructorArgs( [$this->context] )
129
-			->setMethods( ['saveItem'] )
127
+		$managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Standard')
128
+			->setConstructorArgs([$this->context])
129
+			->setMethods(['saveItem'])
130 130
 			->getMock();
131 131
 
132
-		\Aimeos\MShop\Factory::injectManager( $this->context, 'order', $managerStub );
132
+		\Aimeos\MShop\Factory::injectManager($this->context, 'order', $managerStub);
133 133
 
134
-		$managerStub->expects( $this->once() )->method( 'saveItem' );
134
+		$managerStub->expects($this->once())->method('saveItem');
135 135
 
136
-		$this->access( 'createOrderInvoice' )->invokeArgs( $this->object, [$this->context, $baseItem] );
136
+		$this->access('createOrderInvoice')->invokeArgs($this->object, [$this->context, $baseItem]);
137 137
 	}
138 138
 
139 139
 
@@ -141,55 +141,55 @@  discard block
 block discarded – undo
141 141
 	{
142 142
 		$item = $this->getSubscription();
143 143
 		$invoice = $this->getOrderItem();
144
-		$baseItem = $this->getOrderBaseItem( $item->getOrderBaseId() );
144
+		$baseItem = $this->getOrderBaseItem($item->getOrderBaseId());
145 145
 
146
-		$managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Order\\Manager\\Standard' )
147
-			->setConstructorArgs( [$this->context] )
148
-			->setMethods( ['saveItem'] )
146
+		$managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Standard')
147
+			->setConstructorArgs([$this->context])
148
+			->setMethods(['saveItem'])
149 149
 			->getMock();
150 150
 
151
-		\Aimeos\MShop\Factory::injectManager( $this->context, 'order', $managerStub );
151
+		\Aimeos\MShop\Factory::injectManager($this->context, 'order', $managerStub);
152 152
 
153
-		$managerStub->expects( $this->once() )->method( 'saveItem' );
153
+		$managerStub->expects($this->once())->method('saveItem');
154 154
 
155
-		$this->access( 'createPayment' )->invokeArgs( $this->object, [$this->context, $baseItem, $invoice] );
155
+		$this->access('createPayment')->invokeArgs($this->object, [$this->context, $baseItem, $invoice]);
156 156
 	}
157 157
 
158 158
 
159 159
 	protected function getOrderItem()
160 160
 	{
161
-		return \Aimeos\MShop\Factory::createManager( $this->context, 'order' )->createItem();
161
+		return \Aimeos\MShop\Factory::createManager($this->context, 'order')->createItem();
162 162
 	}
163 163
 
164 164
 
165
-	protected function getOrderBaseItem( $baseId )
165
+	protected function getOrderBaseItem($baseId)
166 166
 	{
167
-		return \Aimeos\MShop\Factory::createManager( $this->context, 'order/base' )->getItem( $baseId, ['order/base/service'] );
167
+		return \Aimeos\MShop\Factory::createManager($this->context, 'order/base')->getItem($baseId, ['order/base/service']);
168 168
 	}
169 169
 
170 170
 
171 171
 	protected function getSubscription()
172 172
 	{
173
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'subscription' );
173
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'subscription');
174 174
 
175 175
 		$search = $manager->createSearch();
176
-		$search->setConditions( $search->compare( '==', 'subscription.dateend', '2010-01-01' ) );
176
+		$search->setConditions($search->compare('==', 'subscription.dateend', '2010-01-01'));
177 177
 
178
-		$items = $manager->searchItems( $search );
178
+		$items = $manager->searchItems($search);
179 179
 
180
-		if( ( $item = reset( $items ) ) !== false ) {
180
+		if (($item = reset($items)) !== false) {
181 181
 			return $item;
182 182
 		}
183 183
 
184
-		throw new \Exception( 'No subscription item found' );
184
+		throw new \Exception('No subscription item found');
185 185
 	}
186 186
 
187 187
 
188
-	protected function access( $name )
188
+	protected function access($name)
189 189
 	{
190
-		$class = new \ReflectionClass( '\Aimeos\Controller\Jobs\Subscription\Process\Renew\Standard' );
191
-		$method = $class->getMethod( $name );
192
-		$method->setAccessible( true );
190
+		$class = new \ReflectionClass('\Aimeos\Controller\Jobs\Subscription\Process\Renew\Standard');
191
+		$method = $class->getMethod($name);
192
+		$method->setAccessible(true);
193 193
 
194 194
 		return $method;
195 195
 	}
Please login to merge, or discard this patch.
tests/Controller/Common/Order/Export/Csv/Processor/Product/StandardTest.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -35,51 +35,51 @@
 block discarded – undo
35 35
 		);
36 36
 
37 37
 
38
-		$object = new \Aimeos\Controller\Common\Order\Export\Csv\Processor\Product\Standard( $context, $mapping );
39
-
40
-		$invoice = $this->getInvoice( $context );
41
-		$order = \Aimeos\MShop\Factory::createManager( $context, 'order/base' )->load( $invoice->getBaseId() );
42
-
43
-		$data = $object->process( $invoice, $order );
44
-
45
-
46
-		$this->assertEquals( 4, count( $data ) );
47
-
48
-		$this->assertEquals( 18, count( $data[0] ) );
49
-		$this->assertEquals( 'default', $data[0][0] );
50
-		$this->assertEquals( 'unit_type1', $data[0][1] );
51
-		$this->assertEquals( 'unitsupplier', $data[0][2] );
52
-		$this->assertEquals( 'CNE', $data[0][3] );
53
-		$this->assertGreaterThan( 0, $data[0][4] );
54
-		$this->assertEquals( '9', $data[0][5] );
55
-		$this->assertEquals( 'Cafe Noire Expresso', $data[0][6] );
56
-		$this->assertEquals( 'somewhere/thump1.jpg', $data[0][7] );
57
-		$this->assertEquals( '4.50', $data[0][8] );
58
-		$this->assertEquals( '0.00', $data[0][9] );
59
-		$this->assertEquals( '0.00', $data[0][10] );
60
-		$this->assertEquals( '0.0000', $data[0][11] );
61
-		$this->assertEquals( '1', $data[0][12] );
62
-		$this->assertEquals( '1', $data[0][13] );
63
-		$this->assertEquals( "default\ndefault\nconfig", $data[0][14] );
64
-		$this->assertEquals( "width\nlength\ninterval", $data[0][15] );
65
-		$this->assertEquals( "33\n36\nP0Y1M0W0D", $data[0][16] );
66
-		$this->assertEquals( "33\n36\nP0Y1M0W0D", $data[0][17] );
38
+		$object = new \Aimeos\Controller\Common\Order\Export\Csv\Processor\Product\Standard($context, $mapping);
39
+
40
+		$invoice = $this->getInvoice($context);
41
+		$order = \Aimeos\MShop\Factory::createManager($context, 'order/base')->load($invoice->getBaseId());
42
+
43
+		$data = $object->process($invoice, $order);
44
+
45
+
46
+		$this->assertEquals(4, count($data));
47
+
48
+		$this->assertEquals(18, count($data[0]));
49
+		$this->assertEquals('default', $data[0][0]);
50
+		$this->assertEquals('unit_type1', $data[0][1]);
51
+		$this->assertEquals('unitsupplier', $data[0][2]);
52
+		$this->assertEquals('CNE', $data[0][3]);
53
+		$this->assertGreaterThan(0, $data[0][4]);
54
+		$this->assertEquals('9', $data[0][5]);
55
+		$this->assertEquals('Cafe Noire Expresso', $data[0][6]);
56
+		$this->assertEquals('somewhere/thump1.jpg', $data[0][7]);
57
+		$this->assertEquals('4.50', $data[0][8]);
58
+		$this->assertEquals('0.00', $data[0][9]);
59
+		$this->assertEquals('0.00', $data[0][10]);
60
+		$this->assertEquals('0.0000', $data[0][11]);
61
+		$this->assertEquals('1', $data[0][12]);
62
+		$this->assertEquals('1', $data[0][13]);
63
+		$this->assertEquals("default\ndefault\nconfig", $data[0][14]);
64
+		$this->assertEquals("width\nlength\ninterval", $data[0][15]);
65
+		$this->assertEquals("33\n36\nP0Y1M0W0D", $data[0][16]);
66
+		$this->assertEquals("33\n36\nP0Y1M0W0D", $data[0][17]);
67 67
 	}
68 68
 
69 69
 
70
-	protected function getInvoice( $context )
70
+	protected function getInvoice($context)
71 71
 	{
72
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'order' );
72
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'order');
73 73
 
74 74
 		$search = $manager->createSearch();
75
-		$search->setConditions( $search->compare( '==', 'order.datepayment', '2008-02-15 12:34:56' ) );
75
+		$search->setConditions($search->compare('==', 'order.datepayment', '2008-02-15 12:34:56'));
76 76
 
77
-		$items = $manager->searchItems( $search );
77
+		$items = $manager->searchItems($search);
78 78
 
79
-		if( ( $item = reset( $items ) ) !== false ) {
79
+		if (($item = reset($items)) !== false) {
80 80
 			return $item;
81 81
 		}
82 82
 
83
-		throw new \Exception( 'No order item found' );
83
+		throw new \Exception('No order item found');
84 84
 	}
85 85
 }
Please login to merge, or discard this patch.
Common/Subscription/Export/Csv/Processor/Product/StandardTest.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -35,51 +35,51 @@
 block discarded – undo
35 35
 		);
36 36
 
37 37
 
38
-		$object = new \Aimeos\Controller\Common\Subscription\Export\Csv\Processor\Product\Standard( $context, $mapping );
39
-
40
-		$subscription = $this->getSubscription( $context );
41
-		$order = \Aimeos\MShop\Factory::createManager( $context, 'order/base' )->load( $subscription->getOrderBaseId() );
42
-
43
-		$data = $object->process( $subscription, $order );
44
-
45
-
46
-		$this->assertEquals( 1, count( $data ) );
47
-
48
-		$this->assertEquals( 18, count( $data[0] ) );
49
-		$this->assertEquals( 'default', $data[0][0] );
50
-		$this->assertEquals( 'unit_type1', $data[0][1] );
51
-		$this->assertEquals( 'unitsupplier', $data[0][2] );
52
-		$this->assertEquals( 'CNE', $data[0][3] );
53
-		$this->assertGreaterThan( 0, $data[0][4] );
54
-		$this->assertEquals( '9', $data[0][5] );
55
-		$this->assertEquals( 'Cafe Noire Expresso', $data[0][6] );
56
-		$this->assertEquals( 'somewhere/thump1.jpg', $data[0][7] );
57
-		$this->assertEquals( '4.50', $data[0][8] );
58
-		$this->assertEquals( '0.00', $data[0][9] );
59
-		$this->assertEquals( '0.00', $data[0][10] );
60
-		$this->assertEquals( '0.0000', $data[0][11] );
61
-		$this->assertEquals( '1', $data[0][12] );
62
-		$this->assertEquals( '1', $data[0][13] );
63
-		$this->assertEquals( "default\ndefault\nconfig", $data[0][14] );
64
-		$this->assertEquals( "width\nlength\ninterval", $data[0][15] );
65
-		$this->assertEquals( "33\n36\nP0Y1M0W0D", $data[0][16] );
66
-		$this->assertEquals( "33\n36\nP0Y1M0W0D", $data[0][17] );
38
+		$object = new \Aimeos\Controller\Common\Subscription\Export\Csv\Processor\Product\Standard($context, $mapping);
39
+
40
+		$subscription = $this->getSubscription($context);
41
+		$order = \Aimeos\MShop\Factory::createManager($context, 'order/base')->load($subscription->getOrderBaseId());
42
+
43
+		$data = $object->process($subscription, $order);
44
+
45
+
46
+		$this->assertEquals(1, count($data));
47
+
48
+		$this->assertEquals(18, count($data[0]));
49
+		$this->assertEquals('default', $data[0][0]);
50
+		$this->assertEquals('unit_type1', $data[0][1]);
51
+		$this->assertEquals('unitsupplier', $data[0][2]);
52
+		$this->assertEquals('CNE', $data[0][3]);
53
+		$this->assertGreaterThan(0, $data[0][4]);
54
+		$this->assertEquals('9', $data[0][5]);
55
+		$this->assertEquals('Cafe Noire Expresso', $data[0][6]);
56
+		$this->assertEquals('somewhere/thump1.jpg', $data[0][7]);
57
+		$this->assertEquals('4.50', $data[0][8]);
58
+		$this->assertEquals('0.00', $data[0][9]);
59
+		$this->assertEquals('0.00', $data[0][10]);
60
+		$this->assertEquals('0.0000', $data[0][11]);
61
+		$this->assertEquals('1', $data[0][12]);
62
+		$this->assertEquals('1', $data[0][13]);
63
+		$this->assertEquals("default\ndefault\nconfig", $data[0][14]);
64
+		$this->assertEquals("width\nlength\ninterval", $data[0][15]);
65
+		$this->assertEquals("33\n36\nP0Y1M0W0D", $data[0][16]);
66
+		$this->assertEquals("33\n36\nP0Y1M0W0D", $data[0][17]);
67 67
 	}
68 68
 
69 69
 
70
-	protected function getSubscription( $context )
70
+	protected function getSubscription($context)
71 71
 	{
72
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'subscription' );
72
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'subscription');
73 73
 
74 74
 		$search = $manager->createSearch();
75
-		$search->setConditions( $search->compare( '==', 'subscription.dateend', '2010-01-01' ) );
75
+		$search->setConditions($search->compare('==', 'subscription.dateend', '2010-01-01'));
76 76
 
77
-		$items = $manager->searchItems( $search );
77
+		$items = $manager->searchItems($search);
78 78
 
79
-		if( ( $item = reset( $items ) ) !== false ) {
79
+		if (($item = reset($items)) !== false) {
80 80
 			return $item;
81 81
 		}
82 82
 
83
-		throw new \Exception( 'No subscription item found' );
83
+		throw new \Exception('No subscription item found');
84 84
 	}
85 85
 }
Please login to merge, or discard this patch.