Completed
Push — master ( 0b1729...545b8f )
by Aimeos
01:57
created
controller/jobs/tests/Controller/Jobs/Index/Optimize/StandardTest.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 		$context = \TestHelperJobs::getContext();
25 25
 		$aimeos = \TestHelperJobs::getAimeos();
26 26
 
27
-		$this->object = new \Aimeos\Controller\Jobs\Index\Optimize\Standard( $context, $aimeos );
27
+		$this->object = new \Aimeos\Controller\Jobs\Index\Optimize\Standard($context, $aimeos);
28 28
 	}
29 29
 
30 30
 
@@ -42,14 +42,14 @@  discard block
 block discarded – undo
42 42
 
43 43
 	public function testGetName()
44 44
 	{
45
-		$this->assertEquals( 'Index optimization', $this->object->getName() );
45
+		$this->assertEquals('Index optimization', $this->object->getName());
46 46
 	}
47 47
 
48 48
 
49 49
 	public function testGetDescription()
50 50
 	{
51 51
 		$text = 'Optimizes the index for searching products faster';
52
-		$this->assertEquals( $text, $this->object->getDescription() );
52
+		$this->assertEquals($text, $this->object->getDescription());
53 53
 	}
54 54
 
55 55
 
@@ -60,21 +60,21 @@  discard block
 block discarded – undo
60 60
 
61 61
 
62 62
 		$name = 'ControllerJobsCatalogIndexOptimizeDefaultRun';
63
-		$context->getConfig()->set( 'mshop/index/manager/name', $name );
63
+		$context->getConfig()->set('mshop/index/manager/name', $name);
64 64
 
65 65
 
66
-		$indexManagerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Index\\Manager\\Standard' )
67
-			->setMethods( array( 'optimize' ) )
68
-			->setConstructorArgs( array( $context ) )
66
+		$indexManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Index\\Manager\\Standard')
67
+			->setMethods(array('optimize'))
68
+			->setConstructorArgs(array($context))
69 69
 			->getMock();
70 70
 
71
-		\Aimeos\MShop\Catalog\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Index\\Manager\\' . $name, $indexManagerStub );
71
+		\Aimeos\MShop\Catalog\Manager\Factory::injectManager('\\Aimeos\\MShop\\Index\\Manager\\' . $name, $indexManagerStub);
72 72
 
73 73
 
74
-		$indexManagerStub->expects( $this->once() )->method( 'optimize' );
74
+		$indexManagerStub->expects($this->once())->method('optimize');
75 75
 
76 76
 
77
-		$object = new \Aimeos\Controller\Jobs\Index\Optimize\Standard( $context, $aimeos );
77
+		$object = new \Aimeos\Controller\Jobs\Index\Optimize\Standard($context, $aimeos);
78 78
 		$object->run();
79 79
 	}
80 80
 }
Please login to merge, or discard this patch.
controller/jobs/tests/Controller/Jobs/Index/Rebuild/StandardTest.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 		$context = \TestHelperJobs::getContext();
25 25
 		$aimeos = \TestHelperJobs::getAimeos();
26 26
 
27
-		$this->object = new \Aimeos\Controller\Jobs\Index\Rebuild\Standard( $context, $aimeos );
27
+		$this->object = new \Aimeos\Controller\Jobs\Index\Rebuild\Standard($context, $aimeos);
28 28
 	}
29 29
 
30 30
 
@@ -42,14 +42,14 @@  discard block
 block discarded – undo
42 42
 
43 43
 	public function testGetName()
44 44
 	{
45
-		$this->assertEquals( 'Index rebuild', $this->object->getName() );
45
+		$this->assertEquals('Index rebuild', $this->object->getName());
46 46
 	}
47 47
 
48 48
 
49 49
 	public function testGetDescription()
50 50
 	{
51 51
 		$text = 'Rebuilds the index for searching products';
52
-		$this->assertEquals( $text, $this->object->getDescription() );
52
+		$this->assertEquals($text, $this->object->getDescription());
53 53
 	}
54 54
 
55 55
 
@@ -60,22 +60,22 @@  discard block
 block discarded – undo
60 60
 
61 61
 
62 62
 		$name = 'ControllerJobsCatalogIndexRebuildDefaultRun';
63
-		$context->getConfig()->set( 'mshop/index/manager/name', $name );
63
+		$context->getConfig()->set('mshop/index/manager/name', $name);
64 64
 
65 65
 
66
-		$indexManagerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Index\\Manager\\Standard' )
67
-			->setMethods( array( 'rebuildIndex', 'cleanupIndex' ) )
68
-			->setConstructorArgs( array( $context ) )
66
+		$indexManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Index\\Manager\\Standard')
67
+			->setMethods(array('rebuildIndex', 'cleanupIndex'))
68
+			->setConstructorArgs(array($context))
69 69
 			->getMock();
70 70
 
71
-		\Aimeos\MShop\Catalog\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Index\\Manager\\' . $name, $indexManagerStub );
71
+		\Aimeos\MShop\Catalog\Manager\Factory::injectManager('\\Aimeos\\MShop\\Index\\Manager\\' . $name, $indexManagerStub);
72 72
 
73 73
 
74
-		$indexManagerStub->expects( $this->once() )->method( 'rebuildIndex' );
75
-		$indexManagerStub->expects( $this->once() )->method( 'cleanupIndex' );
74
+		$indexManagerStub->expects($this->once())->method('rebuildIndex');
75
+		$indexManagerStub->expects($this->once())->method('cleanupIndex');
76 76
 
77 77
 
78
-		$object = new \Aimeos\Controller\Jobs\Index\Rebuild\Standard( $context, $aimeos );
78
+		$object = new \Aimeos\Controller\Jobs\Index\Rebuild\Standard($context, $aimeos);
79 79
 		$object->run();
80 80
 	}
81 81
 }
Please login to merge, or discard this patch.
controller/jobs/tests/Controller/Jobs/Media/Scale/StandardTest.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 		$context = \TestHelperJobs::getContext();
20 20
 		$aimeos = \TestHelperJobs::getAimeos();
21 21
 
22
-		$this->object = new \Aimeos\Controller\Jobs\Media\Scale\Standard( $context, $aimeos );
22
+		$this->object = new \Aimeos\Controller\Jobs\Media\Scale\Standard($context, $aimeos);
23 23
 	}
24 24
 
25 25
 
@@ -31,14 +31,14 @@  discard block
 block discarded – undo
31 31
 
32 32
 	public function testGetName()
33 33
 	{
34
-		$this->assertEquals( 'Rescale product images', $this->object->getName() );
34
+		$this->assertEquals('Rescale product images', $this->object->getName());
35 35
 	}
36 36
 
37 37
 
38 38
 	public function testGetDescription()
39 39
 	{
40 40
 		$text = 'Rescales product images to the new sizes';
41
-		$this->assertEquals( $text, $this->object->getDescription() );
41
+		$this->assertEquals($text, $this->object->getDescription());
42 42
 	}
43 43
 
44 44
 
@@ -49,31 +49,31 @@  discard block
 block discarded – undo
49 49
 
50 50
 
51 51
 		$name = 'ControllerJobsMediaScaleStandardRun';
52
-		$context->getConfig()->set( 'mshop/media/manager/name', $name );
53
-		$context->getConfig()->set( 'controller/common/media/name', $name );
52
+		$context->getConfig()->set('mshop/media/manager/name', $name);
53
+		$context->getConfig()->set('controller/common/media/name', $name);
54 54
 
55 55
 
56
-		$managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Media\\Manager\\Standard' )
57
-			->setMethods( array( 'saveItem' ) )
58
-			->setConstructorArgs( array( $context ) )
56
+		$managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Media\\Manager\\Standard')
57
+			->setMethods(array('saveItem'))
58
+			->setConstructorArgs(array($context))
59 59
 			->getMock();
60 60
 
61
-		\Aimeos\MShop\Media\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Media\\Manager\\' . $name, $managerStub );
61
+		\Aimeos\MShop\Media\Manager\Factory::injectManager('\\Aimeos\\MShop\\Media\\Manager\\' . $name, $managerStub);
62 62
 
63
-		$managerStub->expects( $this->atLeast( 1 ) )->method( 'saveItem' );
63
+		$managerStub->expects($this->atLeast(1))->method('saveItem');
64 64
 
65 65
 
