Completed
Push — master ( 308729...6a7433 )
by Aimeos
02:35
created
tests/Controller/Common/Product/Import/Csv/Processor/Price/StandardTest.php 1 patch
Spacing   +95 added lines, -95 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\Product\Import\Csv\Processor\Done( $this->context, [] );
23
+		$this->endpoint = new \Aimeos\Controller\Common\Product\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
 
@@ -57,38 +57,38 @@  discard block
 block discarded – undo
57 57
 			8 => 1,
58 58
 		);
59 59
 
60
-		$product = $this->create( 'job_csv_test' );
60
+		$product = $this->create('job_csv_test');
61 61
 
62
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, $mapping, $this->endpoint );
63
-		$object->process( $product, $data );
62
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, $mapping, $this->endpoint);
63
+		$object->process($product, $data);
64 64
 
65
-		$product = $this->get( 'job_csv_test' );
66
-		$this->delete( $product );
65
+		$product = $this->get('job_csv_test');
66
+		$this->delete($product);
67 67
 
68 68
 
69 69
 		$listItems = $product->getListItems();
70
-		$listItem = reset( $listItems );
70
+		$listItem = reset($listItems);
71 71
 
72
-		$this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem );
73
-		$this->assertEquals( 1, count( $listItems ) );
72
+		$this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem);
73
+		$this->assertEquals(1, count($listItems));
74 74
 
75
-		$this->assertEquals( 1, $listItem->getStatus() );
76
-		$this->assertEquals( 0, $listItem->getPosition() );
77
-		$this->assertEquals( 'price', $listItem->getDomain() );
78
-		$this->assertEquals( 'default', $listItem->getType() );
75
+		$this->assertEquals(1, $listItem->getStatus());
76
+		$this->assertEquals(0, $listItem->getPosition());
77
+		$this->assertEquals('price', $listItem->getDomain());
78
+		$this->assertEquals('default', $listItem->getType());
79 79
 
80 80
 		$refItem = $listItem->getRefItem();
81 81
 
82
-		$this->assertEquals( 1, $refItem->getStatus() );
83
-		$this->assertEquals( 'default', $refItem->getType() );
84
-		$this->assertEquals( 'product', $refItem->getDomain() );
85
-		$this->assertEquals( 'EUR 1.00', $refItem->getLabel() );
86
-		$this->assertEquals( 5, $refItem->getQuantity() );
87
-		$this->assertEquals( '1.00', $refItem->getValue() );
88
-		$this->assertEquals( '0.20', $refItem->getCosts() );
89
-		$this->assertEquals( '0.10', $refItem->getRebate() );
90
-		$this->assertEquals( '20.00', $refItem->getTaxrate() );
91
-		$this->assertEquals( 1, $refItem->getStatus() );
82
+		$this->assertEquals(1, $refItem->getStatus());
83
+		$this->assertEquals('default', $refItem->getType());
84
+		$this->assertEquals('product', $refItem->getDomain());
85
+		$this->assertEquals('EUR 1.00', $refItem->getLabel());
86
+		$this->assertEquals(5, $refItem->getQuantity());
87
+		$this->assertEquals('1.00', $refItem->getValue());
88
+		$this->assertEquals('0.20', $refItem->getCosts());
89
+		$this->assertEquals('0.10', $refItem->getRebate());
90
+		$this->assertEquals('20.00', $refItem->getTaxrate());
91
+		$this->assertEquals(1, $refItem->getStatus());
92 92
 	}
93 93
 
94 94
 
@@ -116,24 +116,24 @@  discard block
 block discarded – undo
116 116
 			7 => '4.00',
117 117
 		);
118 118
 
119
-		$product = $this->create( 'job_csv_test' );
119
+		$product = $this->create('job_csv_test');
120 120
 
121
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, $mapping, $this->endpoint );
122
-		$object->process( $product, $data );
121
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, $mapping, $this->endpoint);
122
+		$object->process($product, $data);
123 123
 
124
-		$product = $this->get( 'job_csv_test' );
125
-		$this->delete( $product );
124
+		$product = $this->get('job_csv_test');
125
+		$this->delete($product);
126 126
 
127 127
 
128 128
 		$pos = 0;
129 129
 		$listItems = $product->getListItems();
130 130
 
131
-		$this->assertEquals( 4, count( $listItems ) );
131
+		$this->assertEquals(4, count($listItems));
132 132
 
