Completed
Push — master ( a9b00f...475749 )
by Aimeos
02:16
created
common/src/Controller/Common/Coupon/Import/Csv/Processor/Iface.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
27 27
 	 * @param \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $object Decorated processor
28 28
 	 */
29
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
30
-		\Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $object = null );
29
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
30
+		\Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $object = null);
31 31
 
32 32
 
33 33
 	/**
@@ -37,5 +37,5 @@  discard block
 block discarded – undo
37 37
 	 * @param array $data List of CSV fields with position as key and data as value
38 38
 	 * @return array List of data which hasn't been imported
39 39
 	 */
40
-	public function process( \Aimeos\MShop\Coupon\Item\Code\Iface $item, array $data );
40
+	public function process(\Aimeos\MShop\Coupon\Item\Code\Iface $item, array $data);
41 41
 }
42 42
\ No newline at end of file
Please login to merge, or discard this patch.
tests/Controller/Common/Coupon/Import/Csv/Processor/Code/StandardTest.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -17,16 +17,16 @@  discard block
 block discarded – undo
17 17
 
18 18
 	protected function setUp()
19 19
 	{
20
-		\Aimeos\MShop\Factory::setCache( true );
20
+		\Aimeos\MShop\Factory::setCache(true);
21 21
 
22 22
 		$this->context = \TestHelperCntl::getContext();
23
-		$this->endpoint = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Done( $this->context, [] );
23
+		$this->endpoint = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Done($this->context, []);
24 24
 	}
25 25
 
26 26
 
27 27
 	protected function tearDown()
28 28
 	{
29
-		\Aimeos\MShop\Factory::setCache( false );
29
+		\Aimeos\MShop\Factory::setCache(false);
30 30
 		\Aimeos\MShop\Factory::clear();
31 31
 	}
32 32
 
@@ -47,24 +47,24 @@  discard block
 block discarded – undo
47 47
 			3 => '',
48 48
 		);
49 49
 
50
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'coupon' );
51
-		$codeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'coupon/code' );
50
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'coupon');
51
+		$codeManager = \Aimeos\MShop\Factory::createManager($this->context, 'coupon/code');
52 52
 
53
-		$coupon = $manager->saveItem( $manager->createItem()->setProvider( 'test' ) );
53
+		$coupon = $manager->saveItem($manager->createItem()->setProvider('test'));
54 54
 		$couponCode = $codeManager->createItem();
55
-		$couponCode->setParentId( $coupon->getId() );
55
+		$couponCode->setParentId($coupon->getId());
56 56
 
57
-		$object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Code\Standard( $this->context, $mapping, $this->endpoint );
58
-		$object->process( $couponCode, $data );
57
+		$object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Code\Standard($this->context, $mapping, $this->endpoint);
58
+		$object->process($couponCode, $data);
59 59
 
60
-		$codeManager->deleteItem( $couponCode->getId() );
61
-		$manager->deleteItem( $coupon->getId() );
60
+		$codeManager->deleteItem($couponCode->getId());
61
+		$manager->deleteItem($coupon->getId());
62 62
 
63 63
 
64
-		$this->assertEquals( 10, $couponCode->getCount() );
65
-		$this->assertEquals( 'jobimporttest', $couponCode->getCode() );
66
-		$this->assertEquals( '2000-01-01 00:00:00', $couponCode->getDateStart() );
67
-		$this->assertEquals( null, $couponCode->getDateEnd() );
64
+		$this->assertEquals(10, $couponCode->getCount());
65
+		$this->assertEquals('jobimporttest', $couponCode->getCode());
66
+		$this->assertEquals('2000-01-01 00:00:00', $couponCode->getDateStart());
67
+		$this->assertEquals(null, $couponCode->getDateEnd());
68 68
 	}
69 69
 
70 70
 
@@ -86,23 +86,23 @@  discard block
 block discarded – undo
86 86
 		);
87 87
 
88 88
 
89
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'coupon' );
90
-		$codeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'coupon/code' );
89
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'coupon');
90
+		$codeManager = \Aimeos\MShop\Factory::createManager($this->context, 'coupon/code');
91 91
 
92
-		$coupon = $manager->saveItem( $manager->createItem()->setProvider( 'test' ) );
92
+		$coupon = $manager->saveItem($manager->createItem()->setProvider('test'));
93 93
 		$couponCode = $codeManager->createItem();
94
-		$couponCode->setParentId( $coupon->getId() );
94
+		$couponCode->setParentId($coupon->getId());
95 95
 
96
-		$object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Code\Standard( $this->context, $mapping, $this->endpoint );
97
-		$object->process( $couponCode, $data );
98
-		$object->process( $couponCode, $dataUpdate );
96
+		$object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Code\Standard($this->context, $mapping, $this->endpoint);
97
+		$object->process($couponCode, $data);
98
+		$object->process($couponCode, $dataUpdate);
99 99
 
100
-		$codeManager->deleteItem( $couponCode->getId() );
101
-		$manager->deleteItem( $coupon->getId() );
100
+		$codeManager->deleteItem($couponCode->getId());
101
+		$manager->deleteItem($coupon->getId());
102 102
 
103 103
 