66
-		$cntlStub = $this->getMockBuilder( '\\Aimeos\\Controller\\Common\\Media\\Standard' )
67
-			->setMethods( array( 'scale' ) )
68
-			->setConstructorArgs( array( $context ) )
66
+		$cntlStub = $this->getMockBuilder('\\Aimeos\\Controller\\Common\\Media\\Standard')
67
+			->setMethods(array('scale'))
68
+			->setConstructorArgs(array($context))
69 69
 			->getMock();
70 70
 
71
-		\Aimeos\Controller\Common\Media\Factory::injectController( '\\Aimeos\\Controller\\Common\\Media\\' . $name, $cntlStub );
71
+		\Aimeos\Controller\Common\Media\Factory::injectController('\\Aimeos\\Controller\\Common\\Media\\' . $name, $cntlStub);
72 72
 
73
-		$cntlStub->expects( $this->atLeast( 1 ) )->method( 'scale' );
73
+		$cntlStub->expects($this->atLeast(1))->method('scale');
74 74
 
75 75
 
76
-		$object = new \Aimeos\Controller\Jobs\Media\Scale\Standard( $context, $aimeos );
76
+		$object = new \Aimeos\Controller\Jobs\Media\Scale\Standard($context, $aimeos);
77 77
 		$object->run();
78 78
 	}
79 79
 }
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Product/Import/Csv/Standard.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -351,8 +351,7 @@  discard block
 block discarded – undo
351 351
 			}
352 352
 
353 353
 			$container->close();
354
-		}
355
-		catch( \Exception $e )
354
+		} catch( \Exception $e )
356 355
 		{
357 356
 			$logger->log( 'Product import error: ' . $e->getMessage() );
358 357
 			$logger->log( $e->getTraceAsString() );
@@ -540,8 +539,7 @@  discard block
 block discarded – undo
540 539
 				}
541 540
 
542 541
 				$manager->commit();