133
-		foreach( $listItems as $listItem )
133
+		foreach ($listItems as $listItem)
134 134
 		{
135
-			$this->assertEquals( $data[$pos++], $listItem->getRefItem()->getCurrencyId() );
136
-			$this->assertEquals( $data[$pos++], $listItem->getRefItem()->getValue() );
135
+			$this->assertEquals($data[$pos++], $listItem->getRefItem()->getCurrencyId());
136
+			$this->assertEquals($data[$pos++], $listItem->getRefItem()->getValue());
137 137
 		}
138 138
 	}
139 139
 
@@ -155,26 +155,26 @@  discard block
 block discarded – undo
155 155
 			1 => '2.00',
156 156
 		);
157 157
 
158
-		$product = $this->create( 'job_csv_test' );
158
+		$product = $this->create('job_csv_test');
159 159
 
160
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, $mapping, $this->endpoint );
161
-		$object->process( $product, $data );
160
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, $mapping, $this->endpoint);
161
+		$object->process($product, $data);
162 162
 
163
-		$product = $this->get( 'job_csv_test' );
163
+		$product = $this->get('job_csv_test');
164 164
 
165
-		$object->process( $product, $dataUpdate );
165
+		$object->process($product, $dataUpdate);
166 166
 
167
-		$product = $this->get( 'job_csv_test' );
168
-		$this->delete( $product );
167
+		$product = $this->get('job_csv_test');
168
+		$this->delete($product);
169 169
 
170 170
 
171 171
 		$listItems = $product->getListItems();
172
-		$listItem = reset( $listItems );
172
+		$listItem = reset($listItems);
173 173
 
174
-		$this->assertEquals( 1, count( $listItems ) );
175
-		$this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem );
174
+		$this->assertEquals(1, count($listItems));
175
+		$this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem);
176 176
 
177
-		$this->assertEquals( '2.00', $listItem->getRefItem()->getValue() );
177
+		$this->assertEquals('2.00', $listItem->getRefItem()->getValue());
178 178
 	}
179 179
 
180 180
 
@@ -190,23 +190,23 @@  discard block
 block discarded – undo
190 190
 			1 => '1.00',
191 191
 		);
192 192
 
193
-		$product = $this->create( 'job_csv_test' );
193
+		$product = $this->create('job_csv_test');
194 194
 
195
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, $mapping, $this->endpoint );
196
-		$object->process( $product, $data );
195
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, $mapping, $this->endpoint);
196
+		$object->process($product, $data);
197 197
 
198
-		$product = $this->get( 'job_csv_test' );
198
+		$product = $this->get('job_csv_test');
199 199
 
200
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, [], $this->endpoint );
201
-		$object->process( $product, [] );
200
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, [], $this->endpoint);
201
+		$object->process($product, []);
202 202
 
203
-		$product = $this->get( 'job_csv_test' );
204
-		$this->delete( $product );
203
+		$product = $this->get('job_csv_test');
204
+		$this->delete($product);
205 205
 
206 206
 
207 207
 		$listItems = $product->getListItems();
208 208
 
209
-		$this->assertEquals( 0, count( $listItems ) );
209
+		$this->assertEquals(0, count($listItems));
210 210
 	}
211 211
 
212 212
 
@@ -226,18 +226,18 @@  discard block
 block discarded – undo
226 226
 			3 => '',
227 227
 		);
228 228
 
229
-		$product = $this->create( 'job_csv_test' );
229
+		$product = $this->create('job_csv_test');
230 230
 
231
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, $mapping, $this->endpoint );
232
-		$object->process( $product, $data );
231
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, $mapping, $this->endpoint);
232
+		$object->process($product, $data);
233 233
 
234
-		$product = $this->get( 'job_csv_test' );
235
-		$this->delete( $product );
234
+		$product = $this->get('job_csv_test');
235
+		$this->delete($product);
236 236
 
237 237
 
238 238
 		$listItems = $product->getListItems();
239 239
 
240
-		$this->assertEquals( 1, count( $listItems ) );
240
+		$this->assertEquals(1, count($listItems));
241 241
 	}
242 242
 
243 243
 
@@ -261,82 +261,82 @@  discard block
 block discarded – undo
261 261
 			5 => 'default',
262 262
 		);
263 263
 
264
-		$this->context->getConfig()->set( 'controller/common/product/import/csv/processor/price/listtypes', array( 'default' ) );
264
+		$this->context->getConfig()->set('controller/common/product/import/csv/processor/price/listtypes', array('default'));
265 265
 
266
-		$product = $this->create( 'job_csv_test' );
266
+		$product = $this->create('job_csv_test');
267 267
 
268
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, $mapping, $this->endpoint );
269
-		$object->process( $product, $data );
268
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, $mapping, $this->endpoint);
269
+		$object->process($product, $data);
270 270
 