104
-		$this->assertEquals( 5, $couponCode->getCount() );
105
-		$this->assertEquals( 'jobimporttest', $couponCode->getCode() );
104
+		$this->assertEquals(5, $couponCode->getCount());
105
+		$this->assertEquals('jobimporttest', $couponCode->getCode());
106 106
 	}
107 107
 
108 108
 
@@ -119,20 +119,20 @@  discard block
 block discarded – undo
119 119
 		);
120 120
 
121 121
 
122
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'coupon' );
123
-		$codeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'coupon/code' );
122
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'coupon');
123
+		$codeManager = \Aimeos\MShop\Factory::createManager($this->context, 'coupon/code');
124 124
 
125
-		$coupon = $manager->saveItem( $manager->createItem()->setProvider( 'test' ) );
125
+		$coupon = $manager->saveItem($manager->createItem()->setProvider('test'));
126 126
 		$couponCode = $codeManager->createItem();
127
-		$couponCode->setParentId( $coupon->getId() );
127
+		$couponCode->setParentId($coupon->getId());
128 128
 
129
-		$object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Code\Standard( $this->context, $mapping, $this->endpoint );
130
-		$object->process( $couponCode, $data );
129
+		$object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Code\Standard($this->context, $mapping, $this->endpoint);
130
+		$object->process($couponCode, $data);
131 131
 
132
-		$codeManager->deleteItem( $couponCode->getId() );
133
-		$manager->deleteItem( $coupon->getId() );
132
+		$codeManager->deleteItem($couponCode->getId());
133
+		$manager->deleteItem($coupon->getId());
134 134
 
135 135
 
136
-		$this->assertEquals( 0, $couponCode->getCount() );
136
+		$this->assertEquals(0, $couponCode->getCount());
137 137
 	}
138 138
 }
139 139
\ No newline at end of file
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Coupon/Import/Csv/Code/Standard.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -160,8 +160,7 @@  discard block
 block discarded – undo
160 160
 				$msg = 'Finished coupon import: %1$d successful, %2$s errors, %3$s total (%4$s)';
161 161
 				$logger->log( sprintf( $msg, $total - $errors, $errors, $total, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE );
162 162
 			}
163
-		}
164
-		catch( \Exception $e )
163
+		} catch( \Exception $e )
165 164
 		{
166 165
 			$logger->log( 'Coupon import error: ' . $e->getMessage() );
167 166
 			$logger->log( $e->getTraceAsString() );
@@ -309,8 +308,7 @@  discard block
 block discarded – undo
309 308
 				$list = $processor->process( $item, $list );
310 309
 
311 310
 				$manager->commit();
312
-			}
313
-			catch( \Exception $e )
311
+			} catch( \Exception $e )
314 312
 			{
315 313
 				$manager->rollback();
316 314
 
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 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', 'Coupon code import CSV' );
31
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Coupon code import 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', 'Imports new and updates existing coupon code from CSV files' );
42
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Imports new and updates existing coupon code from CSV files');
43 43
 	}
44 44
 
45 45
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 		 * @see controller/jobs/coupon/import/csv/code/skip-lines
72 72
 		 * @see controller/jobs/coupon/import/csv/code/max-size
73 73
 		 */
74
-		$mappings = $config->get( 'controller/jobs/coupon/import/csv/code/mapping', $mappings );
74
+		$mappings = $config->get('controller/jobs/coupon/import/csv/code/mapping', $mappings);
75 75
 
76 76
 
77 77
 		/** controller/jobs/coupon/import/csv/code/max-size
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 		 * @see controller/jobs/coupon/import/csv/code/skip-lines
91 91
 		 * @see controller/jobs/coupon/import/csv/code/mapping
92 92
 		 */
93
-		$maxcnt = (int) $config->get( 'controller/jobs/coupon/import/csv/code/max-size', 1000 );
93
+		$maxcnt = (int) $config->get('controller/jobs/coupon/import/csv/code/max-size', 1000);
94 94
 
95 95
 
96 96
 		/** controller/jobs/coupon/import/csv/code/skip-lines
@@ -108,64 +108,64 @@  discard block
 block discarded – undo
108 108
 		 * @see controller/jobs/coupon/import/csv/code/mapping
109 109
 		 * @see controller/jobs/coupon/import/csv/code/max-size
110 110
 		 */
111
-		$skiplines = (int) $config->get( 'controller/jobs/coupon/import/csv/code/skip-lines', 0 );
111
+		$skiplines = (int) $config->get('controller/jobs/coupon/import/csv/code/skip-lines', 0);
112 112
 
113 113
 
114 114
 		try
