Completed
Push — master ( 0b1729...545b8f )
by Aimeos
01:57
created
controller/jobs/src/Controller/Jobs/Product/Bought/Standard.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	public function getName()
31 31
 	{
32
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Products bought together' );
32
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Products bought together');
33 33
 	}
34 34
 
35 35
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	public function getDescription()
42 42
 	{
43
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Creates bought together product suggestions' );
43
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Creates bought together product suggestions');
44 44
 	}
45 45
 
46 46
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 		 * @see controller/jobs/product/bought/min-confidence
73 73
 		 * @see controller/jobs/product/bought/limit-days
74 74
 		 */
75
-		$maxItems = $config->get( 'controller/jobs/product/bought/max-items', 5 );
75
+		$maxItems = $config->get('controller/jobs/product/bought/max-items', 5);
76 76
 
77 77
 		/** controller/jobs/product/bought/min-support
78 78
 		 * Minimum support value to sort out all irrelevant combinations
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 		 * @see controller/jobs/product/bought/min-confidence
102 102
 		 * @see controller/jobs/product/bought/limit-days
103 103
 		 */
104
-		$minSupport = $config->get( 'controller/jobs/product/bought/min-support', 0.02 );
104
+		$minSupport = $config->get('controller/jobs/product/bought/min-support', 0.02);
105 105
 
106 106
 		/** controller/jobs/product/bought/min-confidence
107 107
 		 * Minimum confidence value for high quality suggestions
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 		 * @see controller/jobs/product/bought/min-support
127 127
 		 * @see controller/jobs/product/bought/limit-days
128 128
 		 */
129
-		$minConfidence = $config->get( 'controller/jobs/product/bought/min-confidence', 0.66 );
129
+		$minConfidence = $config->get('controller/jobs/product/bought/min-confidence', 0.66);
130 130
 
131 131
 		/** controller/jobs/product/bought/limit-days
132 132
 		 * Only use orders placed in the past within the configured number of days for calculating bought together products
@@ -150,43 +150,43 @@  discard block
 block discarded – undo
150 150
 		 * @see controller/jobs/product/bought/min-support
151 151
 		 * @see controller/jobs/product/bought/min-confidence
152 152
 		 */
153
-		$days = $config->get( 'controller/jobs/product/bought/limit-days', 180 );
154
-		$date = date( 'Y-m-d H:i:s', time() - $days * 86400 );
153
+		$days = $config->get('controller/jobs/product/bought/limit-days', 180);
154
+		$date = date('Y-m-d H:i:s', time() - $days * 86400);
155 155
 
156 156
 
157
-		$baseManager = \Aimeos\MShop::create( $context, 'order/base' );
157
+		$baseManager = \Aimeos\MShop::create($context, 'order/base');
158 158
 		$search = $baseManager->createSearch();
159
-		$search->setConditions( $search->compare( '>', 'order.base.ctime', $date ) );
160
-		$search->setSlice( 0, 0 );
159
+		$search->setConditions($search->compare('>', 'order.base.ctime', $date));
160
+		$search->setSlice(0, 0);
161 161
 		$totalOrders = 0;
162
-		$baseManager->searchItems( $search, [], $totalOrders );
162
+		$baseManager->searchItems($search, [], $totalOrders);
163 163
 
164
-		$baseProductManager = \Aimeos\MShop::create( $context, 'order/base/product' );
164
+		$baseProductManager = \Aimeos\MShop::create($context, 'order/base/product');
165 165
 		$search = $baseProductManager->createSearch();
166
-		$search->setConditions( $search->compare( '>', 'order.base.product.ctime', $date ) );
166
+		$search->setConditions($search->compare('>', 'order.base.product.ctime', $date));
167 167
 		$start = 0;
168 168
 
169 169
 		do
170 170
 		{
171
-			$totalCounts = $baseProductManager->aggregate( $search, 'order.base.product.productid' );
172
-			$prodIds = array_keys( $totalCounts );
171
+			$totalCounts = $baseProductManager->aggregate($search, 'order.base.product.productid');
172
+			$prodIds = array_keys($totalCounts);
173 173
 
174
-			foreach( $totalCounts as $id => $count )
174
+			foreach ($totalCounts as $id => $count)
175 175
 			{
176
-				$this->removeListItems( $id );
176
+				$this->removeListItems($id);
177 177
 
178
-				if( $count / $totalOrders > $minSupport )
178
+				if ($count / $totalOrders > $minSupport)
179 179
 				{
180
-					$productIds = $this->getSuggestions( $id, $prodIds, $count, $totalOrders, $maxItems, $minSupport, $minConfidence, $date );
181
-					$this->addListItems( $id, $productIds );
180
+					$productIds = $this->getSuggestions($id, $prodIds, $count, $totalOrders, $maxItems, $minSupport, $minConfidence, $date);
181
+					$this->addListItems($id, $productIds);
182 182
 				}
183 183
 			}
184 184
 
185
-			$count = count( $totalCounts );
185
+			$count = count($totalCounts);
186 186
 			$start += $count;
187
-			$search->setSlice( $start );
187
+			$search->setSlice($start);
188 188
 		}
189
-		while( $count >= $search->getSliceSize() );
189
+		while ($count >= $search->getSliceSize());
190 190
 	}
191 191
 
192 192
 
@@ -203,59 +203,59 @@  discard block
 block discarded – undo
203 203
 	 * @param string $date Date in YYYY-MM-DD HH:mm:ss format after which orders should be used for calculations
204 204
 	 * @return array List of suggested product IDs as key and their confidence as value
205 205
 	 */