543
-			}
544
-			catch( \Exception $e )
542
+			} catch( \Exception $e )
545 543
 			{
546 544
 				$manager->rollback();
547 545
 
Please login to merge, or discard this patch.
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
30 30
 	 * @param \Aimeos\MShop\Context\Item\Iface $context MShop context object
31 31
 	 * @param \Aimeos\Bootstrap $aimeos \Aimeos\Bootstrap main object
32 32
 	 */
33
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos )
33
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos)
34 34
 	{
35
-		parent::__construct( $context, $aimeos );
35
+		parent::__construct($context, $aimeos);
36 36
 
37
-		$manager = \Aimeos\MShop::create( $context, 'product/type' );
38
-		$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
37
+		$manager = \Aimeos\MShop::create($context, 'product/type');
38
+		$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
39 39
 
40
-		foreach( $manager->searchItems( $search ) as $item ) {
40
+		foreach ($manager->searchItems($search) as $item) {
41 41
 			$this->types[$item->getCode()] = $item->getCode();
42 42
 		}
43 43
 	}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	public function getName()
52 52
 	{
53
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Product import CSV' );
53
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Product import CSV');
54 54
 	}
55 55
 
56 56
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	 */
62 62
 	public function getDescription()
63 63
 	{
64
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Imports new and updates existing products from CSV files' );
64
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Imports new and updates existing products from CSV files');
65 65
 	}
66 66
 
67 67
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 		$context = $this->getContext();
77 77
 		$config = $context->getConfig();
78 78
 		$logger = $context->getLogger();
79
-		$domains = array( 'attribute', 'media', 'price', 'product', 'product/property', 'text' );
79
+		$domains = array('attribute', 'media', 'price', 'product', 'product/property', 'text');
80 80
 		$mappings = $this->getDefaultMapping();
81 81
 
82 82
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 		 * @see controller/common/product/import/csv/converter
97 97
 		 * @see controller/common/product/import/csv/max-size
98 98
 		 */
99
-		$domains = $config->get( 'controller/common/product/import/csv/domains', $domains );
99
+		$domains = $config->get('controller/common/product/import/csv/domains', $domains);
100 100
 
101 101
 		/** controller/jobs/product/import/csv/domains
102 102
 		 * List of item domain names that should be retrieved along with the product items
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 		 * @see controller/jobs/product/import/csv/backup
117 117
 		 * @see controller/common/product/import/csv/max-size
118 118
 		 */
119
-		$domains = $config->get( 'controller/jobs/product/import/csv/domains', $domains );
119
+		$domains = $config->get('controller/jobs/product/import/csv/domains', $domains);
120 120
 
121 121
 
122 122
 		/** controller/common/product/import/csv/mapping
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 		 * @see controller/common/product/import/csv/converter
142 142
 		 * @see controller/common/product/import/csv/max-size
143 143
 		 */
144
-		$mappings = $config->get( 'controller/common/product/import/csv/mapping', $mappings );
144
+		$mappings = $config->get('controller/common/product/import/csv/mapping', $mappings);
145 145
 
146 146
 		/** controller/jobs/product/import/csv/mapping
147 147
 		 * List of mappings between the position in the CSV file and item keys
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 		 * @see controller/jobs/product/import/csv/backup
162 162
 		 * @see controller/common/product/import/csv/max-size
163 163
 		 */
164
-		$mappings = $config->get( 'controller/jobs/product/import/csv/mapping', $mappings );
164
+		$mappings = $config->get('controller/jobs/product/import/csv/mapping', $mappings);
165 165
 
166 166
 
167 167
 		/** controller/common/product/import/csv/converter
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 		 * @see controller/common/product/import/csv/mapping
204 204
 		 * @see controller/common/product/import/csv/max-size
205 205
 		 */
206
-		$converters = $config->get( 'controller/common/product/import/csv/converter', [] );
206
+		$converters = $config->get('controller/common/product/import/csv/converter', []);
207 207
 
208 208
 		/** controller/jobs/product/import/csv/converter
209 209
 		 * List of converter names for the values at the position in the CSV file
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 		 * @see controller/jobs/product/import/csv/backup
224 224
 		 * @see controller/common/product/import/csv/max-size
225 225
 		 */
226
-		$converters = $config->get( 'controller/jobs/product/import/csv/converter', $converters );
226
+		$converters = $config->get('controller/jobs/product/import/csv/converter', $converters);
227 227
 
228 228
 
229 229
 		/** controller/common/product/import/csv/max-size
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 		 * @see controller/common/product/import/csv/mapping
244 244
 		 * @see controller/common/product/import/csv/converter
245 245
 		 */
246
-		$maxcnt = (int) $config->get( 'controller/common/product/import/csv/max-size', 1000 );
246
+		$maxcnt = (int) $config->get('controller/common/product/import/csv/max-size', 1000);
247 247
 
248 248
 
249 249
 		/** controller/jobs/product/import/csv/skip-lines
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 		 * @see controller/jobs/product/import/csv/backup
266 266
 		 * @see controller/common/product/import/csv/max-size
267 267
 		 */
268
-		$skiplines = (int) $config->get( 'controller/jobs/product/import/csv/skip-lines', 0 );
268
+		$skiplines = (int) $config->get('controller/jobs/product/import/csv/skip-lines', 0);
269 269
 
270 270
 
271 271
 		/** controller/jobs/product/import/csv/strict
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 		 * @see controller/jobs/product/import/csv/backup
290 290
 		 * @see controller/common/product/import/csv/max-size
291 291
 		 */
292
-		$strict = (bool) $config->get( 'controller/jobs/product/import/csv/strict', true );
292
+		$strict = (bool) $config->get('controller/jobs/product/import/csv/strict', true);
293 293
 
294 294
 
295 295
 		/** controller/jobs/product/import/csv/backup
@@ -322,74 +322,74 @@  discard block
 block discarded – undo
322 322
 		 * @see controller/jobs/product/import/csv/strict
323 323
 		 * @see controller/common/product/import/csv/max-size
324 324
 		 */
325
-		$backup = $config->get( 'controller/jobs/product/import/csv/backup' );
325
+		$backup = $config->get('controller/jobs/product/import/csv/backup');
326 326
 
327 327
 
328
-		if( !isset( $mappings['item'] ) || !is_array( $mappings['item'] ) )
328
+		if (!isset($mappings['item']) || !is_array($mappings['item']))
329 329
 		{
330
-			$msg = sprintf( 'Required mapping key "%1$s" is missing or contains no array', 'item' );
331
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
330
+			$msg = sprintf('Required mapping key "%1$s" is missing or contains no array', 'item');
331
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
332 332
 		}
333 333
 
334 334
 		try
335 335
 		{
336 336
 			$procMappings = $mappings;
337
-			unset( $procMappings['item'] );
337
+			unset($procMappings['item']);
338 338
 
339
-			$codePos = $this->getCodePosition( $mappings['item'] );
340
-			$convlist = $this->getConverterList( $converters );
341
-			$processor = $this->getProcessors( $procMappings );
339
+			$codePos = $this->getCodePosition($mappings['item']);
340
+			$convlist = $this->getConverterList($converters);
341
+			$processor = $this->getProcessors($procMappings);
342 342
 			$container = $this->getContainer();
343 343
 			$path = $container->getName();
344 344
 
345
-			$msg = sprintf( 'Started product import from "%1$s" (%2$s)', $path, __CLASS__ );
346
-			$logger->log( $msg, \Aimeos\MW\Logger\Base::NOTICE );
345
+			$msg = sprintf('Started product import from "%1$s" (%2$s)', $path, __CLASS__);
346
+			$logger->log($msg, \Aimeos\MW\Logger\Base::NOTICE);
347 347
 
348
-			foreach( $container as $content )
348
+			foreach ($container as $content)
349 349
 			{
350 350
 				$name = $content->getName();
351 351
 
352
-				for( $i = 0; $i < $skiplines; $i++ ) {
352
+				for ($i = 0; $i < $skiplines; $i++) {
353 353
 					$content->next();
354 354
 				}
355 355
 
356
-				while( ( $data = $this->getData( $content, $maxcnt, $codePos ) ) !== [] )
356
+				while (($data = $this->getData($content, $maxcnt, $codePos)) !== [])
357 357
 				{
358
-					$data = $this->convertData( $convlist, $data );
359
-					$products = $this->getProducts( array_keys( $data ), $domains );
360
-					$errcnt = $this->import( $products, $data, $mappings['item'], $processor, $strict );
361
-					$chunkcnt = count( $data );
358
+					$data = $this->convertData($convlist, $data);
359
+					$products = $this->getProducts(array_keys($data), $domains);
360
+					$errcnt = $this->import($products, $data, $mappings['item'], $processor, $strict);
361
+					$chunkcnt = count($data);
362 362
 
363 363
 					$msg = 'Imported product lines from "%1$s": %2$d/%3$d (%4$s)';
364
-					$logger->log( sprintf( $msg, $name, $chunkcnt - $errcnt, $chunkcnt, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE );
364
+					$logger->log(sprintf($msg, $name, $chunkcnt - $errcnt, $chunkcnt, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE);
365 365
 
366 366
 					$errors += $errcnt;
367 367
 					$total += $chunkcnt;
368
-					unset( $products, $data );
368
+					unset($products, $data);
369 369
 				}
370 370
 			}
371 371
 
372 372
 			$container->close();
373 373
 		}
374
-		catch( \Exception $e )
374
+		catch (\Exception $e)
375 375
 		{
376
-			$logger->log( 'Product import error: ' . $e->getMessage() );
377
-			$logger->log( $e->getTraceAsString() );
376
+			$logger->log('Product import error: ' . $e->getMessage());
377
+			$logger->log($e->getTraceAsString());
378 378
 
379
-			throw new \Aimeos\Controller\Jobs\Exception( $e->getMessage() );
379
+			throw new \Aimeos\Controller\Jobs\Exception($e->getMessage());
380 380
 		}
381 381
 
382 382
 		$msg = 'Finished product import from "%1$s": %2$d successful, %3$s errors, %4$s total (%5$s)';
383
-		$logger->log( sprintf( $msg, $path, $total - $errors, $errors, $total, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE );
383
+		$logger->log(sprintf($msg, $path, $total - $errors, $errors, $total, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE);
384 384
 
385
-		if( $errors > 0 )
385
+		if ($errors > 0)
386 386
 		{
387
-			$msg = sprintf( 'Invalid product lines in "%1$s": %2$d/%3$d', $path, $errors, $total );
388
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
387
+			$msg = sprintf('Invalid product lines in "%1$s": %2$d/%3$d', $path, $errors, $total);
388
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
389 389
 		}
390 390
 
391
-		if( !empty( $backup ) && @rename( $path, strftime( $backup ) ) === false ) {
392
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Unable to move imported file' ) );
391
+		if (!empty($backup) && @rename($path, strftime($backup)) === false) {
392
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Unable to move imported file'));
393 393
 		}
394 394
 	}
395 395
 
@@ -401,16 +401,16 @@  discard block
 block discarded – undo
401 401
 	 * @return integer Position of the "product.code" column
402 402
 	 * @throws \Aimeos\Controller\Jobs\Exception If no mapping for "product.code" is found
403 403
 	 */
404
-	protected function getCodePosition( array $mapping )
404
+	protected function getCodePosition(array $mapping)
405 405
 	{
406
-		foreach( $mapping as $pos => $key )
406
+		foreach ($mapping as $pos => $key)
407 407
 		{
408
-			if( $key === 'product.code' ) {
408
+			if ($key === 'product.code') {
409 409
 				return $pos;
410 410
 			}
411 411
 		}
412 412
 
413
-		throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No "product.code" column in CSV mapping found' ) );
413
+		throw new \Aimeos\Controller\Jobs\Exception(sprintf('No "product.code" column in CSV mapping found'));
414 414
 	}
415 415
 
416 416
 
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 		 * @see controller/jobs/product/import/csv/container/content
446 446
 		 * @see controller/jobs/product/import/csv/container/options
447 447
 		 */
448
-		$location = $config->get( 'controller/jobs/product/import/csv/location' );
448
+		$location = $config->get('controller/jobs/product/import/csv/location');
449 449
 
450 450
 		/** controller/jobs/product/import/csv/container/type
451 451
 		 * Nave of the container type to read the data from
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 		 * @see controller/jobs/product/import/csv/container/content
469 469
 		 * @see controller/jobs/product/import/csv/container/options
470 470
 		 */
471
-		$container = $config->get( 'controller/jobs/product/import/csv/container/type', 'Directory' );
471
+		$container = $config->get('controller/jobs/product/import/csv/container/type', 'Directory');
472 472
 
473 473
 		/** controller/jobs/product/import/csv/container/content
474 474
 		 * Name of the content type inside the container to read the data from
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 		 * @see controller/jobs/product/import/csv/container/type
490 490
 		 * @see controller/jobs/product/import/csv/container/options
491 491
 		 */
492
-		$content = $config->get( 'controller/jobs/product/import/csv/container/content', 'CSV' );
492
+		$content = $config->get('controller/jobs/product/import/csv/container/content', 'CSV');
493 493
 
494 494
 		/** controller/jobs/product/import/csv/container/options
495 495
 		 * List of file container options for the product import files
@@ -507,15 +507,15 @@  discard block
 block discarded – undo
507 507
 		 * @see controller/jobs/product/import/csv/container/content
508 508
 		 * @see controller/jobs/product/import/csv/container/type
509 509
 		 */
510
-		$options = $config->get( 'controller/jobs/product/import/csv/container/options', [] );
510
+		$options = $config->get('controller/jobs/product/import/csv/container/options', []);
511 511
 
512
-		if( $location === null )
512
+		if ($location === null)
513 513
 		{
514
-			$msg = sprintf( 'Required configuration for "%1$s" is missing', 'controller/jobs/product/import/csv/location' );
515
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
514
+			$msg = sprintf('Required configuration for "%1$s" is missing', 'controller/jobs/product/import/csv/location');
515
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
516 516
 		}
517 517
 
518
-		return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options );
518
+		return \Aimeos\MW\Container\Factory::getContainer($location, $container, $content, $options);
519 519
 	}
520 520
 
521 521
 
@@ -530,68 +530,68 @@  discard block
 block discarded – undo
530 530
 	 * @return integer Number of products that couldn't be imported
531 531
 	 * @throws \Aimeos\Controller\Jobs\Exception
532 532
 	 */
533
-	protected function import( array $products, array $data, array $mapping,
534
-		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor, $strict )
533
+	protected function import(array $products, array $data, array $mapping,
534
+		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor, $strict)
535 535
 	{
536 536
 		$items = [];
537 537
 		$errors = 0;
538 538
 		$context = $this->getContext();
539
-		$manager = \Aimeos\MShop::create( $context, 'product' );
540
-		$indexManager = \Aimeos\MShop::create( $context, 'index' );
539
+		$manager = \Aimeos\MShop::create($context, 'product');
540
+		$indexManager = \Aimeos\MShop::create($context, 'index');
541 541
 
542
-		foreach( $data as $code => $list )
542
+		foreach ($data as $code => $list)
543 543
 		{
544 544
 			$manager->begin();
545 545
 
546 546
 			try
547 547
 			{
548
-				$code = trim( $code );
548
+				$code = trim($code);
549 549
 
550
-				if( isset( $products[$code] ) ) {
550
+				if (isset($products[$code])) {
551 551
 					$product = $products[$code];
552 552
 				} else {
553 553
 					$product = $manager->createItem();
554 554
 				}
555 555
 
556
-				$map = $this->getMappedChunk( $list, $mapping );
556
+				$map = $this->getMappedChunk($list, $mapping);
557 557
 
558
-				if( isset( $map[0] ) )
558
+				if (isset($map[0]))
559 559
 				{
560 560
 					$map = $map[0]; // there can only be one chunk for the base product data
561
-					$map['product.type'] = $this->getValue( $map, 'product.type', 'default' );
561
+					$map['product.type'] = $this->getValue($map, 'product.type', 'default');
562 562
 
563
-					if( !in_array( $map['product.type'], $this->types ) )
563
+					if (!in_array($map['product.type'], $this->types))
564 564
 					{
565
-						$msg = sprintf( 'Invalid product type "%1$s"', $map['product.type'] );
566
-						throw new \Aimeos\Controller\Jobs\Exception( $msg );
565
+						$msg = sprintf('Invalid product type "%1$s"', $map['product.type']);
566
+						throw new \Aimeos\Controller\Jobs\Exception($msg);
567 567
 					}
568 568
 
569
-					$product = $manager->saveItem( $product->fromArray( $map ) );
569
+					$product = $manager->saveItem($product->fromArray($map));
570 570
 
571
-					$list = $processor->process( $product, $list );
571
+					$list = $processor->process($product, $list);
572 572
 
573
-					$product = $manager->saveItem( $product );
573
+					$product = $manager->saveItem($product);
574 574
 					$items[$product->getId()] = $product;
575 575
 				}
576 576
 
577 577
 				$manager->commit();
578 578
 			}
579
-			catch( \Exception $e )
579
+			catch (\Exception $e)
580 580
 			{
581 581
 				$manager->rollback();
582 582
 
583
-				$msg = sprintf( 'Unable to import product with code "%1$s": %2$s', $code, $e->getMessage() );
584
-				$context->getLogger()->log( $msg );
583
+				$msg = sprintf('Unable to import product with code "%1$s": %2$s', $code, $e->getMessage());
584
+				$context->getLogger()->log($msg);
585 585
 
586 586
 				$errors++;
587 587
 			}
588 588
 
589
-			if( $strict && !empty( $list ) ) {
590
-				$context->getLogger()->log( 'Not imported: ' . print_r( $list, true ) );
589
+			if ($strict && !empty($list)) {
590
+				$context->getLogger()->log('Not imported: ' . print_r($list, true));
591 591
 			}
592 592
 		}
593 593
 
594
-		$indexManager->rebuildIndex( $items );
594
+		$indexManager->rebuildIndex($items);
595 595
 
596 596
 		return $errors;
597 597
 	}
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Stock/Standard.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -131,8 +131,7 @@
 block discarded – undo
131 131
 			$data = $this->getObject()->process( $product, $data );
132 132
 
133 133
 			$manager->commit();
134
-		}
135
-		catch( \Exception $e )
134
+		} catch( \Exception $e )
136 135
 		{
137 136
 			$manager->rollback();
138 137
 			throw $e;
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -42,15 +42,15 @@  discard block
 block discarded – undo
42 42
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
43 43
 	 * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor
44 44
 	 */
45
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
46
-		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null )
45
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
46
+		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null)
47 47
 	{
48
-		parent::__construct( $context, $mapping, $object );
48
+		parent::__construct($context, $mapping, $object);
49 49
 
50
-		$manager = \Aimeos\MShop::create( $context, 'stock/type' );
51
-		$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
50
+		$manager = \Aimeos\MShop::create($context, 'stock/type');
51
+		$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
52 52
 
53
-		foreach( $manager->searchItems( $search ) as $item ) {
53
+		foreach ($manager->searchItems($search) as $item) {
54 54
 			$this->types[$item->getCode()] = $item->getCode();
55 55
 		}
56 56
 	}
@@ -63,47 +63,47 @@  discard block
 block discarded – undo
63 63
 	 * @param array $data List of CSV fields with position as key and data as value
64 64
 	 * @return array List of data which hasn't been imported
65 65
 	 */
66
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
66
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
67 67
 	{
68
-		$manager = \Aimeos\MShop::create( $this->getContext(), 'stock' );
68
+		$manager = \Aimeos\MShop::create($this->getContext(), 'stock');
69 69
 		$manager->begin();
70 70
 
71 71
 		try
72 72
 		{
73
-			$map = $this->getMappedChunk( $data, $this->getMapping() );
74
-			$items = $this->getStockItems( $product->getCode() );
73
+			$map = $this->getMappedChunk($data, $this->getMapping());
74
+			$items = $this->getStockItems($product->getCode());
75 75
 
76
-			foreach( $map as $pos => $list )
76
+			foreach ($map as $pos => $list)
77 77
 			{
78
-				if( !array_key_exists( 'stock.stocklevel', $list ) ) {
78
+				if (!array_key_exists('stock.stocklevel', $list)) {
79 79
 					continue;
80 80
 				}
81 81
 
82 82
 				$list['stock.productcode'] = $product->getCode();
83
-				$list['stock.dateback'] = $this->getValue( $list, 'stock.dateback' );
84
-				$list['stock.stocklevel'] = $this->getValue( $list, 'stock.stocklevel' );
85
-				$list['stock.type'] = $this->getValue( $list, 'stock.type', 'default' );
83
+				$list['stock.dateback'] = $this->getValue($list, 'stock.dateback');
84
+				$list['stock.stocklevel'] = $this->getValue($list, 'stock.stocklevel');
85
+				$list['stock.type'] = $this->getValue($list, 'stock.type', 'default');
86 86
 
87
-				if( !in_array( $list['stock.type'], $this->types ) )
87
+				if (!in_array($list['stock.type'], $this->types))
88 88
 				{
89
-					$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $list['stock.type'], 'stock' );
90
-					throw new \Aimeos\Controller\Common\Exception( $msg );
89
+					$msg = sprintf('Invalid type "%1$s" (%2$s)', $list['stock.type'], 'stock');
90
+					throw new \Aimeos\Controller\Common\Exception($msg);
91 91
 				}
92 92
 
93
-				if( ( $item = array_pop( $items ) ) === null ) {
93
+				if (($item = array_pop($items)) === null) {
94 94
 					$item = $manager->createItem();
95 95
 				}
96 96
 
97
-				$manager->saveItem( $item->fromArray( $list ), false );
97
+				$manager->saveItem($item->fromArray($list), false);
98 98
 			}
99 99
 
100
-			$manager->deleteItems( array_keys( $items ) );
100
+			$manager->deleteItems(array_keys($items));
101 101
 
102
-			$data = $this->getObject()->process( $product, $data );
102
+			$data = $this->getObject()->process($product, $data);
103 103
 
104 104
 			$manager->commit();
105 105
 		}
106
-		catch( \Exception $e )
106
+		catch (\Exception $e)
107 107
 		{
108 108
 			$manager->rollback();
109 109
 			throw $e;
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
 	 * @param string $code Unique product code
120 120
 	 * @return \Aimeos\MShop\Stock\Item\Iface[] Associative list of stock items
121 121
 	 */
122
-	protected function getStockItems( $code )
122
+	protected function getStockItems($code)
123 123
 	{
124
-		$manager = \Aimeos\MShop::create( $this->getContext(), 'stock' );
124
+		$manager = \Aimeos\MShop::create($this->getContext(), 'stock');
125 125
 
126 126
 		$search = $manager->createSearch();
127
-		$search->setConditions( $search->compare( '==', 'stock.productcode', $code ) );
127
+		$search->setConditions($search->compare('==', 'stock.productcode', $code));
128 128
 
129
-		return $manager->searchItems( $search );
129
+		return $manager->searchItems($search);
130 130
 	}
131 131
 }
Please login to merge, or discard this patch.
controller/jobs/tests/Controller/Jobs/Admin/Log/StandardTest.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 		$this->context = \TestHelperJobs::getContext();
26 26
 		$aimeos = \TestHelperJobs::getAimeos();
27 27
 
28
-		$this->object = new \Aimeos\Controller\Jobs\Admin\Log\Standard( $this->context, $aimeos );
28
+		$this->object = new \Aimeos\Controller\Jobs\Admin\Log\Standard($this->context, $aimeos);
29 29
 	}
30 30
 
31 31
 
@@ -44,14 +44,14 @@  discard block
 block discarded – undo
44 44
 
45 45
 	public function testGetName()
46 46
 	{
47
-		$this->assertEquals( 'Log cleanup', $this->object->getName() );
47
+		$this->assertEquals('Log cleanup', $this->object->getName());
48 48
 	}
49 49
 
50 50
 
51 51
 	public function testGetDescription()
52 52
 	{
53 53
 		$text = 'Removes the old log entries from the database and archives them (optional)';
54
-		$this->assertEquals( $text, $this->object->getDescription() );
54
+		$this->assertEquals($text, $this->object->getDescription());
55 55
 	}
56 56
 
57 57
 
@@ -59,38 +59,38 @@  discard block
 block discarded – undo
59 59
 	{
60 60
 		$config = $this->context->getConfig();
61 61
 
62
-		$mock = $this->getMockBuilder( '\\Aimeos\\MAdmin\\Log\\Manager\\Standard' )
63
-			->setMethods( array( 'deleteItems' ) )
64
-			->setConstructorArgs( array( $this->context ) )
62
+		$mock = $this->getMockBuilder('\\Aimeos\\MAdmin\\Log\\Manager\\Standard')
63
+			->setMethods(array('deleteItems'))
64
+			->setConstructorArgs(array($this->context))
65 65
 			->getMock();
66 66
 
67
-		$mock->expects( $this->atLeastOnce() )->method( 'deleteItems' );
67
+		$mock->expects($this->atLeastOnce())->method('deleteItems');
68 68
 
69
-		$tmppath = dirname( dirname( dirname( dirname( __DIR__ ) ) ) ) . DIRECTORY_SEPARATOR . 'tmp';
69
+		$tmppath = dirname(dirname(dirname(dirname(__DIR__)))) . DIRECTORY_SEPARATOR . 'tmp';
70 70
 		$name = 'ControllerJobsAdminLogDefaultRun';
71
-		$config->set( 'madmin/log/manager/name', $name );
72
-		$config->set( 'controller/jobs/admin/log/standard/limit-days', 0 );
73
-		$config->set( 'controller/jobs/admin/log/standard/path', $tmppath );
71
+		$config->set('madmin/log/manager/name', $name);
72
+		$config->set('controller/jobs/admin/log/standard/limit-days', 0);
73
+		$config->set('controller/jobs/admin/log/standard/path', $tmppath);
74 74
 
75
-		\Aimeos\MAdmin\Log\Manager\Factory::injectManager( '\\Aimeos\\MAdmin\\Log\\Manager\\' . $name, $mock );
75
+		\Aimeos\MAdmin\Log\Manager\Factory::injectManager('\\Aimeos\\MAdmin\\Log\\Manager\\' . $name, $mock);
76 76
 
77
-		if( !is_dir( $tmppath ) && mkdir( $tmppath ) === false ) {
78
-			throw new \RuntimeException( sprintf( 'Unable to create temporary path "%1$s"', $tmppath ) );
77
+		if (!is_dir($tmppath) && mkdir($tmppath) === false) {
78
+			throw new \RuntimeException(sprintf('Unable to create temporary path "%1$s"', $tmppath));
79 79
 		}
80 80
 
81 81
 		$this->object->run();
82 82
 
83
-		foreach( new \DirectoryIterator( $tmppath ) as $file )
83
+		foreach (new \DirectoryIterator($tmppath) as $file)
84 84
 		{
85
-			if( $file->isFile() && $file->getExtension() === 'zip' )
85
+			if ($file->isFile() && $file->getExtension() === 'zip')
86 86
 			{
87
-				$container = \Aimeos\MW\Container\Factory::getContainer( $file->getPathName(), 'Zip', 'CSV', [] );
88
-				$container->get( 'unittest facility.csv' );
89
-				unlink( $file->getPathName() );
87
+				$container = \Aimeos\MW\Container\Factory::getContainer($file->getPathName(), 'Zip', 'CSV', []);
88
+				$container->get('unittest facility.csv');
89
+				unlink($file->getPathName());
90 90
 				return;
91 91
 			}
92 92
 		}
93 93
 
94
-		$this->fail( 'Log archive file not found' );
94
+		$this->fail('Log archive file not found');
95 95
 	}
96 96
 }
Please login to merge, or discard this patch.
jobs/tests/Controller/Jobs/Order/Service/Payment/StandardTest.php 1 patch
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 		$context = \TestHelperJobs::getContext();
25 25
 		$aimeos = \TestHelperJobs::getAimeos();
26 26
 
27
-		$this->object = new \Aimeos\Controller\Jobs\Order\Service\Payment\Standard( $context, $aimeos );
27
+		$this->object = new \Aimeos\Controller\Jobs\Order\Service\Payment\Standard($context, $aimeos);
28 28
 	}
29 29
 
30 30
 
@@ -42,14 +42,14 @@  discard block
 block discarded – undo
42 42
 
43 43
 	public function testGetName()
44 44
 	{
45
-		$this->assertEquals( 'Capture authorized payments', $this->object->getName() );
45
+		$this->assertEquals('Capture authorized payments', $this->object->getName());
46 46
 	}
47 47
 
48 48
 
49 49
 	public function testGetDescription()
50 50
 	{
51 51
 		$text = 'Authorized payments of orders will be captured after dispatching or after a configurable amount of time';
52
-		$this->assertEquals( $text, $this->object->getDescription() );
52
+		$this->assertEquals($text, $this->object->getDescription());
53 53
 	}
54 54
 
55 55
 
@@ -60,49 +60,49 @@  discard block
 block discarded – undo
60 60
 
61 61
 
62 62
 		$name = 'ControllerJobsServicePaymentProcessDefaultRun';
63
-		$context->getConfig()->set( 'mshop/service/manager/name', $name );
64
-		$context->getConfig()->set( 'mshop/order/manager/name', $name );
63
+		$context->getConfig()->set('mshop/service/manager/name', $name);
64
+		$context->getConfig()->set('mshop/order/manager/name', $name);
65 65
 
66 66
 
67
-		$serviceManagerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Service\\Manager\\Standard' )
68
-			->setMethods( array( 'getProvider', 'searchItems' ) )
69
-			->setConstructorArgs( array( $context ) )
67
+		$serviceManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Service\\Manager\\Standard')
68
+			->setMethods(array('getProvider', 'searchItems'))
69
+			->setConstructorArgs(array($context))
70 70
 			->getMock();
71 71
 
72
-		$orderManagerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Order\\Manager\\Standard' )
73
-			->setMethods( array( 'saveItem', 'searchItems' ) )
74
-			->setConstructorArgs( array( $context ) )
72
+		$orderManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Standard')
73
+			->setMethods(array('saveItem', 'searchItems'))
74
+			->setConstructorArgs(array($context))
75 75
 			->getMock();
76 76
 
77
-		\Aimeos\MShop\Service\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Service\\Manager\\' . $name, $serviceManagerStub );
78
-		\Aimeos\MShop\Order\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Order\\Manager\\' . $name, $orderManagerStub );
77
+		\Aimeos\MShop\Service\Manager\Factory::injectManager('\\Aimeos\\MShop\\Service\\Manager\\' . $name, $serviceManagerStub);
78
+		\Aimeos\MShop\Order\Manager\Factory::injectManager('\\Aimeos\\MShop\\Order\\Manager\\' . $name, $orderManagerStub);
79 79
 
80 80
 
81 81
 		$serviceItem = $serviceManagerStub->createItem();
82 82
 		$orderItem = $orderManagerStub->createItem();
83 83
 
84
-		$serviceProviderStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Service\\Provider\\Payment\\PrePay' )
85
-			->setMethods( array( 'isImplemented', 'capture' ) )
86
-			->setConstructorArgs( array( $context, $serviceItem ) )
84
+		$serviceProviderStub = $this->getMockBuilder('\\Aimeos\\MShop\\Service\\Provider\\Payment\\PrePay')
85
+			->setMethods(array('isImplemented', 'capture'))
86
+			->setConstructorArgs(array($context, $serviceItem))
87 87
 			->getMock();
88 88
 
89 89
 
90
-		$serviceManagerStub->expects( $this->once() )->method( 'searchItems' )
91
-			->will( $this->onConsecutiveCalls( array( $serviceItem ), [] ) );
90
+		$serviceManagerStub->expects($this->once())->method('searchItems')
91
+			->will($this->onConsecutiveCalls(array($serviceItem), []));
92 92
 
93
-		$serviceManagerStub->expects( $this->once() )->method( 'getProvider' )
94
-			->will( $this->returnValue( $serviceProviderStub ) );
93
+		$serviceManagerStub->expects($this->once())->method('getProvider')
94
+			->will($this->returnValue($serviceProviderStub));
95 95
 
96
-		$orderManagerStub->expects( $this->once() )->method( 'searchItems' )
97
-			->will( $this->onConsecutiveCalls( array( $orderItem ), [] ) );
96
+		$orderManagerStub->expects($this->once())->method('searchItems')
97
+			->will($this->onConsecutiveCalls(array($orderItem), []));
98 98
 
99
-		$serviceProviderStub->expects( $this->once() )->method( 'isImplemented' )
100
-			->will( $this->returnValue( true ) );
99
+		$serviceProviderStub->expects($this->once())->method('isImplemented')
100
+			->will($this->returnValue(true));
101 101
 
102
-		$serviceProviderStub->expects( $this->once() )->method( 'capture' );
102
+		$serviceProviderStub->expects($this->once())->method('capture');
103 103
 
104 104
 
105
-		$object = new \Aimeos\Controller\Jobs\Order\Service\Payment\Standard( $context, $aimeos );
105
+		$object = new \Aimeos\Controller\Jobs\Order\Service\Payment\Standard($context, $aimeos);
106 106
 		$object->run();
107 107
 	}
108 108
 
@@ -114,52 +114,52 @@  discard block
 block discarded – undo
114 114
 
115 115
 
116 116
 		$name = 'ControllerJobsServicePaymentProcessDefaultRun';
117
-		$context->getConfig()->set( 'mshop/service/manager/name', $name );
118
-		$context->getConfig()->set( 'mshop/order/manager/name', $name );
117
+		$context->getConfig()->set('mshop/service/manager/name', $name);
118
+		$context->getConfig()->set('mshop/order/manager/name', $name);
119 119
 
120 120
 
121
-		$orderManagerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Order\\Manager\\Standard' )
122
-			->setMethods( array( 'saveItem', 'searchItems' ) )
123
-			->setConstructorArgs( array( $context ) )
121
+		$orderManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Standard')
122
+			->setMethods(array('saveItem', 'searchItems'))
123
+			->setConstructorArgs(array($context))
124 124
 			->getMock();
125 125
 
126
-		$serviceManagerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Service\\Manager\\Standard' )
127
-			->setMethods( array( 'getProvider', 'searchItems' ) )
128
-			->setConstructorArgs( array( $context ) )
126
+		$serviceManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Service\\Manager\\Standard')
127
+			->setMethods(array('getProvider', 'searchItems'))
128
+			->setConstructorArgs(array($context))
129 129
 			->getMock();
130 130
 
131
-		\Aimeos\MShop\Service\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Service\\Manager\\' . $name, $serviceManagerStub );
132
-		\Aimeos\MShop\Order\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Order\\Manager\\' . $name, $orderManagerStub );
131
+		\Aimeos\MShop\Service\Manager\Factory::injectManager('\\Aimeos\\MShop\\Service\\Manager\\' . $name, $serviceManagerStub);
132
+		\Aimeos\MShop\Order\Manager\Factory::injectManager('\\Aimeos\\MShop\\Order\\Manager\\' . $name, $orderManagerStub);
133 133
 
134 134
 
135 135
 		$serviceItem = $serviceManagerStub->createItem();
136 136
 		$orderItem = $orderManagerStub->createItem();
137 137
 
138
-		$serviceProviderStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Service\\Provider\\Payment\\PrePay' )
139
-			->setMethods( array( 'isImplemented', 'capture' ) )
140
-			->setConstructorArgs( array( $context, $serviceItem ) )
138
+		$serviceProviderStub = $this->getMockBuilder('\\Aimeos\\MShop\\Service\\Provider\\Payment\\PrePay')
139
+			->setMethods(array('isImplemented', 'capture'))
140
+			->setConstructorArgs(array($context, $serviceItem))
141 141
 			->getMock();
142 142
 
143 143
 
144
-		$serviceManagerStub->expects( $this->once() )->method( 'searchItems' )
145
-			->will( $this->onConsecutiveCalls( array( $serviceItem ), [] ) );
144
+		$serviceManagerStub->expects($this->once())->method('searchItems')
145
+			->will($this->onConsecutiveCalls(array($serviceItem), []));
146 146
 
147
-		$serviceManagerStub->expects( $this->once() )->method( 'getProvider' )
148
-			->will( $this->returnValue( $serviceProviderStub ) );
147
+		$serviceManagerStub->expects($this->once())->method('getProvider')
148
+			->will($this->returnValue($serviceProviderStub));
149 149
 
150
-		$orderManagerStub->expects( $this->once() )->method( 'searchItems' )
151
-			->will( $this->onConsecutiveCalls( array( $orderItem ), [] ) );
150
+		$orderManagerStub->expects($this->once())->method('searchItems')
151
+			->will($this->onConsecutiveCalls(array($orderItem), []));
152 152
 
153
-		$serviceProviderStub->expects( $this->once() )->method( 'isImplemented' )
154
-			->will( $this->returnValue( true ) );
153
+		$serviceProviderStub->expects($this->once())->method('isImplemented')
154
+			->will($this->returnValue(true));
155 155
 
156
-		$serviceProviderStub->expects( $this->once() )->method( 'capture' )
157
-			->will( $this->throwException( new \Aimeos\MShop\Service\Exception( 'test oder service payment: capture' ) ) );
156
+		$serviceProviderStub->expects($this->once())->method('capture')
157
+			->will($this->throwException(new \Aimeos\MShop\Service\Exception('test oder service payment: capture')));
158 158
 
159
-		$orderManagerStub->expects( $this->never() )->method( 'saveItem' );
159
+		$orderManagerStub->expects($this->never())->method('saveItem');
160 160
 
161 161
 
162
-		$object = new \Aimeos\Controller\Jobs\Order\Service\Payment\Standard( $context, $aimeos );
162
+		$object = new \Aimeos\Controller\Jobs\Order\Service\Payment\Standard($context, $aimeos);
163 163
 		$object->run();
164 164
 	}
165 165
 
@@ -171,36 +171,36 @@  discard block
 block discarded – undo
171 171
 
172 172
 
173 173
 		$name = 'ControllerJobsServicePaymentProcessDefaultRun';
174
-		$context->getConfig()->set( 'mshop/service/manager/name', $name );
175
-		$context->getConfig()->set( 'mshop/order/manager/name', $name );
174
+		$context->getConfig()->set('mshop/service/manager/name', $name);
175
+		$context->getConfig()->set('mshop/order/manager/name', $name);
176 176
 
177 177
 
178
-		$orderManagerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Order\\Manager\\Standard' )
179
-			->setMethods( array( 'saveItem', 'searchItems' ) )
180
-			->setConstructorArgs( array( $context ) )
178
+		$orderManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Standard')
179
+			->setMethods(array('saveItem', 'searchItems'))
180
+			->setConstructorArgs(array($context))
181 181
 			->getMock();
182 182
 
183
-		$serviceManagerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Service\\Manager\\Standard' )
184
-			->setMethods( array( 'getProvider', 'searchItems' ) )
185
-			->setConstructorArgs( array( $context ) )
183
+		$serviceManagerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Service\\Manager\\Standard')
184
+			->setMethods(array('getProvider', 'searchItems'))
185
+			->setConstructorArgs(array($context))
186 186
 			->getMock();
187 187
 
188
-		\Aimeos\MShop\Service\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Service\\Manager\\' . $name, $serviceManagerStub );
189
-		\Aimeos\MShop\Order\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Order\\Manager\\' . $name, $orderManagerStub );
188
+		\Aimeos\MShop\Service\Manager\Factory::injectManager('\\Aimeos\\MShop\\Service\\Manager\\' . $name, $serviceManagerStub);
189
+		\Aimeos\MShop\Order\Manager\Factory::injectManager('\\Aimeos\\MShop\\Order\\Manager\\' . $name, $orderManagerStub);
190 190
 
191 191
 
192 192
 		$serviceItem = $serviceManagerStub->createItem();
193 193
 
194
-		$serviceManagerStub->expects( $this->once() )->method( 'searchItems' )
195
-			->will( $this->onConsecutiveCalls( array( $serviceItem ), [] ) );
194
+		$serviceManagerStub->expects($this->once())->method('searchItems')
195
+			->will($this->onConsecutiveCalls(array($serviceItem), []));
196 196
 
197
-		$serviceManagerStub->expects( $this->once() )->method( 'getProvider' )
198
-			->will( $this->throwException( new \Aimeos\MShop\Service\Exception( 'test service delivery process: getProvider' ) ) );
197
+		$serviceManagerStub->expects($this->once())->method('getProvider')
198
+			->will($this->throwException(new \Aimeos\MShop\Service\Exception('test service delivery process: getProvider')));
199 199
 
200
-		$orderManagerStub->expects( $this->never() )->method( 'searchItems' );
200
+		$orderManagerStub->expects($this->never())->method('searchItems');
201 201
 
202 202
 
203
-		$object = new \Aimeos\Controller\Jobs\Order\Service\Payment\Standard( $context, $aimeos );
203
+		$object = new \Aimeos\Controller\Jobs\Order\Service\Payment\Standard($context, $aimeos);
204 204
 		$object->run();
205 205
 	}
206 206
 }
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Order/Export/Csv/Standard.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -121,8 +121,7 @@
 block discarded – undo
121 121
 				}