115 115
 		{
116
-			$processor = $this->getProcessors( $mappings );
117
-			$codePos = $this->getCodePosition( $mappings['code'] );
118
-			$fs = $context->getFileSystemManager()->get( 'fs-import' );
116
+			$processor = $this->getProcessors($mappings);
117
+			$codePos = $this->getCodePosition($mappings['code']);
118
+			$fs = $context->getFileSystemManager()->get('fs-import');
119 119
 			$dir = 'couponcode/' . $context->getLocale()->getSite()->getCode();
120 120
 
121
-			if( $fs->isDir( $dir ) === false ) {
121
+			if ($fs->isDir($dir) === false) {
122 122
 				return;
123 123
 			}
124 124
 
125
-			foreach( $fs->scan( $dir ) as $filename )
125
+			foreach ($fs->scan($dir) as $filename)
126 126
 			{
127
-				if( $filename == '.' || $filename == '..' ) {
127
+				if ($filename == '.' || $filename == '..') {
128 128
 					continue;
129 129
 				}
130 130
 
131
-				list( $couponId, ) = explode( '.', $filename );
132
-				$container = $this->getContainer( $fs->readf( $dir . '/' . $filename ) );
131
+				list($couponId,) = explode('.', $filename);
132
+				$container = $this->getContainer($fs->readf($dir . '/' . $filename));
133 133
 
134
-				$msg = sprintf( 'Started coupon import from "%1$s" (%2$s)', $filename, __CLASS__ );
135
-				$logger->log( $msg, \Aimeos\MW\Logger\Base::NOTICE );
134
+				$msg = sprintf('Started coupon import from "%1$s" (%2$s)', $filename, __CLASS__);
135
+				$logger->log($msg, \Aimeos\MW\Logger\Base::NOTICE);
136 136
 
137
-				foreach( $container as $content )
137
+				foreach ($container as $content)
138 138
 				{
139
-					for( $i = 0; $i < $skiplines; $i++ ) {
139
+					for ($i = 0; $i < $skiplines; $i++) {
140 140
 						$content->next();
141 141
 					}
142 142
 
143
-					while( ( $data = $this->getData( $content, $maxcnt, $codePos ) ) !== [] )
143
+					while (($data = $this->getData($content, $maxcnt, $codePos)) !== [])
144 144
 					{
145
-						$items = $this->getCouponCodeItems( array_keys( $data ) );
146
-						$errcnt = $this->import( $items, $data, $couponId, $processor );
147
-						$chunkcnt = count( $data );
145
+						$items = $this->getCouponCodeItems(array_keys($data));
146
+						$errcnt = $this->import($items, $data, $couponId, $processor);
147
+						$chunkcnt = count($data);
148 148
 
149 149
 						$msg = 'Imported coupon lines from "%1$s": %2$d/%3$d (%4$s)';
150
-						$logger->log( sprintf( $msg, $filename, $chunkcnt - $errcnt, $chunkcnt, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE );
150
+						$logger->log(sprintf($msg, $filename, $chunkcnt - $errcnt, $chunkcnt, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE);
151 151
 
152 152
 						$errors += $errcnt;
153 153
 						$total += $chunkcnt;
154
-						unset( $items, $data );
154
+						unset($items, $data);
155 155
 					}
156 156
 				}
157 157
 
158 158
 				$container->close();
159
-				$fs->rm( $dir . '/' . $filename );
159
+				$fs->rm($dir . '/' . $filename);
160 160
 
161 161
 				$msg = 'Finished coupon import: %1$d successful, %2$s errors, %3$s total (%4$s)';
162
-				$logger->log( sprintf( $msg, $total - $errors, $errors, $total, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE );
162
+				$logger->log(sprintf($msg, $total - $errors, $errors, $total, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE);
163 163
 			}
164 164
 		}
165
-		catch( \Exception $e )
165
+		catch (\Exception $e)
166 166
 		{
167
-			$logger->log( 'Coupon import error: ' . $e->getMessage() );
168
-			$logger->log( $e->getTraceAsString() );
167
+			$logger->log('Coupon import error: ' . $e->getMessage());
168
+			$logger->log($e->getTraceAsString());
169 169
 
170 170
 			throw $e;
171 171
 		}
@@ -179,16 +179,16 @@  discard block
 block discarded – undo
179 179
 	 * @return integer Position of the "coupon.code" column
180 180
 	 * @throws \Aimeos\Controller\Jobs\Exception If no mapping for "coupon.code.code" is found
181 181
 	 */
182
-	protected function getCodePosition( array $mapping )
182
+	protected function getCodePosition(array $mapping)
183 183
 	{
184
-		foreach( $mapping as $pos => $key )
184
+		foreach ($mapping as $pos => $key)
185 185
 		{
186
-			if( $key === 'coupon.code.code' ) {
186
+			if ($key === 'coupon.code.code') {
187 187
 				return $pos;
188 188
 			}
189 189
 		}
190 190
 
191
-		throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No "coupon.code.code" column in CSV mapping found' ) );
191
+		throw new \Aimeos\Controller\Jobs\Exception(sprintf('No "coupon.code.code" column in CSV mapping found'));
192 192
 	}
193 193
 
194 194
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	 * @param string $filepath Path to the container file
199 199
 	 * @return \Aimeos\MW\Container\Iface Container object
200 200
 	 */
201
-	protected function getContainer( $filepath )
201
+	protected function getContainer($filepath)
202 202
 	{
203 203
 		$config = $this->getContext()->getConfig();
204 204
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 		 * @see controller/jobs/coupon/import/csv/code/container/content
223 223
 		 * @see controller/jobs/coupon/import/csv/code/container/options
224 224
 		 */
225
-		$container = $config->get( 'controller/jobs/coupon/import/csv/code/container/type', 'File' );
225
+		$container = $config->get('controller/jobs/coupon/import/csv/code/container/type', 'File');
226 226
 
227 227
 		/** controller/jobs/coupon/import/csv/code/container/content
228 228
 		 * Name of the content type inside the container to read the data from
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 		 * @see controller/jobs/coupon/import/csv/code/container/type
243 243
 		 * @see controller/jobs/coupon/import/csv/code/container/options
244 244
 		 */
245
-		$content = $config->get( 'controller/jobs/coupon/import/csv/code/container/content', 'CSV' );
245
+		$content = $config->get('controller/jobs/coupon/import/csv/code/container/content', 'CSV');
246 246
 
247 247
 		/** controller/jobs/coupon/import/csv/code/container/options
248 248
 		 * List of file container options for the coupon import files
@@ -259,9 +259,9 @@  discard block
 block discarded – undo
259 259
 		 * @see controller/jobs/coupon/import/csv/code/container/content
260 260
 		 * @see controller/jobs/coupon/import/csv/code/container/type
261 261
 		 */
262
-		$options = $config->get( 'controller/jobs/coupon/import/csv/code/container/options', [] );
262
+		$options = $config->get('controller/jobs/coupon/import/csv/code/container/options', []);
263 263
 
264
-		return \Aimeos\MW\Container\Factory::getContainer( $filepath, $container, $content, $options );
264
+		return \Aimeos\MW\Container\Factory::getContainer($filepath, $container, $content, $options);
265 265
 	}
266 266
 
267 267
 
@@ -275,36 +275,36 @@  discard block
 block discarded – undo
275 275
 	 * @return integer Number of coupons that couldn't be imported
276 276
 	 * @throws \Aimeos\Controller\Jobs\Exception
277 277
 	 */
278
-	protected function import( array $items, array $data, $couponId,
279
-		\Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $processor )
278
+	protected function import(array $items, array $data, $couponId,
279
+		\Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $processor)
280 280
 	{
281 281
 		$errors = 0;
282 282
 		$context = $this->getContext();
283
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'coupon/code' );
283
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'coupon/code');
284 284
 
285
-		foreach( $data as $code => $list )
285
+		foreach ($data as $code => $list)
286 286
 		{
287 287
 			$manager->begin();
288 288
 
289 289
 			try
290 290
 			{
291
-				if( isset( $items[$code] ) ) {
291
+				if (isset($items[$code])) {
292 292
 					$item = $items[$code];
293 293
 				} else {
294 294
 					$item = $manager->createItem();
295 295
 				}
296 296
 
297
-				$item->setParentId( $couponId );
298
-				$list = $processor->process( $item, $list );
297
+				$item->setParentId($couponId);
298
+				$list = $processor->process($item, $list);
299 299
 
300 300
 				$manager->commit();
301 301
 			}
302
-			catch( \Exception $e )
302
+			catch (\Exception $e)
303 303
 			{
304 304
 				$manager->rollback();
305 305
 
306
-				$msg = sprintf( 'Unable to import coupon with code "%1$s": %2$s', $code, $e->getMessage() );
307
-				$context->getLogger()->log( $msg );
306
+				$msg = sprintf('Unable to import coupon with code "%1$s": %2$s', $code, $e->getMessage());
307
+				$context->getLogger()->log($msg);
308 308
 
309 309
 				$errors++;
310 310
 			}
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Coupon/Import/Csv/Code/Factory.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 * @param string|null $name Name of the controller or "Standard" if null
30 30
 	 * @return \Aimeos\Controller\Jobs\Iface New controller object
31 31
 	 */
32
-	public static function createController( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null )
32
+	public static function createController(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null)
33 33
 	{
34 34
 		/** controller/jobs/coupon/import/csv/code/name
35 35
 		 * Class name of the used coupon code import job controller implementation
@@ -64,20 +64,20 @@  discard block
 block discarded – undo
64 64
 		 * @since 2017.10
65 65
 		 * @category Developer
66 66
 		 */
67
-		if ( $name === null ) {
67
+		if ($name === null) {
68 68
 			$name = $context->getConfig()->get('controller/jobs/coupon/import/csv/code/name', 'Standard');
69 69
 		}
70 70
 
71
-		if ( ctype_alnum($name) === false )
71
+		if (ctype_alnum($name) === false)
72 72
 		{
73 73
 			$classname = is_string($name) ? '\\Aimeos\\Controller\\Jobs\\Coupon\\Import\\Csv\\Code\\' . $name : '<not a string>';
74
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
74
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
75 75
 		}
76 76
 
77 77
 		$iface = '\\Aimeos\\Controller\\Jobs\\Iface';
78 78
 		$classname = '\\Aimeos\\Controller\\Jobs\\Coupon\\Import\\Csv\\Code\\' . $name;
79 79
 
80
-		$controller = self::createControllerBase( $context, $aimeos, $classname, $iface );
80
+		$controller = self::createControllerBase($context, $aimeos, $classname, $iface);
81 81
 
82 82
 		/** controller/jobs/coupon/import/csv/code/decorators/excludes
83 83
 		 * Excludes decorators added by the "common" option from the coupon code import CSV job controller
@@ -154,6 +154,6 @@  discard block
 block discarded – undo
154 154
 		 * @see controller/jobs/coupon/import/csv/code/decorators/excludes
155 155
 		 * @see controller/jobs/coupon/import/csv/code/decorators/global
156 156
 		 */
157
-		return self::addControllerDecorators( $context, $aimeos, $controller, 'coupon/import/csv/code' );
157
+		return self::addControllerDecorators($context, $aimeos, $controller, 'coupon/import/csv/code');
158 158
 	}
159 159
 }
160 160
\ No newline at end of file
Please login to merge, or discard this patch.
controller/jobs/tests/Controller/Jobs/Product/Bought/StandardTest.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -19,18 +19,18 @@  discard block
 block discarded – undo
19 19
 
20 20
 	protected function setUp()
21 21
 	{
22
-		\Aimeos\MShop\Factory::setCache( true );
22
+		\Aimeos\MShop\Factory::setCache(true);
23 23
 
24 24
 		$this->context = \TestHelperJobs::getContext();
25 25
 		$this->aimeos = \TestHelperJobs::getAimeos();
26 26
 
27
-		$this->object = new \Aimeos\Controller\Jobs\Product\Bought\Standard( $this->context, $this->aimeos );
27
+		$this->object = new \Aimeos\Controller\Jobs\Product\Bought\Standard($this->context, $this->aimeos);
28 28
 	}
29 29
 
30 30
 
31 31
 	protected function tearDown()
32 32
 	{
33
-		\Aimeos\MShop\Factory::setCache( false );
33
+		\Aimeos\MShop\Factory::setCache(false);
34 34
 		\Aimeos\MShop\Factory::clear();
35 35
 
36 36
 		$this->object = null;
@@ -39,28 +39,28 @@  discard block
 block discarded – undo
39 39
 
40 40
 	public function testGetName()
41 41
 	{
42
-		$this->assertEquals( 'Products bought together', $this->object->getName() );
42
+		$this->assertEquals('Products bought together', $this->object->getName());
43 43
 	}
44 44
 
45 45
 
46 46
 	public function testGetDescription()
47 47
 	{
48 48
 		$text = 'Creates bought together product suggestions';
49
-		$this->assertEquals( $text, $this->object->getDescription() );
49
+		$this->assertEquals($text, $this->object->getDescription());
50 50
 	}
51 51
 
52 52
 
53 53
 	public function testRun()
54 54
 	{
55
-		$stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Product\\Manager\\Lists\\Standard' )
56
-			->setConstructorArgs( array( $this->context ) )
57
-			->setMethods( array( 'deleteItems', 'saveItem' ) )
55
+		$stub = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Lists\\Standard')
56
+			->setConstructorArgs(array($this->context))
57
+			->setMethods(array('deleteItems', 'saveItem'))
58 58
 			->getMock();
59 59
 
60
-		\Aimeos\MShop\Factory::injectManager( $this->context, 'product/lists', $stub );
60
+		\Aimeos\MShop\Factory::injectManager($this->context, 'product/lists', $stub);
61 61
 
62
-		$stub->expects( $this->atLeastOnce() )->method( 'deleteItems' );
63
-		$stub->expects( $this->atLeastOnce() )->method( 'saveItem' );
62
+		$stub->expects($this->atLeastOnce())->method('deleteItems');
63
+		$stub->expects($this->atLeastOnce())->method('saveItem');
64 64
 
65 65
 		$this->object->run();
66 66
 	}
Please login to merge, or discard this patch.
jobs/tests/Controller/Jobs/Coupon/Import/Csv/Code/FactoryTest.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 		$context = \TestHelperJobs::getContext();
17 17
 		$aimeos = \TestHelperJobs::getAimeos();
18 18
 
19
-		$obj = \Aimeos\Controller\Jobs\Coupon\Import\Csv\Code\Factory::createController( $context, $aimeos );
20
-		$this->assertInstanceOf( '\\Aimeos\\Controller\\Jobs\\Iface', $obj);
19
+		$obj = \Aimeos\Controller\Jobs\Coupon\Import\Csv\Code\Factory::createController($context, $aimeos);
20
+		$this->assertInstanceOf('\\Aimeos\\Controller\\Jobs\\Iface', $obj);
21 21
 	}
22 22
 
23 23
 
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 		$context = \TestHelperJobs::getContext();
27 27
 		$aimeos = \TestHelperJobs::getAimeos();
28 28
 
29
-		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
30
-		\Aimeos\Controller\Jobs\Coupon\Import\Csv\Code\Factory::createController( $context, $aimeos, 'Wrong$$$Name' );
29
+		$this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception');
30
+		\Aimeos\Controller\Jobs\Coupon\Import\Csv\Code\Factory::createController($context, $aimeos, 'Wrong$$$Name');
31 31
 	}
32 32
 
33 33
 
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
 		$context = \TestHelperJobs::getContext();
37 37
 		$aimeos = \TestHelperJobs::getAimeos();
38 38
 
39
-		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
40
-		\Aimeos\Controller\Jobs\Coupon\Import\Csv\Code\Factory::createController( $context, $aimeos, 'WrongClass' );
39
+		$this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception');
40
+		\Aimeos\Controller\Jobs\Coupon\Import\Csv\Code\Factory::createController($context, $aimeos, 'WrongClass');
41 41
 	}
42 42
 
43 43
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		$context = \TestHelperJobs::getContext();
47 47
 		$aimeos = \TestHelperJobs::getAimeos();
48 48
 
49
-		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
50
-		\Aimeos\Controller\Jobs\Coupon\Import\Csv\Code\Factory::createController( $context, $aimeos, 'Factory' );
49
+		$this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception');
50
+		\Aimeos\Controller\Jobs\Coupon\Import\Csv\Code\Factory::createController($context, $aimeos, 'Factory');
51 51
 	}
52 52
 }
53 53
\ No newline at end of file
Please login to merge, or discard this patch.
tests/Controller/Common/Order/Export/Csv/Processor/Service/StandardTest.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -29,59 +29,59 @@
 block discarded – undo
29 29
 		);
30 30
 
31 31
 
32
-		$object = new \Aimeos\Controller\Common\Order\Export\Csv\Processor\Service\Standard( $context, $mapping );
33
-
34
-		$invoice = $this->getInvoice( $context );
35
-		$order = \Aimeos\MShop\Factory::createManager( $context, 'order/base' )->load( $invoice->getBaseId() );
36
-
37
-		$data = $object->process( $invoice, $order );
38
-
39
-
40
-		$this->assertEquals( 2, count( $data ) );
41
-
42
-		$this->assertEquals( 12, count( $data[0] ) );
43
-		$this->assertEquals( 'payment', $data[0][0] );
44
-		$this->assertEquals( 'OGONE', $data[0][1] );
45
-		$this->assertEquals( 'ogone', $data[0][2] );
46
-		$this->assertEquals( 'somewhere/thump1.jpg', $data[0][3] );
47
-		$this->assertEquals( '0.00', $data[0][4] );
48
-		$this->assertEquals( '0.00', $data[0][5] );
49
-		$this->assertEquals( '0.00', $data[0][6] );
50
-		$this->assertEquals( '0.0000', $data[0][7] );
51
-		$this->assertEquals( "payment\npayment\npayment\npayment\npayment\npayment\npayment\npayment\npayment", $data[0][8] );
52
-		$this->assertEquals( "ACOWNER\nACSTRING\nNAME\nOgone-alias-name\nOgone-alias-value\nREFID\nTXDATE\nX-ACCOUNT\nX-STATUS", $data[0][9] );
53
-		$this->assertEquals( "account owner\naccount number\npayment method\nogone alias name\nogone alias value\nreference id\ntransaction date\ntransaction account\ntransaction status", $data[0][10] );
54
-		$this->assertEquals( "test user\n9876543\nCreditCard\naliasName\naliasValue\n12345678\n2009-08-18\nKraft02\n9", $data[0][11] );
55
-
56
-		$this->assertEquals( 12, count( $data[1] ) );
57
-		$this->assertEquals( 'delivery', $data[1][0] );
58
-		$this->assertEquals( '73', $data[1][1] );
59
-		$this->assertEquals( 'solucia', $data[1][2] );
60
-		$this->assertEquals( 'somewhere/thump1.jpg', $data[1][3] );
61
-		$this->assertEquals( '0.00', $data[1][4] );
62
-		$this->assertEquals( '5.00', $data[1][5] );
63
-		$this->assertEquals( '0.00', $data[1][6] );
64
-		$this->assertEquals( '0.0000', $data[1][7] );
65
-		$this->assertEquals( '', $data[1][8] );
66
-		$this->assertEquals( '', $data[1][9] );
67
-		$this->assertEquals( '', $data[1][10] );
68
-		$this->assertEquals( '', $data[1][11] );
32
+		$object = new \Aimeos\Controller\Common\Order\Export\Csv\Processor\Service\Standard($context, $mapping);
33
+
34
+		$invoice = $this->getInvoice($context);
35
+		$order = \Aimeos\MShop\Factory::createManager($context, 'order/base')->load($invoice->getBaseId());
36
+
37
+		$data = $object->process($invoice, $order);
38
+
39
+
40
+		$this->assertEquals(2, count($data));
41
+
42
+		$this->assertEquals(12, count($data[0]));
43
+		$this->assertEquals('payment', $data[0][0]);
44
+		$this->assertEquals('OGONE', $data[0][1]);
45
+		$this->assertEquals('ogone', $data[0][2]);
46
+		$this->assertEquals('somewhere/thump1.jpg', $data[0][3]);
47
+		$this->assertEquals('0.00', $data[0][4]);
48
+		$this->assertEquals('0.00', $data[0][5]);
49
+		$this->assertEquals('0.00', $data[0][6]);
50
+		$this->assertEquals('0.0000', $data[0][7]);
51
+		$this->assertEquals("payment\npayment\npayment\npayment\npayment\npayment\npayment\npayment\npayment", $data[0][8]);
52
+		$this->assertEquals("ACOWNER\nACSTRING\nNAME\nOgone-alias-name\nOgone-alias-value\nREFID\nTXDATE\nX-ACCOUNT\nX-STATUS", $data[0][9]);
53
+		$this->assertEquals("account owner\naccount number\npayment method\nogone alias name\nogone alias value\nreference id\ntransaction date\ntransaction account\ntransaction status", $data[0][10]);
54
+		$this->assertEquals("test user\n9876543\nCreditCard\naliasName\naliasValue\n12345678\n2009-08-18\nKraft02\n9", $data[0][11]);
55
+
56
+		$this->assertEquals(12, count($data[1]));
57
+		$this->assertEquals('delivery', $data[1][0]);
58
+		$this->assertEquals('73', $data[1][1]);
59
+		$this->assertEquals('solucia', $data[1][2]);
60
+		$this->assertEquals('somewhere/thump1.jpg', $data[1][3]);
61
+		$this->assertEquals('0.00', $data[1][4]);
62
+		$this->assertEquals('5.00', $data[1][5]);
63
+		$this->assertEquals('0.00', $data[1][6]);
64
+		$this->assertEquals('0.0000', $data[1][7]);
65
+		$this->assertEquals('', $data[1][8]);
66
+		$this->assertEquals('', $data[1][9]);
67
+		$this->assertEquals('', $data[1][10]);
68
+		$this->assertEquals('', $data[1][11]);
69 69
 	}
70 70
 
71 71
 
72
-	protected function getInvoice( $context )
72
+	protected function getInvoice($context)
73 73
 	{
74
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'order' );
74
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'order');
75 75
 
76 76
 		$search = $manager->createSearch();
77
-		$search->setConditions( $search->compare( '==', 'order.datepayment', '2008-02-15 12:34:56' ) );
77
+		$search->setConditions($search->compare('==', 'order.datepayment', '2008-02-15 12:34:56'));
78 78
 
79
-		$items = $manager->searchItems( $search );
79
+		$items = $manager->searchItems($search);
80 80
 
81
-		if( ( $item = reset( $items ) ) !== false ) {
81
+		if (($item = reset($items)) !== false) {
82 82
 			return $item;
83 83
 		}
84 84
 
85
-		throw new \Exception( 'No order item found' );
85
+		throw new \Exception('No order item found');
86 86
 	}
87 87
 }
Please login to merge, or discard this patch.
jobs/tests/Controller/Jobs/Coupon/Import/Csv/Code/StandardTest.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -18,95 +18,95 @@
 block discarded – undo
18 18
 
19 19
 	protected function setUp()
20 20
 	{
21
-		\Aimeos\MShop\Factory::setCache( true );
21
+		\Aimeos\MShop\Factory::setCache(true);
22 22
 
23 23
 		$this->context = \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 );
27
+		$config->set('controller/jobs/product/import/csv/skip-lines', 1);
28 28
 
29
-		$this->object = new \Aimeos\Controller\Jobs\Coupon\Import\Csv\Code\Standard( $this->context, $this->aimeos );
29
+		$this->object = new \Aimeos\Controller\Jobs\Coupon\Import\Csv\Code\Standard($this->context, $this->aimeos);
30 30
 	}