271
-		$product = $this->get( 'job_csv_test' );
272
-		$this->delete( $product );
271
+		$product = $this->get('job_csv_test');
272
+		$this->delete($product);
273 273
 
274 274
 
275 275
 		$listItems = $product->getListItems();
276
-		$listItem = reset( $listItems );
276
+		$listItem = reset($listItems);
277 277
 
278
-		$this->assertEquals( 1, count( $listItems ) );
279
-		$this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem );
278
+		$this->assertEquals(1, count($listItems));
279
+		$this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem);
280 280
 
281
-		$this->assertEquals( 'default', $listItem->getType() );
282
-		$this->assertEquals( '2.00', $listItem->getRefItem()->getValue() );
281
+		$this->assertEquals('default', $listItem->getType());
282
+		$this->assertEquals('2.00', $listItem->getRefItem()->getValue());
283 283
 	}
284 284
 
285 285
 
286 286
 	/**
287 287
 	 * @param string $code
288 288
 	 */
289
-	protected function create( $code )
289
+	protected function create($code)
290 290
 	{
291
-		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context );
292
-		$typeManager = $manager->getSubManager( 'type' );
291
+		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context);
292
+		$typeManager = $manager->getSubManager('type');
293 293
 
294 294
 		$typeSearch = $typeManager->createSearch();
295
-		$typeSearch->setConditions( $typeSearch->compare( '==', 'product.type.code', 'default' ) );
296
-		$typeResult = $typeManager->searchItems( $typeSearch );
295
+		$typeSearch->setConditions($typeSearch->compare('==', 'product.type.code', 'default'));
296
+		$typeResult = $typeManager->searchItems($typeSearch);
297 297
 
298
-		if( ( $typeItem = reset( $typeResult ) ) === false ) {
299
-			throw new \RuntimeException( 'No product type "default" found' );
298
+		if (($typeItem = reset($typeResult)) === false) {
299
+			throw new \RuntimeException('No product type "default" found');
300 300
 		}
301 301
 
302 302
 		$item = $manager->createItem();
303
-		$item->setTypeid( $typeItem->getId() );
304
-		$item->setCode( $code );
303
+		$item->setTypeid($typeItem->getId());
304
+		$item->setCode($code);
305 305
 
306
-		return $manager->saveItem( $item );
306
+		return $manager->saveItem($item);
307 307
 	}
308 308
 
309 309
 
310
-	protected function delete( \Aimeos\MShop\Product\Item\Iface $product )
310
+	protected function delete(\Aimeos\MShop\Product\Item\Iface $product)
311 311
 	{
312
-		$priceManager = \Aimeos\MShop\Price\Manager\Factory::createManager( $this->context );
313
-		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context );
314
-		$listManager = $manager->getSubManager( 'lists' );
312
+		$priceManager = \Aimeos\MShop\Price\Manager\Factory::createManager($this->context);
313
+		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context);
314
+		$listManager = $manager->getSubManager('lists');
315 315
 
316
-		foreach( $product->getListItems('price') as $listItem )
316
+		foreach ($product->getListItems('price') as $listItem)
317 317
 		{
318
-			$priceManager->deleteItem( $listItem->getRefItem()->getId() );
319
-			$listManager->deleteItem( $listItem->getId() );
318
+			$priceManager->deleteItem($listItem->getRefItem()->getId());
319
+			$listManager->deleteItem($listItem->getId());
320 320
 		}
321 321
 
322
-		$manager->deleteItem( $product->getId() );
322
+		$manager->deleteItem($product->getId());
323 323
 	}
324 324
 
325 325
 
326 326
 	/**
327 327
 	 * @param string $code
328 328
 	 */
329
-	protected function get( $code )
329
+	protected function get($code)
330 330
 	{
331
-		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context );
331
+		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context);
332 332
 
333 333
 		$search = $manager->createSearch();
334
-		$search->setConditions( $search->compare( '==', 'product.code', $code ) );
334
+		$search->setConditions($search->compare('==', 'product.code', $code));
335 335
 
336
-		$result = $manager->searchItems( $search, array('price') );
336
+		$result = $manager->searchItems($search, array('price'));
337 337
 
338
-		if( ( $item = reset( $result ) ) === false ) {
339
-			throw new \RuntimeException( sprintf( 'No product item for code "%1$s"', $code ) );
338
+		if (($item = reset($result)) === false) {
339
+			throw new \RuntimeException(sprintf('No product item for code "%1$s"', $code));
340 340
 		}
341 341
 
342 342
 		return $item;
Please login to merge, or discard this patch.