122 122
 
123 123
 				$this->export( $processors, $data, $maxcnt );
124
-			}
125
-			catch( \Exception $e )
124
+			} catch( \Exception $e )
126 125
 			{
127 126
 				$logger->log( 'Order export error: ' . $e->getMessage() );
128 127
 				$logger->log( $e->getTraceAsString() );
Please login to merge, or discard this patch.
Spacing   +60 added lines, -60 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', 'Order export CSV' );
31
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Order export CSV');
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', 'Exports orders to CSV file' );
42
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Exports orders to CSV file');
43 43
 	}
44 44
 
45 45
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 		 * @category Developer
74 74
 		 * @see controller/common/order/export/csv/max-size
75 75
 		 */
76
-		$mappings = $config->get( 'controller/common/order/export/csv/mapping', $mappings );
76
+		$mappings = $config->get('controller/common/order/export/csv/mapping', $mappings);
77 77
 
78 78
 		/** controller/jobs/order/export/csv/mapping
79 79
 		 * List of mappings between the position in the CSV file and item keys
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		 * @category Developer
89 89
 		 * @see controller/common/order/export/csv/max-size
90 90
 		 */
91
-		$mappings = $config->get( 'controller/jobs/order/export/csv/mapping', $mappings );
91
+		$mappings = $config->get('controller/jobs/order/export/csv/mapping', $mappings);
92 92
 