31 31
 
32 32
 
33 33
 	protected function tearDown()
34 34
 	{
35
-		\Aimeos\MShop\Factory::setCache( false );
35
+		\Aimeos\MShop\Factory::setCache(false);
36 36
 		\Aimeos\MShop\Factory::clear();
37 37
 
38
-		unset( $this->object );
38
+		unset($this->object);
39 39
 	}
40 40
 
41 41
 
42 42
 	public function testGetName()
43 43
 	{
44
-		$this->assertEquals( 'Coupon code import CSV', $this->object->getName() );
44
+		$this->assertEquals('Coupon code import CSV', $this->object->getName());
45 45
 	}
46 46
 
47 47
 
48 48
 	public function testGetDescription()
49 49
 	{
50 50
 		$text = 'Imports new and updates existing coupon code from CSV files';
51
-		$this->assertEquals( $text, $this->object->getDescription() );
51
+		$this->assertEquals($text, $this->object->getDescription());
52 52
 	}
53 53
 
54 54
 
55 55
 	public function testRun()
56 56
 	{
57
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'coupon' );
58
-		$coupon = $manager->saveItem( $manager->createItem()->setProvider( 'Example' ) );
57
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'coupon');
58
+		$coupon = $manager->saveItem($manager->createItem()->setProvider('Example'));
59 59
 