206
-	protected function getSuggestions( $id, $prodIds, $count, $total, $maxItems, $minSupport, $minConfidence, $date )
206
+	protected function getSuggestions($id, $prodIds, $count, $total, $maxItems, $minSupport, $minConfidence, $date)
207 207
 	{
208 208
 		$refIds = [];
209 209
 		$context = $this->getContext();
210 210
 
211
-		$catalogListManager = \Aimeos\MShop::create( $context, 'catalog/lists' );
212
-		$baseProductManager = \Aimeos\MShop::create( $context, 'order/base/product' );
211
+		$catalogListManager = \Aimeos\MShop::create($context, 'catalog/lists');
212
+		$baseProductManager = \Aimeos\MShop::create($context, 'order/base/product');
213 213
 
214 214
 
215 215
 		$search = $baseProductManager->createSearch();
216
-		$func = $search->createFunction( 'order.base.product.count', array( (string) $id ) );
216
+		$func = $search->createFunction('order.base.product.count', array((string) $id));
217 217
 		$expr = array(
218
-			$search->compare( '==', 'order.base.product.productid', $prodIds ),
219
-			$search->compare( '>', 'order.base.product.ctime', $date ),
220
-			$search->compare( '==', $func, 1 ),
218
+			$search->compare('==', 'order.base.product.productid', $prodIds),
219
+			$search->compare('>', 'order.base.product.ctime', $date),
220
+			$search->compare('==', $func, 1),
221 221
 		);
222
-		$search->setConditions( $search->combine( '&&', $expr ) );
222
+		$search->setConditions($search->combine('&&', $expr));
223 223
 
224
-		$relativeCounts = $baseProductManager->aggregate( $search, 'order.base.product.productid' );
224
+		$relativeCounts = $baseProductManager->aggregate($search, 'order.base.product.productid');
225 225
 
226 226
 
227 227
 		$search = $catalogListManager->createSearch();
228 228
 		$expr = array(
229
-			$search->compare( '==', 'catalog.lists.refid', array_keys( $relativeCounts ) ),
230
-			$search->compare( '==', 'catalog.lists.domain', 'product' ),
229
+			$search->compare('==', 'catalog.lists.refid', array_keys($relativeCounts)),
230
+			$search->compare('==', 'catalog.lists.domain', 'product'),
231 231
 		);
232
-		$search->setConditions( $search->combine( '&&', $expr ) );
232
+		$search->setConditions($search->combine('&&', $expr));
233 233
 
234
-		foreach( $catalogListManager->searchItems( $search ) as $listItem ) {
234
+		foreach ($catalogListManager->searchItems($search) as $listItem) {
235 235
 			$refIds[$listItem->getRefId()] = true;
236 236
 		}
237 237
 
238 238
 
239
-		unset( $relativeCounts[$id] );
239
+		unset($relativeCounts[$id]);
240 240
 		$supportA = $count / $total;
241 241
 		$products = [];
242 242
 
243
-		foreach( $relativeCounts as $prodId => $relCnt )
243
+		foreach ($relativeCounts as $prodId => $relCnt)
244 244
 		{
245
-			if( !isset( $refIds[$prodId] ) ) {
245
+			if (!isset($refIds[$prodId])) {
246 246
 				continue;
247 247
 			}
248 248
 
249 249
 			$supportAB = $relCnt / $total;
250 250
 
251
-			if( $supportAB > $minSupport && ( $conf = ( $supportAB / $supportA ) ) > $minConfidence ) {
251
+			if ($supportAB > $minSupport && ($conf = ($supportAB / $supportA)) > $minConfidence) {
252 252
 				$products[$prodId] = $conf;
253 253
 			}
254 254
 		}
255 255
 
256
-		arsort( $products );
256
+		arsort($products);
257 257
 
258
-		return array_keys( array_slice( $products, 0, $maxItems, true ) );
258
+		return array_keys(array_slice($products, 0, $maxItems, true));
259 259
 	}
260 260
 
261 261
 
@@ -265,26 +265,26 @@  discard block
 block discarded – undo
265 265
 	 * @param string $productId Unique ID of the product the given products should be referenced to
266 266
 	 * @param array $productIds List of position as key and product ID as value
267 267
 	 */
268
-	protected function addListItems( $productId, array $productIds )
268
+	protected function addListItems($productId, array $productIds)
269 269
 	{
270
-		if( empty( $productIds ) ) {
270
+		if (empty($productIds)) {
271 271
 			return;
272 272
 		}
273 273
 
274
-		$manager = \Aimeos\MShop::create( $this->getContext(), 'product/lists' );
274
+		$manager = \Aimeos\MShop::create($this->getContext(), 'product/lists');
275 275
 		$item = $manager->createItem();
276 276
 
277
-		foreach( $productIds as $pos => $refid )
277
+		foreach ($productIds as $pos => $refid)
278 278
 		{
279
-			$item->setId( null );
280
-			$item->setParentId( $productId );
281
-			$item->setDomain( 'product' );
282
-			$item->setType( 'bought-together' );
283
-			$item->setPosition( $pos );
284
-			$item->setRefId( $refid );
285
-			$item->setStatus( 1 );
286
-
287
-			$manager->saveItem( $item, false );
279
+			$item->setId(null);
280
+			$item->setParentId($productId);
281
+			$item->setDomain('product');
282
+			$item->setType('bought-together');
283
+			$item->setPosition($pos);
284
+			$item->setRefId($refid);
285
+			$item->setStatus(1);
286
+
287
+			$manager->saveItem($item, false);
288 288
 		}
289 289
 	}
290 290
 
@@ -294,20 +294,20 @@  discard block
 block discarded – undo
294 294
 	 *
295 295
 	 * @param string $productId Unique ID of the product the references should be removed from
296 296
 	 */
297
-	protected function removeListItems( $productId )
297
+	protected function removeListItems($productId)
298 298
 	{
299
-		$manager = \Aimeos\MShop::create( $this->getContext(), 'product/lists' );
299
+		$manager = \Aimeos\MShop::create($this->getContext(), 'product/lists');
300 300
 
301 301
 		$search = $manager->createSearch();
302 302
 		$expr = array(
303
-			$search->compare( '==', 'product.lists.parentid', $productId ),
304
-			$search->compare( '==', 'product.lists.domain', 'product' ),
305
-			$search->compare( '==', 'product.lists.type', 'bought-together' ),
303
+			$search->compare('==', 'product.lists.parentid', $productId),
304
+			$search->compare('==', 'product.lists.domain', 'product'),
305
+			$search->compare('==', 'product.lists.type', 'bought-together'),
306 306
 		);
307
-		$search->setConditions( $search->combine( '&&', $expr ) );
307
+		$search->setConditions($search->combine('&&', $expr));
308 308
 
309
-		$listItems = $manager->searchItems( $search );
309
+		$listItems = $manager->searchItems($search);
310 310
 
311
-		$manager->deleteItems( array_keys( $listItems ) );
311
+		$manager->deleteItems(array_keys($listItems));
312 312
 	}
313 313
 }
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Admin/Cache/Standard.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	public function getName()
31 31
 	{
32
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Cache cleanup' );
32
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Cache cleanup');
33 33
 	}
34 34
 
35 35
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	public function getDescription()
42 42
 	{
43
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Removes the expired entries from the cache' );
43
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Removes the expired entries from the cache');
44 44
 	}
45 45
 
46 46
 
@@ -51,6 +51,6 @@  discard block
 block discarded – undo
51 51
 	 */
52 52
 	public function run()
53 53
 	{
54
-		\Aimeos\MAdmin\Cache\Manager\Factory::create( $this->getContext() )->getCache()->cleanup();
54
+		\Aimeos\MAdmin\Cache\Manager\Factory::create($this->getContext())->getCache()->cleanup();
55 55
 	}
56 56
 }
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Admin/Log/Standard.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	public function getName()
31 31
 	{
32
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Log cleanup' );
32
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Log cleanup');
33 33
 	}
34 34
 
35 35
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	public function getDescription()
42 42
 	{
43
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Removes the old log entries from the database and archives them (optional)' );
43
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Removes the old log entries from the database and archives them (optional)');
44 44
 	}
45 45
 
46 46
 
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 		 * @see controller/jobs/admin/log/standard/container/format
72 72
 		 * @see controller/jobs/admin/log/standard/container/options
73 73
 		 */
74
-		$limit = $config->get( 'controller/jobs/admin/log/standard/limit-days', 30 );
75
-		$limitDate = date( 'Y-m-d H:i:s', time() - $limit * 86400 );
74
+		$limit = $config->get('controller/jobs/admin/log/standard/limit-days', 30);
75
+		$limitDate = date('Y-m-d H:i:s', time() - $limit * 86400);
76 76
 
77 77
 		/** controller/jobs/admin/log/standard/path
78 78
 		 * Path to a writable directory where the log archive files should be stored
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 		 * @see controller/jobs/admin/log/standard/container/options
102 102
 		 * @see controller/jobs/admin/log/standard/limit-days
103 103
 		 */
104
-		if( ( $path = $config->get( 'controller/jobs/admin/log/standard/path', null ) ) !== null )
104
+		if (($path = $config->get('controller/jobs/admin/log/standard/path', null)) !== null)
105 105
 		{
106 106
 			/** controller/jobs/admin/log/standard/container/type
107 107
 			 * Container file type storing all coupon code files to import
@@ -175,19 +175,19 @@  discard block
 block discarded – undo
175 175
 			 * @see controller/jobs/admin/log/standard/limit-days
176 176
 			 */
177 177
 
178
-			$type = $config->get( 'controller/jobs/admin/log/standard/container/type', 'Zip' );
179
-			$format = $config->get( 'controller/jobs/admin/log/standard/container/format', 'CSV' );
180
-			$options = $config->get( 'controller/jobs/admin/log/standard/container/options', [] );
178
+			$type = $config->get('controller/jobs/admin/log/standard/container/type', 'Zip');
179
+			$format = $config->get('controller/jobs/admin/log/standard/container/format', 'CSV');
180
+			$options = $config->get('controller/jobs/admin/log/standard/container/options', []);
181 181
 
182
-			$path .= DIRECTORY_SEPARATOR . str_replace( ' ', '_', $limitDate );
183
-			$container = \Aimeos\MW\Container\Factory::getContainer( $path, $type, $format, $options );
182
+			$path .= DIRECTORY_SEPARATOR . str_replace(' ', '_', $limitDate);
183
+			$container = \Aimeos\MW\Container\Factory::getContainer($path, $type, $format, $options);
184 184
 		}
185 185
 
186
-		$manager = \Aimeos\MAdmin::create( $context, 'log' );
186
+		$manager = \Aimeos\MAdmin::create($context, 'log');
187 187
 
188 188
 		$search = $manager->createSearch();
189
-		$search->setConditions( $search->compare( '<=', 'log.timestamp', $limitDate ) );
190
-		$search->setSortations( array( $search->sort( '+', 'log.timestamp' ) ) );
189
+		$search->setConditions($search->compare('<=', 'log.timestamp', $limitDate));
190
+		$search->setSortations(array($search->sort('+', 'log.timestamp')));
191 191
 
192 192
 		$start = 0;
193 193
 		$contents = [];
@@ -195,37 +195,37 @@  discard block
 block discarded – undo
195 195
 		do
196 196
 		{
197 197
 			$ids = [];
198
-			$items = $manager->searchItems( $search );
198
+			$items = $manager->searchItems($search);
199 199
 
200
-			foreach( $items as $id => $item )
200
+			foreach ($items as $id => $item)
201 201
 			{
202
-				if( $container !== null )
202
+				if ($container !== null)
203 203
 				{
204 204
 					$facility = $item->getFacility();
205 205
 
206
-					if( !isset( $contents[$facility] ) ) {
207
-						$contents[$facility] = $container->create( $facility );
206
+					if (!isset($contents[$facility])) {
207
+						$contents[$facility] = $container->create($facility);
208 208
 					}
209 209
 
210
-					$contents[$facility]->add( $item->toArray() );
210
+					$contents[$facility]->add($item->toArray());
211 211
 				}
212 212
 
213 213
 				$ids[] = $id;
214 214
 			}
215 215
 
216
-			$manager->deleteItems( $ids );
216
+			$manager->deleteItems($ids);
217 217
 
218
-			$count = count( $items );
218
+			$count = count($items);
219 219
 			$start += $count;
220
-			$search->setSlice( $start );
220
+			$search->setSlice($start);
221 221
 		}
222
-		while( $count >= $search->getSliceSize() );
222
+		while ($count >= $search->getSliceSize());
223 223
 
224 224
 
225
-		if( $container !== null && !empty( $contents ) )
225
+		if ($container !== null && !empty($contents))
226 226
 		{
227
-			foreach( $contents as $content ) {
228
-				$container->add( $content );
227
+			foreach ($contents as $content) {
228
+				$container->add($content);
229 229
 			}
230 230
 
231 231
 			$container->close();
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Index/Optimize/Standard.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	public function getName()
31 31
 	{
32
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Index optimization' );
32
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Index optimization');
33 33
 	}
34 34
 
35 35
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	public function getDescription()
42 42
 	{
43
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Optimizes the index for searching products faster' );
43
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Optimizes the index for searching products faster');
44 44
 	}
45 45
 
46 46
 
@@ -51,6 +51,6 @@  discard block
 block discarded – undo
51 51
 	 */
52 52
 	public function run()
53 53
 	{
54
-		\Aimeos\MShop\Index\Manager\Factory::create( $this->getContext() )->optimize();
54
+		\Aimeos\MShop\Index\Manager\Factory::create($this->getContext())->optimize();
55 55
 	}
56 56
 }
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Index/Rebuild/Standard.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	public function getName()
31 31
 	{
32
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Index rebuild' );
32
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Index rebuild');
33 33
 	}
34 34
 
35 35
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	public function getDescription()
42 42
 	{
43
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Rebuilds the index for searching products' );
43
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Rebuilds the index for searching products');
44 44
 	}
45 45
 
46 46
 
@@ -51,15 +51,15 @@  discard block
 block discarded – undo
51 51
 	 */
52 52
 	public function run()
53 53
 	{
54
-		$timestamp = date( 'Y-m-d H:i:s' );
54
+		$timestamp = date('Y-m-d H:i:s');
55 55
 		$context = clone $this->getContext();
56 56
 
57
-		$context->getLocale()->setLanguageId( null );
58
-		$context->getLocale()->setCurrencyId( null );
57
+		$context->getLocale()->setLanguageId(null);
58
+		$context->getLocale()->setCurrencyId(null);
59 59
 
60
-		$manager = \Aimeos\MShop\Index\Manager\Factory::create( $context );
60
+		$manager = \Aimeos\MShop\Index\Manager\Factory::create($context);
61 61
 
62 62
 		$manager->rebuildIndex();
63
-		$manager->cleanupIndex( $timestamp );
63
+		$manager->cleanupIndex($timestamp);
64 64
 	}
65 65
 }
Please login to merge, or discard this patch.
controller/jobs/tests/TestHelperJobs.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -15,14 +15,14 @@  discard block
 block discarded – undo
15 15
 	public static function bootstrap()
16 16
 	{
17 17
 		self::getAimeos();
18
-		\Aimeos\MShop::cache( false );
18
+		\Aimeos\MShop::cache(false);
19 19
 	}
20 20
 
21 21
 
22
-	public static function getContext( $site = 'unittest' )
22
+	public static function getContext($site = 'unittest')
23 23
 	{
24
-		if( !isset( self::$context[$site] ) ) {
25
-			self::$context[$site] = self::createContext( $site );
24
+		if (!isset(self::$context[$site])) {
25
+			self::$context[$site] = self::createContext($site);
26 26
 		}
27 27
 
28 28
 		return clone self::$context[$site];
@@ -31,13 +31,13 @@  discard block
 block discarded – undo
31 31
 
32 32
 	public static function getAimeos()
33 33
 	{
34
-		if( !isset( self::$aimeos ) )
34
+		if (!isset(self::$aimeos))
35 35
 		{
36 36
 			require_once 'Bootstrap.php';
37
-			spl_autoload_register( 'Aimeos\\Bootstrap::autoload' );
37
+			spl_autoload_register('Aimeos\\Bootstrap::autoload');
38 38
 
39
-			$extdir = dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) );
40
-			self::$aimeos = new \Aimeos\Bootstrap( array( $extdir ), true );
39
+			$extdir = dirname(dirname(dirname(dirname(dirname(__FILE__)))));
40
+			self::$aimeos = new \Aimeos\Bootstrap(array($extdir), true);
41 41
 		}
42 42
 
43 43
 		return self::$aimeos;
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
 
47 47
 	public static function getControllerPaths()
48 48
 	{
49
-		return self::getAimeos()->getCustomPaths( 'controller/jobs' );
49
+		return self::getAimeos()->getCustomPaths('controller/jobs');
50 50
 	}
51 51
 
52 52
 
53 53
 	/**
54 54
 	 * @param string $site
55 55
 	 */
56
-	private static function createContext( $site )
56
+	private static function createContext($site)
57 57
 	{
58 58
 		$ctx = new \Aimeos\MShop\Context\Item\Standard();
59 59
 		$aimeos = self::getAimeos();
@@ -63,80 +63,80 @@  discard block
 block discarded – undo
63 63
 		$paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config';
64 64
 		$file = __DIR__ . DIRECTORY_SEPARATOR . 'confdoc.ser';
65 65
 
66
-		$conf = new \Aimeos\MW\Config\PHPArray( [], $paths );
67
-		$conf = new \Aimeos\MW\Config\Decorator\Memory( $conf );
68
-		$conf = new \Aimeos\MW\Config\Decorator\Documentor( $conf, $file );
69
-		$ctx->setConfig( $conf );
66
+		$conf = new \Aimeos\MW\Config\PHPArray([], $paths);
67
+		$conf = new \Aimeos\MW\Config\Decorator\Memory($conf);
68
+		$conf = new \Aimeos\MW\Config\Decorator\Documentor($conf, $file);
69
+		$ctx->setConfig($conf);
70 70
 
71 71
 
72
-		$logger = new \Aimeos\MW\Logger\File( $site . '.log', \Aimeos\MW\Logger\Base::DEBUG );
73
-		$ctx->setLogger( $logger );
72
+		$logger = new \Aimeos\MW\Logger\File($site . '.log', \Aimeos\MW\Logger\Base::DEBUG);
73
+		$ctx->setLogger($logger);
74 74
 
75 75
 
76
-		$dbm = new \Aimeos\MW\DB\Manager\PDO( $conf );
77
-		$ctx->setDatabaseManager( $dbm );
76
+		$dbm = new \Aimeos\MW\DB\Manager\PDO($conf);
77
+		$ctx->setDatabaseManager($dbm);
78 78
 
79 79
 
80
-		$fs = new \Aimeos\MW\Filesystem\Manager\Standard( $conf );
81
-		$ctx->setFilesystemManager( $fs );
80
+		$fs = new \Aimeos\MW\Filesystem\Manager\Standard($conf);
81
+		$ctx->setFilesystemManager($fs);
82 82
 
83 83
 
84
-		$mq = new \Aimeos\MW\MQueue\Manager\Standard( $conf );
85
-		$ctx->setMessageQueueManager( $mq );
84
+		$mq = new \Aimeos\MW\MQueue\Manager\Standard($conf);
85
+		$ctx->setMessageQueueManager($mq);
86 86
 
87 87
 
88 88
 		$cache = new \Aimeos\MW\Cache\None();
89
-		$ctx->setCache( $cache );
89
+		$ctx->setCache($cache);
90 90
 
91 91
 
92 92
 		$session = new \Aimeos\MW\Session\None();
93
-		$ctx->setSession( $session );
93
+		$ctx->setSession($session);
94 94
 
95 95
 
96
-		$i18n = new \Aimeos\MW\Translation\None( 'de' );
97
-		$ctx->setI18n( array( 'de' => $i18n ) );
96
+		$i18n = new \Aimeos\MW\Translation\None('de');
97
+		$ctx->setI18n(array('de' => $i18n));
98 98
 
99 99
 
100
-		$localeManager = \Aimeos\MShop\Locale\Manager\Factory::create( $ctx );
101
-		$locale = $localeManager->bootstrap( $site, 'de', '', false );
102
-		$ctx->setLocale( $locale );
100
+		$localeManager = \Aimeos\MShop\Locale\Manager\Factory::create($ctx);
101
+		$locale = $localeManager->bootstrap($site, 'de', '', false);
102
+		$ctx->setLocale($locale);
103 103
 
104 104
 
105
-		$view = self::createView( $conf );
106
-		$ctx->setView( $view );
105
+		$view = self::createView($conf);
106
+		$ctx->setView($view);
107 107
 
108 108
 
109
-		$ctx->setEditor( 'core:controller/jobs' );
109
+		$ctx->setEditor('core:controller/jobs');
110 110
 
111 111
 		return $ctx;
112 112
 	}
113 113
 
114 114
 
115
-	protected static function createView( \Aimeos\MW\Config\Iface $config )
115
+	protected static function createView(\Aimeos\MW\Config\Iface $config)
116 116
 	{
117 117
 		$tmplpaths = array_merge_recursive(
118
-			self::getAimeos()->getCustomPaths( 'client/html/templates' ),
119
-			self::getAimeos()->getCustomPaths( 'controller/jobs/templates' )
118
+			self::getAimeos()->getCustomPaths('client/html/templates'),
119
+			self::getAimeos()->getCustomPaths('controller/jobs/templates')
120 120
 		);
121 121
 
122
-		$view = new \Aimeos\MW\View\Standard( $tmplpaths );
122
+		$view = new \Aimeos\MW\View\Standard($tmplpaths);
123 123
 
124
-		$trans = new \Aimeos\MW\Translation\None( 'de_DE' );
125
-		$helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $trans );
126
-		$view->addHelper( 'translate', $helper );
124
+		$trans = new \Aimeos\MW\Translation\None('de_DE');
125
+		$helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $trans);
126
+		$view->addHelper('translate', $helper);
127 127
 
128
-		$helper = new \Aimeos\MW\View\Helper\Url\Standard( $view, 'http://baseurl' );
129
-		$view->addHelper( 'url', $helper );
128
+		$helper = new \Aimeos\MW\View\Helper\Url\Standard($view, 'http://baseurl');
129
+		$view->addHelper('url', $helper);
130 130
 
131
-		$helper = new \Aimeos\MW\View\Helper\Number\Standard( $view, '.', '' );
132
-		$view->addHelper( 'number', $helper );
131
+		$helper = new \Aimeos\MW\View\Helper\Number\Standard($view, '.', '');
132
+		$view->addHelper('number', $helper);
133 133
 
134
-		$helper = new \Aimeos\MW\View\Helper\Date\Standard( $view, 'Y-m-d' );
135
-		$view->addHelper( 'date', $helper );
134
+		$helper = new \Aimeos\MW\View\Helper\Date\Standard($view, 'Y-m-d');
135
+		$view->addHelper('date', $helper);
136 136
 
137
-		$config = new \Aimeos\MW\Config\Decorator\Protect( $config, array( 'controller/jobs', 'client/html' ) );
138
-		$helper = new \Aimeos\MW\View\Helper\Config\Standard( $view, $config );
139
-		$view->addHelper( 'config', $helper );
137
+		$config = new \Aimeos\MW\Config\Decorator\Protect($config, array('controller/jobs', 'client/html'));
138
+		$helper = new \Aimeos\MW\View\Helper\Config\Standard($view, $config);
139
+		$view->addHelper('config', $helper);
140 140
 
141 141
 		return $view;
142 142
 	}
Please login to merge, or discard this patch.
controller/jobs/tests/Controller/Jobs/Product/Import/Csv/StandardTest.php 1 patch
Spacing   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -18,119 +18,119 @@  discard block
 block discarded – undo
18 18
 
19 19
 	protected function setUp()
20 20
 	{
21
-		\Aimeos\MShop::cache( true );
21
+		\Aimeos\MShop::cache(true);
22 22
 
23 23
 		$this->context = \TestHelperJobs::getContext();
24 24
 		$this->aimeos = \TestHelperJobs::getAimeos();
25 25
 		$config = $this->context->getConfig();
26 26
 
27
-		$config->set( 'controller/jobs/product/import/csv/skip-lines', 1 );
28
-		$config->set( 'controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/valid' );
27
+		$config->set('controller/jobs/product/import/csv/skip-lines', 1);
28
+		$config->set('controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/valid');
29 29
 
30
-		$this->object = new \Aimeos\Controller\Jobs\Product\Import\Csv\Standard( $this->context, $this->aimeos );
30
+		$this->object = new \Aimeos\Controller\Jobs\Product\Import\Csv\Standard($this->context, $this->aimeos);
31 31
 	}
32 32
 
33 33
 
34 34
 	protected function tearDown()
35 35
 	{
36
-		\Aimeos\MShop::cache( false );
36
+		\Aimeos\MShop::cache(false);
37 37
 		\Aimeos\MShop::clear();
38 38
 
39 39
 		$this->object = null;
40 40
 
41
-		if( file_exists( 'tmp/import.zip' ) ) {
42
-			unlink( 'tmp/import.zip' );
41
+		if (file_exists('tmp/import.zip')) {
42
+			unlink('tmp/import.zip');
43 43
 		}
44 44
 	}
45 45
 
46 46
 
47 47
 	public function testGetName()
48 48
 	{
49
-		$this->assertEquals( 'Product import CSV', $this->object->getName() );
49
+		$this->assertEquals('Product import CSV', $this->object->getName());
50 50
 	}
51 51
 
52 52
 
53 53
 	public function testGetDescription()
54 54
 	{
55 55
 		$text = 'Imports new and updates existing products from CSV files';
56
-		$this->assertEquals( $text, $this->object->getDescription() );
56
+		$this->assertEquals($text, $this->object->getDescription());
57 57
 	}
58 58
 
59 59
 
60 60
 	public function testRun()
61 61
 	{
62
-		$prodcodes = array( 'job_csv_test', 'job_csv_test2' );
63
-		$nondelete = array( 'attribute', 'product' );
64
-		$delete = array( 'media', 'price', 'text' );
62
+		$prodcodes = array('job_csv_test', 'job_csv_test2');
63
+		$nondelete = array('attribute', 'product');
64
+		$delete = array('media', 'price', 'text');
65 65
 
66 66
 		$convert = array(
67 67
 			1 => 'Text/LatinUTF8',
68 68
 		);
69 69
 
70
-		$this->context->getConfig()->set( 'controller/jobs/product/import/csv/converter', $convert );
70
+		$this->context->getConfig()->set('controller/jobs/product/import/csv/converter', $convert);
71 71
 
72 72
 		$this->object->run();
73 73
 
74
-		$result = $this->get( $prodcodes, array_merge( $delete, $nondelete ) );
75
-		$properties = $this->getProperties( array_keys( $result ) );
76
-		$this->delete( $prodcodes, $delete, $nondelete );
74
+		$result = $this->get($prodcodes, array_merge($delete, $nondelete));
75
+		$properties = $this->getProperties(array_keys($result));
76
+		$this->delete($prodcodes, $delete, $nondelete);
77 77
 
78
-		$this->assertEquals( 2, count( $result ) );
79
-		$this->assertEquals( 2, count( $properties ) );
78
+		$this->assertEquals(2, count($result));
79
+		$this->assertEquals(2, count($properties));
80 80
 
81
-		foreach( $result as $product ) {
82
-			$this->assertEquals( 5, count( $product->getListItems() ) );
81
+		foreach ($result as $product) {
82
+			$this->assertEquals(5, count($product->getListItems()));
83 83
 		}
84 84
 	}
85 85
 
86 86
 
87 87
 	public function testRunUpdate()
88 88
 	{
89
-		$prodcodes = array( 'job_csv_test', 'job_csv_test2' );
90
-		$nondelete = array( 'attribute', 'product' );
91
-		$delete = array( 'media', 'price', 'text' );
89
+		$prodcodes = array('job_csv_test', 'job_csv_test2');
90
+		$nondelete = array('attribute', 'product');
91
+		$delete = array('media', 'price', 'text');
92 92
 
93 93
 		$this->object->run();
94 94
 		$this->object->run();
95 95
 
96
-		$result = $this->get( $prodcodes, array_merge( $delete, $nondelete ) );
97
-		$properties = $this->getProperties( array_keys( $result ) );
98
-		$this->delete( $prodcodes, $delete, $nondelete );
96
+		$result = $this->get($prodcodes, array_merge($delete, $nondelete));
97
+		$properties = $this->getProperties(array_keys($result));
98
+		$this->delete($prodcodes, $delete, $nondelete);
99 99
 
100
-		$this->assertEquals( 2, count( $result ) );
101
-		$this->assertEquals( 2, count( $properties ) );
100
+		$this->assertEquals(2, count($result));
101
+		$this->assertEquals(2, count($properties));
102 102
 
103
-		foreach( $result as $product ) {
104
-			$this->assertEquals( 5, count( $product->getListItems() ) );
103
+		foreach ($result as $product) {
104
+			$this->assertEquals(5, count($product->getListItems()));
105 105
 		}
106 106
 	}
107 107
 
108 108
 
109 109
 	public function testRunPosition()
110 110
 	{
111
-		$prodcodes = array( 'job_csv_test', 'job_csv_test2' );
112
-		$nondelete = array( 'attribute', 'product' );
113
-		$delete = array( 'media', 'price', 'text' );
111
+		$prodcodes = array('job_csv_test', 'job_csv_test2');
112
+		$nondelete = array('attribute', 'product');
113
+		$delete = array('media', 'price', 'text');
114 114
 
115 115
 		$config = $this->context->getConfig();
116
-		$mapping = $config->set( 'controller/jobs/product/import/csv/mapping', [] );
117
-		$mapping['item'] = array( 0 => 'product.label', 1 => 'product.code' );
116
+		$mapping = $config->set('controller/jobs/product/import/csv/mapping', []);
117
+		$mapping['item'] = array(0 => 'product.label', 1 => 'product.code');
118 118
 
119
-		$config->set( 'controller/jobs/product/import/csv/mapping', $mapping );
120
-		$config->set( 'controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/position' );
119
+		$config->set('controller/jobs/product/import/csv/mapping', $mapping);
120
+		$config->set('controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/position');
121 121
 
122 122
 		$this->object->run();
123 123
 
124
-		$result = $this->get( $prodcodes, array_merge( $delete, $nondelete ) );
125
-		$this->delete( $prodcodes, $delete, $nondelete );
124
+		$result = $this->get($prodcodes, array_merge($delete, $nondelete));
125
+		$this->delete($prodcodes, $delete, $nondelete);
126 126
 
127
-		$this->assertEquals( 2, count( $result ) );
127
+		$this->assertEquals(2, count($result));
128 128
 	}
129 129
 
130 130
 
131 131
 	public function testRunProcessorInvalidPosition()
132 132
 	{
133
-		$prodcodes = array( 'job_csv_test', 'job_csv_test2' );
133
+		$prodcodes = array('job_csv_test', 'job_csv_test2');
134 134
 
135 135
 		$mapping = array(
136 136
 			'item' => array(
@@ -150,11 +150,11 @@  discard block
 block discarded – undo
150 150
 			),
151 151
 		);
152 152
 
153
-		$this->context->getConfig()->set( 'controller/jobs/product/import/csv/mapping', $mapping );
153
+		$this->context->getConfig()->set('controller/jobs/product/import/csv/mapping', $mapping);
154 154
 
155 155
 		$this->object->run();
156 156
 
157
-		$this->delete( $prodcodes, array( 'text', 'media' ), [] );
157
+		$this->delete($prodcodes, array('text', 'media'), []);
158 158
 	}
159 159
 
160 160
 
@@ -166,9 +166,9 @@  discard block
 block discarded – undo
166 166
 			),
167 167
 		);
168 168
 
169
-		$this->context->getConfig()->set( 'controller/jobs/product/import/csv/mapping', $mapping );
169
+		$this->context->getConfig()->set('controller/jobs/product/import/csv/mapping', $mapping);
170 170
 
171
-		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
171
+		$this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception');
172 172
 		$this->object->run();
173 173
 	}
174 174
 
@@ -208,15 +208,15 @@  discard block
 block discarded – undo
208 208
 			),
209 209
 		);