93 93
 
94 94
 		/** controller/common/order/export/csv/max-size
@@ -106,29 +106,29 @@  discard block
 block discarded – undo
106 106
 		 * @category Developer
107 107
 		 * @see controller/common/order/export/csv/mapping
108 108
 		 */
109
-		$maxcnt = (int) $config->get( 'controller/common/order/export/csv/max-size', 1000 );
109
+		$maxcnt = (int) $config->get('controller/common/order/export/csv/max-size', 1000);
110 110
 
111 111
 
112
-		$processors = $this->getProcessors( $mappings );
113
-		$mq = $context->getMessageQueueManager()->get( 'mq-admin' )->getQueue( 'order-export' );
112
+		$processors = $this->getProcessors($mappings);
113
+		$mq = $context->getMessageQueueManager()->get('mq-admin')->getQueue('order-export');
114 114
 
115
-		while( ( $msg = $mq->get() ) !== null )
115
+		while (($msg = $mq->get()) !== null)
116 116
 		{
117 117
 			try
118 118
 			{
119
-				if( ( $data = json_decode( $msg->getBody(), true ) ) === null ) {
120
-					throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid message: %1$s', $msg->getBody() ) );
119
+				if (($data = json_decode($msg->getBody(), true)) === null) {
120
+					throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid message: %1$s', $msg->getBody()));
121 121
 				}
122 122
 
123
-				$this->export( $processors, $data, $maxcnt );
123
+				$this->export($processors, $data, $maxcnt);
124 124
 			}
125
-			catch( \Exception $e )
125
+			catch (\Exception $e)
126 126
 			{
127
-				$logger->log( 'Order export error: ' . $e->getMessage() );
128
-				$logger->log( $e->getTraceAsString() );
127
+				$logger->log('Order export error: ' . $e->getMessage());
128
+				$logger->log($e->getTraceAsString());
129 129
 			}
130 130
 
131
-			$mq->del( $msg );
131
+			$mq->del($msg);
132 132
 		}
133 133
 	}
134 134
 
@@ -139,15 +139,15 @@  discard block
 block discarded – undo
139 139
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context item
140 140
 	 * @param string $path Absolute path to the exported file
141 141
 	 */
142
-	protected function addJob( $context, $path )
142
+	protected function addJob($context, $path)
143 143
 	{
144
-		$manager = \Aimeos\MAdmin::create( $context, 'job' );
144
+		$manager = \Aimeos\MAdmin::create($context, 'job');
145 145
 
146 146
 		$item = $manager->createItem();
147
-		$item->setResult( ['file' => $path] );
148
-		$item->setLabel( $path );
147
+		$item->setResult(['file' => $path]);
148
+		$item->setLabel($path);
149 149
 
150
-		$manager->saveItem( $item, false );
150
+		$manager->saveItem($item, false);
151 151
 	}
152 152
 
153 153
 
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 		 * @see controller/jobs/order/export/csv/container/content
178 178
 		 * @see controller/jobs/order/export/csv/container/options
179 179
 		 */
180
-		$location = $config->get( 'controller/jobs/order/export/csv/location', sys_get_temp_dir() );
180
+		$location = $config->get('controller/jobs/order/export/csv/location', sys_get_temp_dir());
181 181
 
182 182
 		/** controller/jobs/order/export/csv/container/type
183 183
 		 * Nave of the container type to read the data from
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 		 * @see controller/jobs/order/export/csv/container/content
201 201
 		 * @see controller/jobs/order/export/csv/container/options
202 202
 		 */
203
-		$container = $config->get( 'controller/jobs/order/export/csv/container/type', 'Directory' );
203
+		$container = $config->get('controller/jobs/order/export/csv/container/type', 'Directory');
204 204
 
205 205
 		/** controller/jobs/order/export/csv/container/content
206 206
 		 * Name of the content type inside the container to read the data from
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 		 * @see controller/jobs/order/export/csv/container/type
222 222
 		 * @see controller/jobs/order/export/csv/container/options
223 223
 		 */
224
-		$content = $config->get( 'controller/jobs/order/export/csv/container/content', 'CSV' );
224
+		$content = $config->get('controller/jobs/order/export/csv/container/content', 'CSV');
225 225
 
226 226
 		/** controller/jobs/order/export/csv/container/options
227 227
 		 * List of file container options for the order export files
@@ -239,9 +239,9 @@  discard block
 block discarded – undo
239 239
 		 * @see controller/jobs/order/export/csv/container/content
240 240
 		 * @see controller/jobs/order/export/csv/container/type
241 241
 		 */
242
-		$options = $config->get( 'controller/jobs/order/export/csv/container/options', [] );
242
+		$options = $config->get('controller/jobs/order/export/csv/container/options', []);
243 243
 
244
-		return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options );
244
+		return \Aimeos\MW\Container\Factory::getContainer($location, $container, $content, $options);
245 245
 	}
246 246
 
247 247
 
@@ -253,56 +253,56 @@  discard block
 block discarded – undo