60 60
 		$dir = 'tmp/import/couponcode/unittest';
61 61
 		$filepath = $dir . '/' . $coupon->getId() . '.csv';
62 62
 
63
-		if( !is_dir( $dir ) && mkdir( 'tmp/import/couponcode/unittest', 0775, true ) === false ) {
64
-			throw new \Exception( sprintf( 'Unable to create directory "%1$s"', $dir ) );
63
+		if (!is_dir($dir) && mkdir('tmp/import/couponcode/unittest', 0775, true) === false) {
64
+			throw new \Exception(sprintf('Unable to create directory "%1$s"', $dir));
65 65
 		}
66 66
 
67 67
 		$content = 'code,count,start,end
68 68
 jobccimport1,3,2000-01-01 00:00:00,
69 69
 jobccimport2,5,,';
70 70
 
71
-		if( file_put_contents( $filepath, $content ) === false ) {
72
-			throw new \Exception( sprintf( 'Unable to create file "%1$s"', $file ) );
71
+		if (file_put_contents($filepath, $content) === false) {
72
+			throw new \Exception(sprintf('Unable to create file "%1$s"', $file));
73 73
 		}
74 74
 
75 75
 		$this->object->run();
76 76
 
77 77
 
78
-		$codeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'coupon/code' );
79
-		$code1 = $codeManager->findItem( 'jobccimport1' );
80
-		$code2 = $codeManager->findItem( 'jobccimport2' );
78
+		$codeManager = \Aimeos\MShop\Factory::createManager($this->context, 'coupon/code');
79
+		$code1 = $codeManager->findItem('jobccimport1');
80
+		$code2 = $codeManager->findItem('jobccimport2');
81 81
 
82
-		$manager->deleteItem( $coupon->getId() );
82
+		$manager->deleteItem($coupon->getId());
83 83
 
84
-		$this->assertEquals( 3, $code1->getCount() );
85
-		$this->assertEquals( '2000-01-01 00:00:00', $code1->getDateStart() );
86
-		$this->assertEquals( null, $code1->getDateEnd() );
84
+		$this->assertEquals(3, $code1->getCount());
85
+		$this->assertEquals('2000-01-01 00:00:00', $code1->getDateStart());
86
+		$this->assertEquals(null, $code1->getDateEnd());
87 87
 
88
-		$this->assertEquals( 5, $code2->getCount() );
89
-		$this->assertEquals( null, $code2->getDateStart() );
90
-		$this->assertEquals( null, $code2->getDateEnd() );
88
+		$this->assertEquals(5, $code2->getCount());
89
+		$this->assertEquals(null, $code2->getDateStart());
90
+		$this->assertEquals(null, $code2->getDateEnd());
91 91
 	}