210 210
 
211
-		$this->context->getConfig()->set( 'controller/jobs/product/import/csv/mapping', $mapping );
211
+		$this->context->getConfig()->set('controller/jobs/product/import/csv/mapping', $mapping);
212 212
 
213 213
 		$config = $this->context->getConfig();
214
-		$config->set( 'controller/jobs/product/import/csv/skip-lines', 0 );
215
-		$config->set( 'controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/invalid' );
214
+		$config->set('controller/jobs/product/import/csv/skip-lines', 0);
215
+		$config->set('controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/invalid');
216 216
 
217
-		$this->object = new \Aimeos\Controller\Jobs\Product\Import\Csv\Standard( $this->context, $this->aimeos );
217
+		$this->object = new \Aimeos\Controller\Jobs\Product\Import\Csv\Standard($this->context, $this->aimeos);
218 218
 
219
-		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
219
+		$this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception');
220 220
 		$this->object->run();
221 221
 	}
222 222
 
@@ -224,104 +224,104 @@  discard block
 block discarded – undo
224 224
 	public function testRunBackup()
225 225
 	{
226 226
 		$config = $this->context->getConfig();
227
-		$config->set( 'controller/jobs/product/import/csv/container/type', 'Zip' );
228
-		$config->set( 'controller/jobs/product/import/csv/location', 'tmp/import.zip' );
229
-		$config->set( 'controller/jobs/product/import/csv/backup', 'tmp/test-%Y-%m-%d.zip' );
227
+		$config->set('controller/jobs/product/import/csv/container/type', 'Zip');
228
+		$config->set('controller/jobs/product/import/csv/location', 'tmp/import.zip');
229
+		$config->set('controller/jobs/product/import/csv/backup', 'tmp/test-%Y-%m-%d.zip');
230 230
 
231
-		if( copy( __DIR__ . '/_testfiles/import.zip', 'tmp/import.zip' ) === false ) {
232
-			throw new \RuntimeException( 'Unable to copy test file' );
231
+		if (copy(__DIR__ . '/_testfiles/import.zip', 'tmp/import.zip') === false) {
232
+			throw new \RuntimeException('Unable to copy test file');
233 233
 		}
234 234
 
235 235
 		$this->object->run();
236 236
 
237
-		$filename = strftime( 'tmp/test-%Y-%m-%d.zip' );
238
-		$this->assertTrue( file_exists( $filename ) );
237
+		$filename = strftime('tmp/test-%Y-%m-%d.zip');
238
+		$this->assertTrue(file_exists($filename));
239 239
 
240
-		unlink( $filename );
240
+		unlink($filename);
241 241
 	}
242 242
 
243 243
 
244 244
 	public function testRunBackupInvalid()
245 245
 	{
246 246
 		$config = $this->context->getConfig();
247
-		$config->set( 'controller/jobs/product/import/csv/container/type', 'Zip' );
248
-		$config->set( 'controller/jobs/product/import/csv/location', 'tmp/import.zip' );
249
-		$config->set( 'controller/jobs/product/import/csv/backup', 'tmp/notexist/import.zip' );
247
+		$config->set('controller/jobs/product/import/csv/container/type', 'Zip');
248
+		$config->set('controller/jobs/product/import/csv/location', 'tmp/import.zip');
249
+		$config->set('controller/jobs/product/import/csv/backup', 'tmp/notexist/import.zip');
250 250
 
251
-		if( copy( __DIR__ . '/_testfiles/import.zip', 'tmp/import.zip' ) === false ) {
252
-			throw new \RuntimeException( 'Unable to copy test file' );
251
+		if (copy(__DIR__ . '/_testfiles/import.zip', 'tmp/import.zip') === false) {
252
+			throw new \RuntimeException('Unable to copy test file');
253 253
 		}
254 254
 
255
-		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
255
+		$this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception');
256 256
 		$this->object->run();
257 257
 	}
258 258
 
259 259
 
260
-	protected function delete( array $prodcodes, array $delete, array $nondelete )
260
+	protected function delete(array $prodcodes, array $delete, array $nondelete)
261 261
 	{
262
-		$catListManager = \Aimeos\MShop\Catalog\Manager\Factory::create( $this->context )->getSubmanager( 'lists' );
263
-		$productManager = \Aimeos\MShop\Product\Manager\Factory::create( $this->context );
264
-		$listManager = $productManager->getSubManager( 'lists' );
262
+		$catListManager = \Aimeos\MShop\Catalog\Manager\Factory::create($this->context)->getSubmanager('lists');
263
+		$productManager = \Aimeos\MShop\Product\Manager\Factory::create($this->context);
264
+		$listManager = $productManager->getSubManager('lists');
265 265
 
266
-		foreach( $this->get( $prodcodes, $delete + $nondelete ) as $id => $product )
266
+		foreach ($this->get($prodcodes, $delete + $nondelete) as $id => $product)
267 267
 		{
268
-			foreach( $delete as $domain )
268
+			foreach ($delete as $domain)
269 269
 			{
270
-				$manager = \Aimeos\MShop::create( $this->context, $domain );
270
+				$manager = \Aimeos\MShop::create($this->context, $domain);
271 271
 
272
-				foreach( $product->getListItems( $domain ) as $listItem )
272
+				foreach ($product->getListItems($domain) as $listItem)
273 273
 				{
274
-					$manager->deleteItem( $listItem->getRefItem()->getId() );
275
-					$listManager->deleteItem( $listItem->getId() );
274
+					$manager->deleteItem($listItem->getRefItem()->getId());
275
+					$listManager->deleteItem($listItem->getId());
276 276
 				}
277 277
 			}
278 278
 
279
-			foreach( $nondelete as $domain )
279
+			foreach ($nondelete as $domain)
280 280
 			{
281
-				$ids = array_keys( $product->getListItems( $domain ) );
282
-				$listManager->deleteItems( $ids );
281
+				$ids = array_keys($product->getListItems($domain));
282
+				$listManager->deleteItems($ids);
283 283
 			}
284 284
 
285
-			$productManager->deleteItem( $product->getId() );
285
+			$productManager->deleteItem($product->getId());
286 286
 
287 287
 			$search = $catListManager->createSearch();
288
-			$search->setConditions( $search->compare( '==', 'catalog.lists.refid', $id ) );
289
-			$result = $catListManager->searchItems( $search );
288
+			$search->setConditions($search->compare('==', 'catalog.lists.refid', $id));
289
+			$result = $catListManager->searchItems($search);
290 290
 
291
-			$catListManager->deleteItems( array_keys( $result ) );
291
+			$catListManager->deleteItems(array_keys($result));
292 292
 		}
293 293
 
294 294
 
295
-		$attrManager = \Aimeos\MShop\Attribute\Manager\Factory::create( $this->context );
295
+		$attrManager = \Aimeos\MShop\Attribute\Manager\Factory::create($this->context);
296 296
 
297 297
 		$search = $attrManager->createSearch();
298
-		$search->setConditions( $search->compare( '==', 'attribute.code', 'import-test' ) );
298
+		$search->setConditions($search->compare('==', 'attribute.code', 'import-test'));
299 299
 
300
-		$result = $attrManager->searchItems( $search );
300
+		$result = $attrManager->searchItems($search);
301 301
 
302
-		$attrManager->deleteItems( array_keys( $result ) );
302
+		$attrManager->deleteItems(array_keys($result));
303 303
 	}
304 304
 
305 305
 
306
-	protected function get( array $prodcodes, array $domains )
306
+	protected function get(array $prodcodes, array $domains)
307 307
 	{
308
-		$productManager = \Aimeos\MShop\Product\Manager\Factory::create( $this->context );
308
+		$productManager = \Aimeos\MShop\Product\Manager\Factory::create($this->context);
309 309
 
310 310
 		$search = $productManager->createSearch();
311
-		$search->setConditions( $search->compare( '==', 'product.code', $prodcodes ) );
311
+		$search->setConditions($search->compare('==', 'product.code', $prodcodes));
312 312
 
313
-		return $productManager->searchItems( $search, $domains );
313
+		return $productManager->searchItems($search, $domains);
314 314
 	}
315 315
 
316 316
 
317
-	protected function getProperties( array $prodids )
317
+	protected function getProperties(array $prodids)
318 318
 	{
319
-		$manager = \Aimeos\MShop\Product\Manager\Factory::create( $this->context )->getSubManager( 'property' );
319
+		$manager = \Aimeos\MShop\Product\Manager\Factory::create($this->context)->getSubManager('property');
320 320
 
321 321
 		$search = $manager->createSearch();
322
-		$search->setConditions( $search->compare( '==', 'product.property.parentid', $prodids ) );
323
-		$search->setSortations( array( $search->sort( '+', 'product.property.type' ) ) );
322
+		$search->setConditions($search->compare('==', 'product.property.parentid', $prodids));
323
+		$search->setSortations(array($search->sort('+', 'product.property.type')));
324 324
 
325
-		return $manager->searchItems( $search );
325
+		return $manager->searchItems($search);
326 326
 	}
327 327
 }
328 328
\ No newline at end of file
Please login to merge, or discard this patch.
jobs/tests/Controller/Jobs/Subscription/Export/Csv/StandardTest.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -20,95 +20,95 @@
 block discarded – undo
20 20
 		$this->context = \TestHelperJobs::getContext();
21 21
 		$aimeos = \TestHelperJobs::getAimeos();
22 22
 
23
-		$this->object = new \Aimeos\Controller\Jobs\Subscription\Export\Csv\Standard( $this->context, $aimeos );
23
+		$this->object = new \Aimeos\Controller\Jobs\Subscription\Export\Csv\Standard($this->context, $aimeos);
24 24
 	}