253 253
 	 * @param integer $maxcnt Maximum number of retrieved orders at once
254 254
 	 * @return string Path of the file containing the exported data
255 255
 	 */
256
-	protected function export( array $processors, $msg, $maxcnt )
256
+	protected function export(array $processors, $msg, $maxcnt)
257 257
 	{
258
-		$lcontext = $this->getLocaleContext( $msg );
258
+		$lcontext = $this->getLocaleContext($msg);
259 259
 		$baseRef = ['order/base/address', 'order/base/coupon', 'order/base/product', 'order/base/service'];
260 260
 
261
-		$manager = \Aimeos\MShop::create( $lcontext, 'order' );
262
-		$baseManager = \Aimeos\MShop::create( $lcontext, 'order/base' );
261
+		$manager = \Aimeos\MShop::create($lcontext, 'order');
262
+		$baseManager = \Aimeos\MShop::create($lcontext, 'order/base');
263 263
 
264 264
 		$container = $this->getContainer();
265
-		$content = $container->create( 'order-export_' . date( 'Y-m-d_H-i-s' ) );
266
-		$search = $this->initCriteria( $manager->createSearch()->setSlice( 0, 0x7fffffff ), $msg );
265
+		$content = $container->create('order-export_' . date('Y-m-d_H-i-s'));
266
+		$search = $this->initCriteria($manager->createSearch()->setSlice(0, 0x7fffffff), $msg);
267 267
 		$start = 0;
268 268
 
269 269
 		do
270 270
 		{
271 271
 			$baseIds = [];
272
-			$search->setSlice( $start, $maxcnt );
273
-			$items = $manager->searchItems( $search );
272
+			$search->setSlice($start, $maxcnt);
273
+			$items = $manager->searchItems($search);
274 274
 
275
-			foreach( $items as $item ) {
275
+			foreach ($items as $item) {
276 276
 				$baseIds[] = $item->getBaseId();
277 277
 			}
278 278
 
279 279
 			$baseSearch = $baseManager->createSearch();
280
-			$baseSearch->setConditions( $baseSearch->compare( '==', 'order.base.id', $baseIds ) );
281
-			$baseSearch->setSlice( 0, count( $baseIds ) );
280
+			$baseSearch->setConditions($baseSearch->compare('==', 'order.base.id', $baseIds));
281
+			$baseSearch->setSlice(0, count($baseIds));
282 282
 
283
-			$baseItems = $baseManager->searchItems( $baseSearch, $baseRef );
283
+			$baseItems = $baseManager->searchItems($baseSearch, $baseRef);
284 284
 
285
-			foreach( $items as $id => $item )
285
+			foreach ($items as $id => $item)
286 286
 			{
287
-				foreach( $processors as $type => $processor )
287
+				foreach ($processors as $type => $processor)
288 288
 				{
289
-					foreach( $processor->process( $item, $baseItems[$item->getBaseId()] ) as $line ) {
290
-						$content->add( [0 => $type, 1 => $id] + $line );
289
+					foreach ($processor->process($item, $baseItems[$item->getBaseId()]) as $line) {
290
+						$content->add([0 => $type, 1 => $id] + $line);
291 291
 					}
292 292
 				}
293 293
 			}
294 294
 
295
-			$count = count( $items );
295
+			$count = count($items);
296 296
 			$start += $count;
297 297
 		}
298
-		while( $count === $search->getSliceSize() );
298
+		while ($count === $search->getSliceSize());
299 299
 
300 300
 		$path = $content->getResource();
301
-		$container->add( $content );
301
+		$container->add($content);
302 302
 		$container->close();
303 303
 
304
-		$path = $this->moveFile( $lcontext, $path );
305
-		$this->addJob( $lcontext, $path );
304
+		$path = $this->moveFile($lcontext, $path);
305
+		$this->addJob($lcontext, $path);
306 306
 	}
307 307
 
308 308
 
@@ -312,15 +312,15 @@  discard block
 block discarded – undo
312 312
 	 * @param array $msg Message data including a "sitecode" value
313 313
 	 * @return \Aimeos\MShop\Context\Item\Iface New context item with updated locale
314 314
 	 */
315
-	protected function getLocaleContext( array $msg )
315
+	protected function getLocaleContext(array $msg)
316 316
 	{
317 317
 		$lcontext = clone $this->getContext();
318
-		$manager = \Aimeos\MShop::create( $lcontext, 'locale' );
318
+		$manager = \Aimeos\MShop::create($lcontext, 'locale');
319 319
 
320
-		$sitecode = ( isset( $msg['sitecode'] ) ? $msg['sitecode'] : 'default' );
321
-		$localeItem = $manager->bootstrap( $sitecode, '', '', false, \Aimeos\MShop\Locale\Manager\Base::SITE_PATH );
320
+		$sitecode = (isset($msg['sitecode']) ? $msg['sitecode'] : 'default');
321
+		$localeItem = $manager->bootstrap($sitecode, '', '', false, \Aimeos\MShop\Locale\Manager\Base::SITE_PATH);
322 322
 
323
-		return $lcontext->setLocale( $localeItem );
323
+		return $lcontext->setLocale($localeItem);
324 324
 	}
325 325
 
326 326
 
@@ -331,14 +331,14 @@  discard block
 block discarded – undo
331 331
 	 * @param array $msg Message data
332 332
 	 * @return \Aimeos\MW\Criteria\Iface Initialized criteria object
333 333
 	 */
334
-	protected function initCriteria( \Aimeos\MW\Criteria\Iface $criteria, array $msg )
334
+	protected function initCriteria(\Aimeos\MW\Criteria\Iface $criteria, array $msg)
335 335
 	{
336
-		if( isset( $msg['filter'] ) ) {
337
-			$criteria->setConditions( $criteria->toConditions( $msg['filter'] ) );
336
+		if (isset($msg['filter'])) {
337
+			$criteria->setConditions($criteria->toConditions($msg['filter']));
338 338
 		}
339 339
 
340
-		if( isset( $msg['sort'] ) ) {
341
-			$criteria->setSortations( $criteria->toSortations( $msg['sort'] ) );
340
+		if (isset($msg['sort'])) {
341
+			$criteria->setSortations($criteria->toSortations($msg['sort']));
342 342
 		}
343 343
 
344 344
 		return $criteria;
@@ -352,12 +352,12 @@  discard block
 block discarded – undo
352 352
 	 * @param string $path Absolute path to the exported file
353 353
 	 * @return string Relative path of the file in the storage
354 354
 	 */
355
-	protected function moveFile( $context, $path )
355
+	protected function moveFile($context, $path)
356 356
 	{
357
-		$filename = basename( $path );
358
-		$context->getFileSystemManager()->get( 'fs-admin' )->writef( $filename, $path );
357
+		$filename = basename($path);
358
+		$context->getFileSystemManager()->get('fs-admin')->writef($filename, $path);
359 359
 
360
-		unlink( $path );
360
+		unlink($path);
361 361
 		return $filename;
362 362
 	}
363 363
 }
Please login to merge, or discard this patch.
common/src/Controller/Common/Order/Export/Csv/Processor/Coupon/Standard.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -40,17 +40,17 @@
 block discarded – undo
40 40
 	 * @param \Aimeos\MShop\Order\Item\Base\Iface $order Full order with associated items
41 41
 	 * @return array Two dimensional associative list of order data representing the lines in CSV
42 42
 	 */
43
-	public function process( \Aimeos\MShop\Order\Item\Iface $invoice, \Aimeos\MShop\Order\Item\Base\Iface $order )
43
+	public function process(\Aimeos\MShop\Order\Item\Iface $invoice, \Aimeos\MShop\Order\Item\Base\Iface $order)
44 44
 	{
45 45
 		$result = [];
46 46
 
47
-		foreach( $order->getCoupons() as $code => $products )
47
+		foreach ($order->getCoupons() as $code => $products)
48 48
 		{
49 49
 			$data = [];
50 50
 
51
-			foreach( $this->getMapping() as $pos => $key )
51
+			foreach ($this->getMapping() as $pos => $key)
52 52
 			{
53
-				if( $key === 'order.base.coupon.code' ) {
53
+				if ($key === 'order.base.coupon.code') {
54 54
 					$data[$pos] = $code;
55 55
 				} else {
56 56
 					$data[$pos] = '';
Please login to merge, or discard this patch.