92 92
 
93 93
 
94 94
 	public function testRunException()
95 95
 	{
96
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'coupon' );
96
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'coupon');
97 97
 
98 98
 		$dir = 'tmp/import/couponcode/unittest';
99 99
 		$filepath = $dir . '/0.csv';
100 100
 
101
-		if( !is_dir( $dir ) && mkdir( 'tmp/import/couponcode/unittest', 0775, true ) === false ) {
102
-			throw new \Exception( sprintf( 'Unable to create directory "%1$s"', $dir ) );
101
+		if (!is_dir($dir) && mkdir('tmp/import/couponcode/unittest', 0775, true) === false) {
102
+			throw new \Exception(sprintf('Unable to create directory "%1$s"', $dir));
103 103
 		}
104 104
 
105 105
 		$content = 'code,count,start,end
106 106
 jobccimport1,,,';
107 107
 
108
-		if( file_put_contents( $filepath, $content ) === false ) {
109
-			throw new \Exception( sprintf( 'Unable to create file "%1$s"', $file ) );
108
+		if (file_put_contents($filepath, $content) === false) {
109
+			throw new \Exception(sprintf('Unable to create file "%1$s"', $file));
110 110
 		}
111 111
 
112 112
 		$this->object->run();
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Order/Service/Async/Standard.php 2 patches
Spacing   +11 added lines, -11 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', 'Batch update of payment/delivery status' );
32
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Batch update of payment/delivery status');
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', 'Executes payment or delivery service providers that uses batch updates' );
43
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Executes payment or delivery service providers that uses batch updates');
44 44
 	}
45 45
 
46 46
 
@@ -52,32 +52,32 @@  discard block
 block discarded – undo
52 52
 	public function run()
53 53
 	{
54 54
 		$context = $this->getContext();
55
-		$serviceManager = \Aimeos\MShop\Factory::createManager( $context, 'service' );
55
+		$serviceManager = \Aimeos\MShop\Factory::createManager($context, 'service');
56 56
 
57 57
 		$search = $serviceManager->createSearch();
58 58
 		$start = 0;
59 59
 
60 60
 		do
61 61
 		{
62
-			$serviceItems = $serviceManager->searchItems( $search );
62
+			$serviceItems = $serviceManager->searchItems($search);
63 63
 
64
-			foreach( $serviceItems as $serviceItem )
64
+			foreach ($serviceItems as $serviceItem)
65 65
 			{
66 66
 				try
67 67
 				{
68
-					$serviceManager->getProvider( $serviceItem, $serviceItem->getType() )->updateAsync();
68
+					$serviceManager->getProvider($serviceItem, $serviceItem->getType())->updateAsync();
69 69
 				}
70
-				catch( \Exception $e )
70
+				catch (\Exception $e)
71 71
 				{
72 72
 					$msg = 'Executing updateAsyc() of "%1$s" failed: %2$s';
73
-					$context->getLogger()->log( sprintf( $msg, $serviceItem->getProvider(), $e->getMessage() ) );
73
+					$context->getLogger()->log(sprintf($msg, $serviceItem->getProvider(), $e->getMessage()));
74 74
 				}
75 75
 			}
76 76
 
77
-			$count = count( $serviceItems );
77
+			$count = count($serviceItems);
78 78
 			$start += $count;
79
-			$search->setSlice( $start );
79
+			$search->setSlice($start);
80 80
 		}
81
-		while( $count >= $search->getSliceSize() );
81
+		while ($count >= $search->getSliceSize());
82 82
 	}
83 83
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -66,8 +66,7 @@
 block discarded – undo
66 66
 				try
67 67
 				{
68 68
 					$serviceManager->getProvider( $serviceItem, $serviceItem->getType() )->updateAsync();
69
-				}
70
-				catch( \Exception $e )
69
+				} catch( \Exception $e )
71 70
 				{
72 71
 					$msg = 'Executing updateAsyc() of "%1$s" failed: %2$s';
73 72
 					$context->getLogger()->log( sprintf( $msg, $serviceItem->getProvider(), $e->getMessage() ) );
Please login to merge, or discard this patch.