25 25
 
26 26
 
27 27
 	protected function tearDown()
28 28
 	{
29
-		unset( $this->object, $this->context );
29
+		unset($this->object, $this->context);
30 30
 	}
31 31
 
32 32
 
33 33
 	public function testGetName()
34 34
 	{
35
-		$this->assertEquals( 'Subscription export CSV', $this->object->getName() );
35
+		$this->assertEquals('Subscription export CSV', $this->object->getName());
36 36
 	}
37 37
 
38 38
 
39 39
 	public function testGetDescription()
40 40
 	{
41
-		$this->assertEquals( 'Exports subscriptions to CSV file', $this->object->getDescription() );
41
+		$this->assertEquals('Exports subscriptions to CSV file', $this->object->getDescription());
42 42
 	}
43 43
 
44 44
 
45 45
 	public function testRun()
46 46
 	{
47
-		$mqmStub = $this->getMockBuilder( '\\Aimeos\\MW\\MQueue\\Manager\\Standard' )
48
-			->setConstructorArgs( [$this->context->getConfig()] )
49
-			->setMethods( ['get'] )
47
+		$mqmStub = $this->getMockBuilder('\\Aimeos\\MW\\MQueue\\Manager\\Standard')
48
+			->setConstructorArgs([$this->context->getConfig()])
49
+			->setMethods(['get'])
50 50
 			->getMock();
51 51
 
52
-		$mqStub = $this->getMockBuilder( '\\Aimeos\\MW\\MQueue\\Standard' )
52
+		$mqStub = $this->getMockBuilder('\\Aimeos\\MW\\MQueue\\Standard')
53 53
 			->disableOriginalConstructor()
54
-			->setMethods( ['getQueue'] )
54
+			->setMethods(['getQueue'])
55 55
 			->getMock();
56 56
 
57
-		$queueStub = $this->getMockBuilder( '\\Aimeos\\MW\\MQueue\\Queue\\Standard' )
57
+		$queueStub = $this->getMockBuilder('\\Aimeos\\MW\\MQueue\\Queue\\Standard')
58 58
 			->disableOriginalConstructor()
59
-			->setMethods( ['del', 'get'] )
59
+			->setMethods(['del', 'get'])
60 60
 			->getMock();
61 61
 
62
-		$msgStub = $this->getMockBuilder( '\\Aimeos\\MW\\MQueue\\Message\\Standard' )
62
+		$msgStub = $this->getMockBuilder('\\Aimeos\\MW\\MQueue\\Message\\Standard')
63 63
 			->disableOriginalConstructor()
64
-			->setMethods( ['getBody'] )
64
+			->setMethods(['getBody'])
65 65
 			->getMock();
66 66
 
67 67
 
68
-		$this->context->setMessageQueueManager( $mqmStub );
68
+		$this->context->setMessageQueueManager($mqmStub);
69 69
 
70 70
 
71
-		$mqmStub->expects( $this->once() )->method( 'get' )
72
-			->will( $this->returnValue( $mqStub ) );
71
+		$mqmStub->expects($this->once())->method('get')
72
+			->will($this->returnValue($mqStub));
73 73
 
74
-		$mqStub->expects( $this->once() )->method( 'getQueue' )
75
-			->will( $this->returnValue( $queueStub ) );
74
+		$mqStub->expects($this->once())->method('getQueue')
75
+			->will($this->returnValue($queueStub));
76 76
 
77
-		$queueStub->expects( $this->exactly( 2 ) )->method( 'get' )
78
-			->will( $this->onConsecutiveCalls( $msgStub, null ) );
77
+		$queueStub->expects($this->exactly(2))->method('get')
78
+			->will($this->onConsecutiveCalls($msgStub, null));
79 79
 
80
-		$queueStub->expects( $this->once() )->method( 'del' );
80
+		$queueStub->expects($this->once())->method('del');
81 81
 
82
-		$msgStub->expects( $this->once() )->method( 'getBody' )
83
-			->will( $this->returnValue( '{"sitecode":"unittest"}' ) );
82
+		$msgStub->expects($this->once())->method('getBody')
83
+			->will($this->returnValue('{"sitecode":"unittest"}'));
84 84
 
85 85
 
86 86
 		$this->object->run();
87 87
 
88 88
 
89
-		$jobManager = \Aimeos\MAdmin::create( $this->context, 'job' );
89
+		$jobManager = \Aimeos\MAdmin::create($this->context, 'job');
90 90
 		$jobSearch = $jobManager->createSearch();
91
-		$jobSearch->setConditions( $jobSearch->compare( '=~', 'job.label', 'subscription-export_' ) );
92
-		$jobItems = $jobManager->searchItems( $jobSearch );
93
-		$jobManager->deleteItems( array_keys( $jobItems ) );
91
+		$jobSearch->setConditions($jobSearch->compare('=~', 'job.label', 'subscription-export_'));
92
+		$jobItems = $jobManager->searchItems($jobSearch);
93
+		$jobManager->deleteItems(array_keys($jobItems));
94 94
 
95
-		$this->assertEquals( 1, count( $jobItems ) );
95
+		$this->assertEquals(1, count($jobItems));
96 96
 
97 97
 
98
-		$filename = dirname( dirname( dirname( dirname( dirname( __DIR__ ) ) ) ) ) . '/tmp/' . reset( $jobItems )->getLabel();
99
-		$fp = fopen( $filename, 'r' );
98
+		$filename = dirname(dirname(dirname(dirname(dirname(__DIR__))))) . '/tmp/' . reset($jobItems)->getLabel();
99
+		$fp = fopen($filename, 'r');
100 100
 
101
-		$subscription = fgetcsv( $fp );
102
-		$address1 = fgetcsv( $fp );
103
-		$address2 = fgetcsv( $fp );
104
-		$product1 = fgetcsv( $fp );
101
+		$subscription = fgetcsv($fp);
102
+		$address1 = fgetcsv($fp);
103
+		$address2 = fgetcsv($fp);
104
+		$product1 = fgetcsv($fp);
105 105
 
106
-		fclose( $fp );
107
-		unlink( $filename );
106
+		fclose($fp);
107
+		unlink($filename);
108 108
 
109
-		$this->assertEquals( 'subscription', $subscription[0] );
110
-		$this->assertEquals( 'address', $address1[0] );
111
-		$this->assertEquals( 'address', $address2[0] );
112
-		$this->assertEquals( 'product', $product1[0] );
109
+		$this->assertEquals('subscription', $subscription[0]);
110
+		$this->assertEquals('address', $address1[0]);
111
+		$this->assertEquals('address', $address2[0]);
112
+		$this->assertEquals('product', $product1[0]);
113 113
 	}
114 114
 }
Please login to merge, or discard this patch.
jobs/tests/Controller/Jobs/Subscription/Process/End/StandardTest.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -20,49 +20,49 @@  discard block
 block discarded – undo
20 20
 		$aimeos = \TestHelperJobs::getAimeos();
21 21
 		$this->context = \TestHelperJobs::getContext();
22 22
 
23
-		$this->object = new \Aimeos\Controller\Jobs\Subscription\Process\End\Standard( $this->context, $aimeos );
23
+		$this->object = new \Aimeos\Controller\Jobs\Subscription\Process\End\Standard($this->context, $aimeos);
24 24
 
25
-		\Aimeos\MShop::cache( true );
25
+		\Aimeos\MShop::cache(true);
26 26
 	}
27 27
 
28 28
 
29 29
 	protected function tearDown()
30 30
 	{
31
-		\Aimeos\MShop::cache( false );
31
+		\Aimeos\MShop::cache(false);
32 32
 		\Aimeos\MShop::clear();
33 33
 
34
-		unset( $this->object, $this->context );
34
+		unset($this->object, $this->context);
35 35
 	}
36 36
 
37 37
 
38 38
 	public function testGetName()
39 39
 	{
40
-		$this->assertEquals( 'Subscription process end', $this->object->getName() );
40
+		$this->assertEquals('Subscription process end', $this->object->getName());
41 41
 	}
42 42
 
43 43
 
44 44
 	public function testGetDescription()
45 45
 	{
46
-		$this->assertEquals( 'Terminates expired subscriptions', $this->object->getDescription() );
46
+		$this->assertEquals('Terminates expired subscriptions', $this->object->getDescription());
47 47
 	}
48 48
 
49 49
 
50 50
 	public function testRun()
51 51
 	{
52
-		$this->context->getConfig()->set( 'controller/common/subscription/process/processors', ['cgroup'] );
52
+		$this->context->getConfig()->set('controller/common/subscription/process/processors', ['cgroup']);
53 53
 		$item = $this->getSubscription();
54 54
 
55
-		$managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Subscription\\Manager\\Standard' )
56
-			->setConstructorArgs( [$this->context] )
57
-			->setMethods( ['searchItems', 'saveItem'] )
55
+		$managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Subscription\\Manager\\Standard')
56
+			->setConstructorArgs([$this->context])
57
+			->setMethods(['searchItems', 'saveItem'])
58 58
 			->getMock();
59 59
 
60
-		\Aimeos\MShop::inject( $this->context, 'subscription', $managerStub );
60
+		\Aimeos\MShop::inject($this->context, 'subscription', $managerStub);
61 61
 
62
-		$managerStub->expects( $this->once() )->method( 'searchItems' )
63
-			->will( $this->returnValue( [$item] ) );
62
+		$managerStub->expects($this->once())->method('searchItems')
63
+			->will($this->returnValue([$item]));
64 64
 
65
-		$managerStub->expects( $this->once() )->method( 'saveItem' );
65
+		$managerStub->expects($this->once())->method('saveItem');
66 66
 
67 67
 		$this->object->run();
68 68
 	}
@@ -70,20 +70,20 @@  discard block
 block discarded – undo
70 70
 
71 71
 	public function testRunException()
72 72
 	{
73
-		$this->context->getConfig()->set( 'controller/common/subscription/process/processors', ['cgroup'] );
74
-		$this->context->getConfig()->set( 'controller/common/subscription/process/processor/cgroup/groupids', ['1'] );
73
+		$this->context->getConfig()->set('controller/common/subscription/process/processors', ['cgroup']);
74
+		$this->context->getConfig()->set('controller/common/subscription/process/processor/cgroup/groupids', ['1']);
75 75
 
76
-		$managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Subscription\\Manager\\Standard' )
77
-			->setConstructorArgs( [$this->context] )
78
-			->setMethods( ['searchItems', 'saveItem'] )
76
+		$managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Subscription\\Manager\\Standard')
77
+			->setConstructorArgs([$this->context])
78
+			->setMethods(['searchItems', 'saveItem'])
79 79
 			->getMock();
80 80
 
81
-		\Aimeos\MShop::inject( $this->context, 'subscription', $managerStub );
81
+		\Aimeos\MShop::inject($this->context, 'subscription', $managerStub);
82 82
 
83
-		$managerStub->expects( $this->once() )->method( 'searchItems' )
84
-			->will( $this->returnValue( [$managerStub->createItem()] ) );
83
+		$managerStub->expects($this->once())->method('searchItems')
84
+			->will($this->returnValue([$managerStub->createItem()]));
85 85
 
86
-		$managerStub->expects( $this->never() )->method( 'saveItem' );
86
+		$managerStub->expects($this->never())->method('saveItem');
87 87
 
88 88
 		$this->object->run();
89 89
 	}
@@ -91,17 +91,17 @@  discard block
 block discarded – undo
91 91
 
92 92
 	protected function getSubscription()
93 93
 	{
94
-		$manager = \Aimeos\MShop::create( $this->context, 'subscription' );
94
+		$manager = \Aimeos\MShop::create($this->context, 'subscription');
95 95
 
96 96
 		$search = $manager->createSearch();
97
-		$search->setConditions( $search->compare( '==', 'subscription.dateend', '2010-01-01' ) );
97
+		$search->setConditions($search->compare('==', 'subscription.dateend', '2010-01-01'));
98 98
 
99
-		$items = $manager->searchItems( $search );
99
+		$items = $manager->searchItems($search);
100 100
 
101
-		if( ( $item = reset( $items ) ) !== false ) {
101
+		if (($item = reset($items)) !== false) {
102 102
 			return $item;
103 103
 		}
104 104
 
105
-		throw new \Exception( 'No subscription item found' );
105
+		throw new \Exception('No subscription item found');
106 106
 	}
107 107
 }
Please login to merge, or discard this patch.