@@ -18,119 +18,119 @@ discard block |
||
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 ); |
|
28 | - $config->set( 'controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/valid' ); |
|
27 | + $config->set('controller/jobs/product/import/csv/skip-lines', 1); |
|
28 | + $config->set('controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/valid'); |
|
29 | 29 | |
30 | - $this->object = new \Aimeos\Controller\Jobs\Product\Import\Csv\Standard( $this->context, $this->aimeos ); |
|
30 | + $this->object = new \Aimeos\Controller\Jobs\Product\Import\Csv\Standard($this->context, $this->aimeos); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
34 | 34 | protected function tearDown() |
35 | 35 | { |
36 | - \Aimeos\MShop\Factory::setCache( false ); |
|
36 | + \Aimeos\MShop\Factory::setCache(false); |
|
37 | 37 | \Aimeos\MShop\Factory::clear(); |
38 | 38 | |
39 | 39 | $this->object = null; |
40 | 40 | |
41 | - if( file_exists( 'tmp/import.zip' ) ) { |
|
42 | - unlink( 'tmp/import.zip' ); |
|
41 | + if (file_exists('tmp/import.zip')) { |
|
42 | + unlink('tmp/import.zip'); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | 46 | |
47 | 47 | public function testGetName() |
48 | 48 | { |
49 | - $this->assertEquals( 'Product import CSV', $this->object->getName() ); |
|
49 | + $this->assertEquals('Product import CSV', $this->object->getName()); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | |
53 | 53 | public function testGetDescription() |
54 | 54 | { |
55 | 55 | $text = 'Imports new and updates existing products from CSV files'; |
56 | - $this->assertEquals( $text, $this->object->getDescription() ); |
|
56 | + $this->assertEquals($text, $this->object->getDescription()); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | |
60 | 60 | public function testRun() |
61 | 61 | { |
62 | - $prodcodes = array( 'job_csv_test', 'job_csv_test2' ); |
|
63 | - $nondelete = array( 'attribute', 'product' ); |
|
64 | - $delete = array( 'media', 'price', 'text' ); |
|
62 | + $prodcodes = array('job_csv_test', 'job_csv_test2'); |
|
63 | + $nondelete = array('attribute', 'product'); |
|
64 | + $delete = array('media', 'price', 'text'); |
|
65 | 65 | |
66 | 66 | $convert = array( |
67 | 67 | 1 => 'Text/LatinUTF8', |
68 | 68 | ); |
69 | 69 | |
70 | - $this->context->getConfig()->set( 'controller/jobs/product/import/csv/converter', $convert ); |
|
70 | + $this->context->getConfig()->set('controller/jobs/product/import/csv/converter', $convert); |
|
71 | 71 | |
72 | 72 | $this->object->run(); |
73 | 73 | |
74 | - $result = $this->get( $prodcodes, array_merge( $delete, $nondelete ) ); |
|
75 | - $properties = $this->getProperties( array_keys( $result ) ); |
|
76 | - $this->delete( $prodcodes, $delete, $nondelete ); |
|
74 | + $result = $this->get($prodcodes, array_merge($delete, $nondelete)); |
|
75 | + $properties = $this->getProperties(array_keys($result)); |
|
76 | + $this->delete($prodcodes, $delete, $nondelete); |
|
77 | 77 | |
78 | - $this->assertEquals( 2, count( $result ) ); |
|
79 | - $this->assertEquals( 2, count( $properties ) ); |
|
78 | + $this->assertEquals(2, count($result)); |
|
79 | + $this->assertEquals(2, count($properties)); |
|
80 | 80 | |
81 | - foreach( $result as $product ) { |
|
82 | - $this->assertEquals( 5, count( $product->getListItems() ) ); |
|
81 | + foreach ($result as $product) { |
|
82 | + $this->assertEquals(5, count($product->getListItems())); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | 86 | |
87 | 87 | public function testRunUpdate() |
88 | 88 | { |
89 | - $prodcodes = array( 'job_csv_test', 'job_csv_test2' ); |
|
90 | - $nondelete = array( 'attribute', 'product' ); |
|
91 | - $delete = array( 'media', 'price', 'text' ); |
|
89 | + $prodcodes = array('job_csv_test', 'job_csv_test2'); |
|
90 | + $nondelete = array('attribute', 'product'); |
|
91 | + $delete = array('media', 'price', 'text'); |
|
92 | 92 | |
93 | 93 | $this->object->run(); |
94 | 94 | $this->object->run(); |
95 | 95 | |
96 | - $result = $this->get( $prodcodes, array_merge( $delete, $nondelete ) ); |
|
97 | - $properties = $this->getProperties( array_keys( $result ) ); |
|
98 | - $this->delete( $prodcodes, $delete, $nondelete ); |
|
96 | + $result = $this->get($prodcodes, array_merge($delete, $nondelete)); |
|
97 | + $properties = $this->getProperties(array_keys($result)); |
|
98 | + $this->delete($prodcodes, $delete, $nondelete); |
|
99 | 99 | |
100 | - $this->assertEquals( 2, count( $result ) ); |
|
101 | - $this->assertEquals( 2, count( $properties ) ); |
|
100 | + $this->assertEquals(2, count($result)); |
|
101 | + $this->assertEquals(2, count($properties)); |
|
102 | 102 | |
103 | - foreach( $result as $product ) { |
|
104 | - $this->assertEquals( 5, count( $product->getListItems() ) ); |
|
103 | + foreach ($result as $product) { |
|
104 | + $this->assertEquals(5, count($product->getListItems())); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
108 | 108 | |
109 | 109 | public function testRunPosition() |
110 | 110 | { |
111 | - $prodcodes = array( 'job_csv_test', 'job_csv_test2' ); |
|
112 | - $nondelete = array( 'attribute', 'product' ); |
|
113 | - $delete = array( 'media', 'price', 'text' ); |
|
111 | + $prodcodes = array('job_csv_test', 'job_csv_test2'); |
|
112 | + $nondelete = array('attribute', 'product'); |
|
113 | + $delete = array('media', 'price', 'text'); |
|
114 | 114 | |
115 | 115 | $config = $this->context->getConfig(); |
116 | - $mapping = $config->set( 'controller/jobs/product/import/csv/mapping', [] ); |
|
117 | - $mapping['item'] = array( 0 => 'product.label', 1 => 'product.code' ); |
|
116 | + $mapping = $config->set('controller/jobs/product/import/csv/mapping', []); |
|
117 | + $mapping['item'] = array(0 => 'product.label', 1 => 'product.code'); |
|
118 | 118 | |
119 | - $config->set( 'controller/jobs/product/import/csv/mapping', $mapping ); |
|
120 | - $config->set( 'controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/position' ); |
|
119 | + $config->set('controller/jobs/product/import/csv/mapping', $mapping); |
|
120 | + $config->set('controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/position'); |
|
121 | 121 | |
122 | 122 | $this->object->run(); |
123 | 123 | |
124 | - $result = $this->get( $prodcodes, array_merge( $delete, $nondelete ) ); |
|
125 | - $this->delete( $prodcodes, $delete, $nondelete ); |
|
124 | + $result = $this->get($prodcodes, array_merge($delete, $nondelete)); |
|
125 | + $this->delete($prodcodes, $delete, $nondelete); |
|
126 | 126 | |
127 | - $this->assertEquals( 2, count( $result ) ); |
|
127 | + $this->assertEquals(2, count($result)); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | |
131 | 131 | public function testRunProcessorInvalidPosition() |
132 | 132 | { |
133 | - $prodcodes = array( 'job_csv_test', 'job_csv_test2' ); |
|
133 | + $prodcodes = array('job_csv_test', 'job_csv_test2'); |
|
134 | 134 | |
135 | 135 | $mapping = array( |
136 | 136 | 'item' => array( |
@@ -150,11 +150,11 @@ discard block |
||
150 | 150 | ), |
151 | 151 | ); |
152 | 152 | |
153 | - $this->context->getConfig()->set( 'controller/jobs/product/import/csv/mapping', $mapping ); |
|
153 | + $this->context->getConfig()->set('controller/jobs/product/import/csv/mapping', $mapping); |
|
154 | 154 | |
155 | 155 | $this->object->run(); |
156 | 156 | |
157 | - $this->delete( $prodcodes, array( 'text', 'media' ), [] ); |
|
157 | + $this->delete($prodcodes, array('text', 'media'), []); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | ), |
167 | 167 | ); |
168 | 168 | |
169 | - $this->context->getConfig()->set( 'controller/jobs/product/import/csv/mapping', $mapping ); |
|
169 | + $this->context->getConfig()->set('controller/jobs/product/import/csv/mapping', $mapping); |
|
170 | 170 | |
171 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
171 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
172 | 172 | $this->object->run(); |
173 | 173 | } |
174 | 174 | |
@@ -208,15 +208,15 @@ discard block |
||
208 | 208 | ), |
209 | 209 | ); |
210 | 210 | |
211 | - $this->context->getConfig()->set( 'controller/jobs/product/import/csv/mapping', $mapping ); |
|
211 | + $this->context->getConfig()->set('controller/jobs/product/import/csv/mapping', $mapping); |
|
212 | 212 | |
213 | 213 | $config = $this->context->getConfig(); |
214 | - $config->set( 'controller/jobs/product/import/csv/skip-lines', 0 ); |
|
215 | - $config->set( 'controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/invalid' ); |
|
214 | + $config->set('controller/jobs/product/import/csv/skip-lines', 0); |
|
215 | + $config->set('controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/invalid'); |
|
216 | 216 | |
217 | - $this->object = new \Aimeos\Controller\Jobs\Product\Import\Csv\Standard( $this->context, $this->aimeos ); |
|
217 | + $this->object = new \Aimeos\Controller\Jobs\Product\Import\Csv\Standard($this->context, $this->aimeos); |
|
218 | 218 | |
219 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
219 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
220 | 220 | $this->object->run(); |
221 | 221 | } |
222 | 222 | |
@@ -224,104 +224,104 @@ discard block |
||
224 | 224 | public function testRunBackup() |
225 | 225 | { |
226 | 226 | $config = $this->context->getConfig(); |
227 | - $config->set( 'controller/jobs/product/import/csv/container/type', 'Zip' ); |
|
228 | - $config->set( 'controller/jobs/product/import/csv/location', 'tmp/import.zip' ); |
|
229 | - $config->set( 'controller/jobs/product/import/csv/backup', 'tmp/test-%Y-%m-%d.zip' ); |
|
227 | + $config->set('controller/jobs/product/import/csv/container/type', 'Zip'); |
|
228 | + $config->set('controller/jobs/product/import/csv/location', 'tmp/import.zip'); |
|
229 | + $config->set('controller/jobs/product/import/csv/backup', 'tmp/test-%Y-%m-%d.zip'); |
|
230 | 230 | |
231 | - if( copy( __DIR__ . '/_testfiles/import.zip', 'tmp/import.zip' ) === false ) { |
|
232 | - throw new \RuntimeException( 'Unable to copy test file' ); |
|
231 | + if (copy(__DIR__ . '/_testfiles/import.zip', 'tmp/import.zip') === false) { |
|
232 | + throw new \RuntimeException('Unable to copy test file'); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | $this->object->run(); |
236 | 236 | |
237 | - $filename = strftime( 'tmp/test-%Y-%m-%d.zip' ); |
|
238 | - $this->assertTrue( file_exists( $filename ) ); |
|
237 | + $filename = strftime('tmp/test-%Y-%m-%d.zip'); |
|
238 | + $this->assertTrue(file_exists($filename)); |
|
239 | 239 | |
240 | - unlink( $filename ); |
|
240 | + unlink($filename); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | |
244 | 244 | public function testRunBackupInvalid() |
245 | 245 | { |
246 | 246 | $config = $this->context->getConfig(); |
247 | - $config->set( 'controller/jobs/product/import/csv/container/type', 'Zip' ); |
|
248 | - $config->set( 'controller/jobs/product/import/csv/location', 'tmp/import.zip' ); |
|
249 | - $config->set( 'controller/jobs/product/import/csv/backup', 'tmp/notexist/import.zip' ); |
|
247 | + $config->set('controller/jobs/product/import/csv/container/type', 'Zip'); |
|
248 | + $config->set('controller/jobs/product/import/csv/location', 'tmp/import.zip'); |
|
249 | + $config->set('controller/jobs/product/import/csv/backup', 'tmp/notexist/import.zip'); |
|
250 | 250 | |
251 | - if( copy( __DIR__ . '/_testfiles/import.zip', 'tmp/import.zip' ) === false ) { |
|
252 | - throw new \RuntimeException( 'Unable to copy test file' ); |
|
251 | + if (copy(__DIR__ . '/_testfiles/import.zip', 'tmp/import.zip') === false) { |
|
252 | + throw new \RuntimeException('Unable to copy test file'); |
|
253 | 253 | } |
254 | 254 | |
255 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
255 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
256 | 256 | $this->object->run(); |
257 | 257 | } |
258 | 258 | |
259 | 259 | |
260 | - protected function delete( array $prodcodes, array $delete, array $nondelete ) |
|
260 | + protected function delete(array $prodcodes, array $delete, array $nondelete) |
|
261 | 261 | { |
262 | - $catListManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( $this->context )->getSubmanager( 'lists' ); |
|
263 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context ); |
|
264 | - $listManager = $productManager->getSubManager( 'lists' ); |
|
262 | + $catListManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager($this->context)->getSubmanager('lists'); |
|
263 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context); |
|
264 | + $listManager = $productManager->getSubManager('lists'); |
|
265 | 265 | |
266 | - foreach( $this->get( $prodcodes, $delete + $nondelete ) as $id => $product ) |
|
266 | + foreach ($this->get($prodcodes, $delete + $nondelete) as $id => $product) |
|
267 | 267 | { |
268 | - foreach( $delete as $domain ) |
|
268 | + foreach ($delete as $domain) |
|
269 | 269 | { |
270 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, $domain ); |
|
270 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, $domain); |
|
271 | 271 | |
272 | - foreach( $product->getListItems( $domain ) as $listItem ) |
|
272 | + foreach ($product->getListItems($domain) as $listItem) |
|
273 | 273 | { |
274 | - $manager->deleteItem( $listItem->getRefItem()->getId() ); |
|
275 | - $listManager->deleteItem( $listItem->getId() ); |
|
274 | + $manager->deleteItem($listItem->getRefItem()->getId()); |
|
275 | + $listManager->deleteItem($listItem->getId()); |
|
276 | 276 | } |
277 | 277 | } |
278 | 278 | |
279 | - foreach( $nondelete as $domain ) |
|
279 | + foreach ($nondelete as $domain) |
|
280 | 280 | { |
281 | - $ids = array_keys( $product->getListItems( $domain ) ); |
|
282 | - $listManager->deleteItems( $ids ); |
|
281 | + $ids = array_keys($product->getListItems($domain)); |
|
282 | + $listManager->deleteItems($ids); |
|
283 | 283 | } |
284 | 284 | |
285 | - $productManager->deleteItem( $product->getId() ); |
|
285 | + $productManager->deleteItem($product->getId()); |
|
286 | 286 | |
287 | 287 | $search = $catListManager->createSearch(); |
288 | - $search->setConditions( $search->compare( '==', 'catalog.lists.refid', $id ) ); |
|
289 | - $result = $catListManager->searchItems( $search ); |
|
288 | + $search->setConditions($search->compare('==', 'catalog.lists.refid', $id)); |
|
289 | + $result = $catListManager->searchItems($search); |
|
290 | 290 | |
291 | - $catListManager->deleteItems( array_keys( $result ) ); |
|
291 | + $catListManager->deleteItems(array_keys($result)); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | |
295 | - $attrManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager( $this->context ); |
|
295 | + $attrManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager($this->context); |
|
296 | 296 | |
297 | 297 | $search = $attrManager->createSearch(); |
298 | - $search->setConditions( $search->compare( '==', 'attribute.code', 'import-test' ) ); |
|
298 | + $search->setConditions($search->compare('==', 'attribute.code', 'import-test')); |
|
299 | 299 | |
300 | - $result = $attrManager->searchItems( $search ); |
|
300 | + $result = $attrManager->searchItems($search); |
|
301 | 301 | |
302 | - $attrManager->deleteItems( array_keys( $result ) ); |
|
302 | + $attrManager->deleteItems(array_keys($result)); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | |
306 | - protected function get( array $prodcodes, array $domains ) |
|
306 | + protected function get(array $prodcodes, array $domains) |
|
307 | 307 | { |
308 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context ); |
|
308 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context); |
|
309 | 309 | |
310 | 310 | $search = $productManager->createSearch(); |
311 | - $search->setConditions( $search->compare( '==', 'product.code', $prodcodes ) ); |
|
311 | + $search->setConditions($search->compare('==', 'product.code', $prodcodes)); |
|
312 | 312 | |
313 | - return $productManager->searchItems( $search, $domains ); |
|
313 | + return $productManager->searchItems($search, $domains); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | |
317 | - protected function getProperties( array $prodids ) |
|
317 | + protected function getProperties(array $prodids) |
|
318 | 318 | { |
319 | - $manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context )->getSubManager( 'property' ); |
|
319 | + $manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context)->getSubManager('property'); |
|
320 | 320 | |
321 | 321 | $search = $manager->createSearch(); |
322 | - $search->setConditions( $search->compare( '==', 'product.property.parentid', $prodids ) ); |
|
323 | - $search->setSortations( array( $search->sort( '+', 'product.property.type.code' ) ) ); |
|
322 | + $search->setConditions($search->compare('==', 'product.property.parentid', $prodids)); |
|
323 | + $search->setSortations(array($search->sort('+', 'product.property.type.code'))); |
|
324 | 324 | |
325 | - return $manager->searchItems( $search ); |
|
325 | + return $manager->searchItems($search); |
|
326 | 326 | } |
327 | 327 | } |
328 | 328 | \ No newline at end of file |
@@ -19,18 +19,18 @@ discard block |
||
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 |
||
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 | } |
@@ -16,8 +16,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -40,20 +40,20 @@ discard block |
||
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->getProducts() as $item ) |
|
47 | + foreach ($order->getProducts() as $item) |
|
48 | 48 | { |
49 | 49 | $data = []; |
50 | 50 | $list = $item->toArray(); |
51 | 51 | |
52 | - foreach( $item->getAttributes() as $attrItem ) |
|
52 | + foreach ($item->getAttributes() as $attrItem) |
|
53 | 53 | { |
54 | - foreach( $attrItem->toArray() as $key => $value ) |
|
54 | + foreach ($attrItem->toArray() as $key => $value) |
|
55 | 55 | { |
56 | - if( isset( $list[$key] ) ) { |
|
56 | + if (isset($list[$key])) { |
|
57 | 57 | $list[$key] .= "\n" . $value; |
58 | 58 | } else { |
59 | 59 | $list[$key] = $value; |
@@ -61,16 +61,16 @@ discard block |
||
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
64 | - foreach( $this->getMapping() as $pos => $key ) |
|
64 | + foreach ($this->getMapping() as $pos => $key) |
|
65 | 65 | { |
66 | - if( array_key_exists( $key, $list ) ) { |
|
66 | + if (array_key_exists($key, $list)) { |
|
67 | 67 | $data[$pos] = $list[$key]; |
68 | 68 | } else { |
69 | 69 | $data[$pos] = ''; |
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | - ksort( $data ); |
|
73 | + ksort($data); |
|
74 | 74 | $result[] = $data; |
75 | 75 | } |
76 | 76 |
@@ -29,59 +29,59 @@ |
||
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 | } |
@@ -18,95 +18,95 @@ |
||
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(); |
@@ -28,7 +28,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -40,25 +40,25 @@ discard block |
||
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 | $services = $order->getServices(); |
47 | 47 | |
48 | - krsort( $services ); |
|
48 | + krsort($services); |
|
49 | 49 | |
50 | - foreach( $services as $list ) |
|
50 | + foreach ($services as $list) |
|
51 | 51 | { |
52 | - foreach( $list as $item ) |
|
52 | + foreach ($list as $item) |
|
53 | 53 | { |
54 | 54 | $data = []; |
55 | 55 | $list = $item->toArray(); |
56 | 56 | |
57 | - foreach( $item->getAttributes() as $attrItem ) |
|
57 | + foreach ($item->getAttributes() as $attrItem) |
|
58 | 58 | { |
59 | - foreach( $attrItem->toArray() as $key => $value ) |
|
59 | + foreach ($attrItem->toArray() as $key => $value) |
|
60 | 60 | { |
61 | - if( isset( $list[$key] ) ) { |
|
61 | + if (isset($list[$key])) { |
|
62 | 62 | $list[$key] .= "\n" . $value; |
63 | 63 | } else { |
64 | 64 | $list[$key] = $value; |
@@ -66,16 +66,16 @@ discard block |
||
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | - foreach( $this->getMapping() as $pos => $key ) |
|
69 | + foreach ($this->getMapping() as $pos => $key) |
|
70 | 70 | { |
71 | - if( array_key_exists( $key, $list ) ) { |
|
71 | + if (array_key_exists($key, $list)) { |
|
72 | 72 | $data[$pos] = $list[$key]; |
73 | 73 | } else { |
74 | 74 | $data[$pos] = ''; |
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
78 | - ksort( $data ); |
|
78 | + ksort($data); |
|
79 | 79 | $result[] = $data; |
80 | 80 | } |
81 | 81 | } |
@@ -15,16 +15,16 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |