Completed
Push — master ( d145d9...24b9f7 )
by Aimeos
01:52
created
Controller/Common/Product/Import/Csv/Processor/Property/StandardTest.php 1 patch
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -15,16 +15,16 @@  discard block
 block discarded – undo
15 15
 
16 16
 	protected function setUp()
17 17
 	{
18
-		\Aimeos\MShop\Factory::setCache( true );
18
+		\Aimeos\MShop\Factory::setCache(true);
19 19
 
20 20
 		$this->context = \TestHelperCntl::getContext();
21
-		$this->endpoint = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done( $this->context, [] );
21
+		$this->endpoint = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done($this->context, []);
22 22
 	}
23 23
 
24 24
 
25 25
 	protected function tearDown()
26 26
 	{
27
-		\Aimeos\MShop\Factory::setCache( false );
27
+		\Aimeos\MShop\Factory::setCache(false);
28 28
 		\Aimeos\MShop\Factory::clear();
29 29
 	}
30 30
 
@@ -47,29 +47,29 @@  discard block
 block discarded – undo
47 47
 			4 => '50',
48 48
 		);
49 49
 
50
-		$product = $this->create( 'job_csv_test' );
50
+		$product = $this->create('job_csv_test');
51 51
 
52
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Property\Standard( $this->context, $mapping, $this->endpoint );
53
-		$object->process( $product, $data );
52
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Property\Standard($this->context, $mapping, $this->endpoint);
53
+		$object->process($product, $data);
54 54
 
55
-		$product = $this->get( 'job_csv_test' );
56
-		$items = $this->getProperties( $product->getId() );
57
-		$this->delete( $product );
55
+		$product = $this->get('job_csv_test');
56
+		$items = $this->getProperties($product->getId());
57
+		$this->delete($product);
58 58
 
59 59
 
60 60
 		$pos = 0;
61 61
 		$expected = array(
62
-			array( 'package-weight', '3.00', 'de' ),
63
-			array( 'package-width', '50', null ),
62
+			array('package-weight', '3.00', 'de'),
63
+			array('package-width', '50', null),
64 64
 		);
65 65
 
66
-		$this->assertEquals( 2, count( $items ) );
66
+		$this->assertEquals(2, count($items));
67 67
 
68
-		foreach( $items as $item )
68
+		foreach ($items as $item)
69 69
 		{
70
-			$this->assertEquals( $expected[$pos][0], $item->getType() );
71
-			$this->assertEquals( $expected[$pos][1], $item->getValue() );
72
-			$this->assertEquals( $expected[$pos][2], $item->getLanguageId() );
70
+			$this->assertEquals($expected[$pos][0], $item->getType());
71
+			$this->assertEquals($expected[$pos][1], $item->getValue());
72
+			$this->assertEquals($expected[$pos][2], $item->getLanguageId());
73 73
 			$pos++;
74 74
 		}
75 75
 	}
@@ -92,27 +92,27 @@  discard block
 block discarded – undo
92 92
 			1 => '10',
93 93
 		);
94 94
 
95
-		$product = $this->create( 'job_csv_test' );
95
+		$product = $this->create('job_csv_test');
96 96
 
97
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Property\Standard( $this->context, $mapping, $this->endpoint );
98
-		$object->process( $product, $data );
97
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Property\Standard($this->context, $mapping, $this->endpoint);
98
+		$object->process($product, $data);
99 99
 
100
-		$product = $this->get( 'job_csv_test' );
100
+		$product = $this->get('job_csv_test');
101 101
 
102
-		$object->process( $product, $dataUpdate );
102
+		$object->process($product, $dataUpdate);
103 103
 
104
-		$product = $this->get( 'job_csv_test' );
105
-		$items = $this->getProperties( $product->getId() );
106
-		$this->delete( $product );
104
+		$product = $this->get('job_csv_test');
105
+		$items = $this->getProperties($product->getId());
106
+		$this->delete($product);
107 107
 
108 108
 
109
-		$item = reset( $items );
109
+		$item = reset($items);
110 110
 
111
-		$this->assertEquals( 1, count( $items ) );
112
-		$this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Item\\Property\\Iface', $item );
111
+		$this->assertEquals(1, count($items));
112
+		$this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Item\\Property\\Iface', $item);
113 113
 
114
-		$this->assertEquals( 'package-height', $item->getType() );
115
-		$this->assertEquals( '10', $item->getValue() );
114
+		$this->assertEquals('package-height', $item->getType());
115
+		$this->assertEquals('10', $item->getValue());
116 116
 	}
117 117
 
118 118
 
@@ -128,22 +128,22 @@  discard block
 block discarded – undo
128 128
 			1 => '3.00',
129 129
 		);
130 130
 
131
-		$product = $this->create( 'job_csv_test' );
131
+		$product = $this->create('job_csv_test');
132 132
 
133
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Property\Standard( $this->context, $mapping, $this->endpoint );
134
-		$object->process( $product, $data );
133
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Property\Standard($this->context, $mapping, $this->endpoint);
134
+		$object->process($product, $data);
135 135
 
136
-		$product = $this->get( 'job_csv_test' );
136
+		$product = $this->get('job_csv_test');
137 137
 
138
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Property\Standard( $this->context, [], $this->endpoint );
139
-		$object->process( $product, [] );
138
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Property\Standard($this->context, [], $this->endpoint);
139
+		$object->process($product, []);
140 140
 
141
-		$product = $this->get( 'job_csv_test' );
142
-		$items = $this->getProperties( $product->getId() );
143
-		$this->delete( $product );
141
+		$product = $this->get('job_csv_test');
142
+		$items = $this->getProperties($product->getId());
143
+		$this->delete($product);
144 144
 
145 145
 
146
-		$this->assertEquals( 0, count( $items ) );
146
+		$this->assertEquals(0, count($items));
147 147
 	}
148 148
 
149 149
 
@@ -163,85 +163,85 @@  discard block
 block discarded – undo
163 163
 			3 => '3.00',
164 164
 		);
165 165
 
166
-		$product = $this->create( 'job_csv_test' );
166
+		$product = $this->create('job_csv_test');
167 167
 
168
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Property\Standard( $this->context, $mapping, $this->endpoint );
169
-		$object->process( $product, $data );
168
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Property\Standard($this->context, $mapping, $this->endpoint);
169
+		$object->process($product, $data);
170 170
 
171
-		$product = $this->get( 'job_csv_test' );
172
-		$items = $this->getProperties( $product->getId() );
173
-		$this->delete( $product );
171
+		$product = $this->get('job_csv_test');
172
+		$items = $this->getProperties($product->getId());
173
+		$this->delete($product);
174 174
 
175 175
 
176
-		$this->assertEquals( 1, count( $items ) );
176
+		$this->assertEquals(1, count($items));
177 177
 	}
178 178
 
179 179
 
180 180
 	/**
181 181
 	 * @param string $code
182 182
 	 */
183
-	protected function create( $code )
183
+	protected function create($code)
184 184
 	{
185
-		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context );
186
-		$typeManager = $manager->getSubManager( 'type' );
185
+		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context);
186
+		$typeManager = $manager->getSubManager('type');
187 187
 
188 188
 		$typeSearch = $typeManager->createSearch();
189
-		$typeSearch->setConditions( $typeSearch->compare( '==', 'product.type.code', 'default' ) );
190
-		$typeResult = $typeManager->searchItems( $typeSearch );
189
+		$typeSearch->setConditions($typeSearch->compare('==', 'product.type.code', 'default'));
190
+		$typeResult = $typeManager->searchItems($typeSearch);
191 191
 
192
-		if( ( $typeItem = reset( $typeResult ) ) === false ) {
193
-			throw new \RuntimeException( 'No product type "default" found' );
192
+		if (($typeItem = reset($typeResult)) === false) {
193
+			throw new \RuntimeException('No product type "default" found');
194 194
 		}
195 195
 
196 196
 		$item = $manager->createItem();
197
-		$item->setTypeid( $typeItem->getId() );
198
-		$item->setCode( $code );
197
+		$item->setTypeid($typeItem->getId());
198
+		$item->setCode($code);
199 199
 
200
-		return $manager->saveItem( $item );
200
+		return $manager->saveItem($item);
201 201
 	}
202 202
 
203 203
 
204
-	protected function delete( \Aimeos\MShop\Product\Item\Iface $product )
204
+	protected function delete(\Aimeos\MShop\Product\Item\Iface $product)
205 205
 	{
206
-		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context );
207
-		$listManager = $manager->getSubManager( 'lists' );
206
+		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context);
207
+		$listManager = $manager->getSubManager('lists');
208 208
 
209
-		foreach( $product->getListItems('attribute') as $listItem ) {
210
-			$listManager->deleteItem( $listItem->getId() );
209
+		foreach ($product->getListItems('attribute') as $listItem) {
210
+			$listManager->deleteItem($listItem->getId());
211 211
 		}
212 212
 
213
-		$manager->deleteItem( $product->getId() );
213
+		$manager->deleteItem($product->getId());
214 214
 	}
215 215
 
216 216
 
217 217
 	/**
218 218
 	 * @param string $code
219 219
 	 */
220
-	protected function get( $code )
220
+	protected function get($code)
221 221
 	{
222
-		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context );
222
+		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context);
223 223
 
224 224
 		$search = $manager->createSearch();
225
-		$search->setConditions( $search->compare( '==', 'product.code', $code ) );
225
+		$search->setConditions($search->compare('==', 'product.code', $code));
226 226
 
227
-		$result = $manager->searchItems( $search, array('attribute') );
227
+		$result = $manager->searchItems($search, array('attribute'));
228 228
 
229
-		if( ( $item = reset( $result ) ) === false ) {
230
-			throw new \RuntimeException( sprintf( 'No product item for code "%1$s"', $code ) );
229
+		if (($item = reset($result)) === false) {
230
+			throw new \RuntimeException(sprintf('No product item for code "%1$s"', $code));
231 231
 		}
232 232
 
233 233
 		return $item;
234 234
 	}
235 235
 
236 236
 
237
-	protected function getProperties( $prodid )
237
+	protected function getProperties($prodid)
238 238
 	{
239
-		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context )->getSubManager( 'property' );
239
+		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context)->getSubManager('property');
240 240
 
241 241
 		$search = $manager->createSearch();
242
-		$search->setConditions( $search->compare( '==', 'product.property.parentid', $prodid ) );
243
-		$search->setSortations( array( $search->sort( '+', 'product.property.type.code' ) ) );
242
+		$search->setConditions($search->compare('==', 'product.property.parentid', $prodid));
243
+		$search->setSortations(array($search->sort('+', 'product.property.type.code')));
244 244
 
245
-		return $manager->searchItems( $search );
245
+		return $manager->searchItems($search);
246 246
 	}
247 247
 }
248 248
\ No newline at end of file
Please login to merge, or discard this patch.