@@ -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(); |
@@ -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 |
@@ -29,7 +29,7 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -66,8 +66,7 @@ |
||
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() ) ); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function getName() |
30 | 30 | { |
31 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Product export' ); |
|
31 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Product export'); |
|
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', 'Exports all available products' ); |
|
42 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Exports all available products'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | public function run() |
52 | 52 | { |
53 | 53 | $container = $this->createContainer(); |
54 | - $this->export( $container ); |
|
54 | + $this->export($container); |
|
55 | 55 | $container->close(); |
56 | 56 | } |
57 | 57 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @param \Aimeos\MW\Container\Content\Iface $content File content object |
63 | 63 | * @param \Aimeos\MShop\Product\Item\Iface[] $items List of product items |
64 | 64 | */ |
65 | - protected function addItems( \Aimeos\MW\Container\Content\Iface $content, array $items ) |
|
65 | + protected function addItems(\Aimeos\MW\Container\Content\Iface $content, array $items) |
|
66 | 66 | { |
67 | 67 | /** controller/jobs/product/export/standard/template-items |
68 | 68 | * Relative path to the XML items template of the product site map job controller. |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | $view->exportItems = $items; |
96 | 96 | |
97 | - $content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) ); |
|
97 | + $content->add($view->render($context->getConfig()->get($tplconf, $default))); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @see controller/jobs/product/export/max-items |
124 | 124 | * @see controller/jobs/product/export/max-query |
125 | 125 | */ |
126 | - $location = $config->get( 'controller/jobs/product/export/location', sys_get_temp_dir() ); |
|
126 | + $location = $config->get('controller/jobs/product/export/location', sys_get_temp_dir()); |
|
127 | 127 | |
128 | 128 | /** controller/jobs/product/export/standard/container/type |
129 | 129 | * List of file container options for the export files |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @see controller/jobs/product/export/max-items |
141 | 141 | * @see controller/jobs/product/export/max-query |
142 | 142 | */ |
143 | - $container = $config->get( 'controller/jobs/product/export/standard/container/type', 'Directory' ); |
|
143 | + $container = $config->get('controller/jobs/product/export/standard/container/type', 'Directory'); |
|
144 | 144 | |
145 | 145 | /** controller/jobs/product/export/standard/container/content |
146 | 146 | * List of file container options for the export files |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @see controller/jobs/product/export/max-items |
158 | 158 | * @see controller/jobs/product/export/max-query |
159 | 159 | */ |
160 | - $content = $config->get( 'controller/jobs/product/export/standard/container/content', 'Binary' ); |
|
160 | + $content = $config->get('controller/jobs/product/export/standard/container/content', 'Binary'); |
|
161 | 161 | |
162 | 162 | /** controller/jobs/product/export/standard/container/options |
163 | 163 | * List of file container options for the export files |
@@ -174,9 +174,9 @@ discard block |
||
174 | 174 | * @see controller/jobs/product/export/max-items |
175 | 175 | * @see controller/jobs/product/export/max-query |
176 | 176 | */ |
177 | - $options = $config->get( 'controller/jobs/product/export/standard/container/options', [] ); |
|
177 | + $options = $config->get('controller/jobs/product/export/standard/container/options', []); |
|
178 | 178 | |
179 | - return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options ); |
|
179 | + return \Aimeos\MW\Container\Factory::getContainer($location, $container, $content, $options); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @param integer $filenum New file number |
188 | 188 | * @return \Aimeos\MW\Container\Content\Iface New content object |
189 | 189 | */ |
190 | - protected function createContent( \Aimeos\MW\Container\Iface $container, $filenum ) |
|
190 | + protected function createContent(\Aimeos\MW\Container\Iface $container, $filenum) |
|
191 | 191 | { |
192 | 192 | /** controller/jobs/product/export/standard/template-header |
193 | 193 | * Relative path to the XML site map header template of the product site map job controller. |
@@ -217,9 +217,9 @@ discard block |
||
217 | 217 | $context = $this->getContext(); |
218 | 218 | $view = $context->getView(); |
219 | 219 | |
220 | - $content = $container->create( $this->getFilename( $filenum ) ); |
|
221 | - $content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) ); |
|
222 | - $container->add( $content ); |
|
220 | + $content = $container->create($this->getFilename($filenum)); |
|
221 | + $content->add($view->render($context->getConfig()->get($tplconf, $default))); |
|
222 | + $container->add($content); |
|
223 | 223 | |
224 | 224 | return $content; |
225 | 225 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | * |
231 | 231 | * @param \Aimeos\MW\Container\Content\Iface $content |
232 | 232 | */ |
233 | - protected function closeContent( \Aimeos\MW\Container\Content\Iface $content ) |
|
233 | + protected function closeContent(\Aimeos\MW\Container\Content\Iface $content) |
|
234 | 234 | { |
235 | 235 | /** controller/jobs/product/export/standard/template-footer |
236 | 236 | * Relative path to the XML site map footer template of the product site map job controller. |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | $context = $this->getContext(); |
261 | 261 | $view = $context->getView(); |
262 | 262 | |
263 | - $content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) ); |
|
263 | + $content->add($view->render($context->getConfig()->get($tplconf, $default))); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | |
@@ -270,45 +270,45 @@ discard block |
||
270 | 270 | * @param \Aimeos\MW\Container\Iface $container Container object |
271 | 271 | * @return array List of content (file) names |
272 | 272 | */ |
273 | - protected function export( \Aimeos\MW\Container\Iface $container ) |
|
273 | + protected function export(\Aimeos\MW\Container\Iface $container) |
|
274 | 274 | { |
275 | - $default = array( 'attribute', 'media', 'price', 'product', 'text' ); |
|
275 | + $default = array('attribute', 'media', 'price', 'product', 'text'); |
|
276 | 276 | |
277 | - $domains = $this->getConfig( 'domains', $default ); |
|
278 | - $maxItems = $this->getConfig( 'max-items', 10000 ); |
|
279 | - $maxQuery = $this->getConfig( 'max-query', 1000 ); |
|
277 | + $domains = $this->getConfig('domains', $default); |
|
278 | + $maxItems = $this->getConfig('max-items', 10000); |
|
279 | + $maxQuery = $this->getConfig('max-query', 1000); |
|
280 | 280 | |
281 | 281 | $start = 0; $filenum = 1; |
282 | 282 | $names = []; |
283 | 283 | |
284 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
284 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
285 | 285 | |
286 | - $search = $productManager->createSearch( true ); |
|
287 | - $search->setSortations( array( $search->sort( '+', 'product.id' ) ) ); |
|
288 | - $search->setSlice( 0, $maxQuery ); |
|
286 | + $search = $productManager->createSearch(true); |
|
287 | + $search->setSortations(array($search->sort('+', 'product.id'))); |
|
288 | + $search->setSlice(0, $maxQuery); |
|
289 | 289 | |
290 | - $content = $this->createContent( $container, $filenum ); |
|
290 | + $content = $this->createContent($container, $filenum); |
|
291 | 291 | $names[] = $content->getResource(); |
292 | 292 | |
293 | 293 | do |
294 | 294 | { |
295 | - $items = $productManager->searchItems( $search, $domains ); |
|
296 | - $this->addItems( $content, $items ); |
|
295 | + $items = $productManager->searchItems($search, $domains); |
|
296 | + $this->addItems($content, $items); |
|
297 | 297 | |
298 | - $count = count( $items ); |
|
298 | + $count = count($items); |
|
299 | 299 | $start += $count; |
300 | - $search->setSlice( $start, $maxQuery ); |
|
300 | + $search->setSlice($start, $maxQuery); |
|
301 | 301 | |
302 | - if( $start + $maxQuery > $maxItems * $filenum ) |
|
302 | + if ($start + $maxQuery > $maxItems * $filenum) |
|
303 | 303 | { |
304 | - $this->closeContent( $content ); |
|
305 | - $content = $this->createContent( $container, ++$filenum ); |
|
304 | + $this->closeContent($content); |
|
305 | + $content = $this->createContent($container, ++$filenum); |
|
306 | 306 | $names[] = $content->getResource(); |
307 | 307 | } |
308 | 308 | } |
309 | - while( $count >= $search->getSliceSize() ); |
|
309 | + while ($count >= $search->getSliceSize()); |
|
310 | 310 | |
311 | - $this->closeContent( $content ); |
|
311 | + $this->closeContent($content); |
|
312 | 312 | |
313 | 313 | return $names; |
314 | 314 | } |
@@ -321,11 +321,11 @@ discard block |
||
321 | 321 | * @param mixed $default Default value if name is unknown |
322 | 322 | * @return mixed Configuration value |
323 | 323 | */ |
324 | - protected function getConfig( $name, $default = null ) |
|
324 | + protected function getConfig($name, $default = null) |
|
325 | 325 | { |
326 | 326 | $config = $this->getContext()->getConfig(); |
327 | 327 | |
328 | - switch( $name ) |
|
328 | + switch ($name) |
|
329 | 329 | { |
330 | 330 | case 'domain': |
331 | 331 | /** controller/jobs/product/export/domains |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | * @see controller/jobs/product/export/max-items |
349 | 349 | * @see controller/jobs/product/export/max-query |
350 | 350 | */ |
351 | - return $config->get( 'controller/jobs/product/export/domains', $default ); |
|
351 | + return $config->get('controller/jobs/product/export/domains', $default); |
|
352 | 352 | |
353 | 353 | case 'max-items': |
354 | 354 | /** controller/jobs/product/export/max-items |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | * @see controller/jobs/product/export/max-query |
372 | 372 | * @see controller/jobs/product/export/domains |
373 | 373 | */ |
374 | - return $config->get( 'controller/jobs/product/export/max-items', $default ); |
|
374 | + return $config->get('controller/jobs/product/export/max-items', $default); |
|
375 | 375 | |
376 | 376 | case 'max-query': |
377 | 377 | /** controller/jobs/product/export/max-query |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | * @see controller/jobs/product/export/max-items |
395 | 395 | * @see controller/jobs/product/export/domains |
396 | 396 | */ |
397 | - return $config->get( 'controller/jobs/product/export/max-query', $default ); |
|
397 | + return $config->get('controller/jobs/product/export/max-query', $default); |
|
398 | 398 | |
399 | 399 | case 'filename': |
400 | 400 | /** controller/jobs/product/export/filename |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | * @see controller/jobs/product/export/max-query |
416 | 416 | * @see controller/jobs/product/export/domains |
417 | 417 | */ |
418 | - return $config->get( 'controller/jobs/product/export/filename', $default ); |
|
418 | + return $config->get('controller/jobs/product/export/filename', $default); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | return $default; |
@@ -428,8 +428,8 @@ discard block |
||
428 | 428 | * @param integer $number Current file number |
429 | 429 | * @return string New file name |
430 | 430 | */ |
431 | - protected function getFilename( $number ) |
|
431 | + protected function getFilename($number) |
|
432 | 432 | { |
433 | - return sprintf( $this->getConfig( 'filename', 'aimeos-products-%1$d_%2$s.xml' ), $number, date( 'Y-m-d_H:i:s' ) ); |
|
433 | + return sprintf($this->getConfig('filename', 'aimeos-products-%1$d_%2$s.xml'), $number, date('Y-m-d_H:i:s')); |
|
434 | 434 | } |
435 | 435 | } |
@@ -18,18 +18,18 @@ 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 | |
26 | - $this->object = new \Aimeos\Controller\Jobs\Product\Export\Standard( $this->context, $this->aimeos ); |
|
26 | + $this->object = new \Aimeos\Controller\Jobs\Product\Export\Standard($this->context, $this->aimeos); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | |
30 | 30 | protected function tearDown() |
31 | 31 | { |
32 | - \Aimeos\MShop\Factory::setCache( false ); |
|
32 | + \Aimeos\MShop\Factory::setCache(false); |
|
33 | 33 | \Aimeos\MShop\Factory::clear(); |
34 | 34 | |
35 | 35 | $this->object = null; |
@@ -38,34 +38,34 @@ discard block |
||
38 | 38 | |
39 | 39 | public function testGetName() |
40 | 40 | { |
41 | - $this->assertEquals( 'Product export', $this->object->getName() ); |
|
41 | + $this->assertEquals('Product export', $this->object->getName()); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | |
45 | 45 | public function testGetDescription() |
46 | 46 | { |
47 | 47 | $text = 'Exports all available products'; |
48 | - $this->assertEquals( $text, $this->object->getDescription() ); |
|
48 | + $this->assertEquals($text, $this->object->getDescription()); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
52 | 52 | public function testRun() |
53 | 53 | { |
54 | - $this->context->getConfig()->set( 'controller/jobs/product/export/filename', 'aimeos-products-%1$d.xml' ); |
|
54 | + $this->context->getConfig()->set('controller/jobs/product/export/filename', 'aimeos-products-%1$d.xml'); |
|
55 | 55 | |
56 | 56 | $this->object->run(); |
57 | 57 | |
58 | 58 | $ds = DIRECTORY_SEPARATOR; |
59 | - $this->assertFileExists( 'tmp' . $ds . 'aimeos-products-1.xml' ); |
|
60 | - $this->assertFileExists( 'tmp' . $ds . 'aimeos-products-2.xml' ); |
|
59 | + $this->assertFileExists('tmp' . $ds . 'aimeos-products-1.xml'); |
|
60 | + $this->assertFileExists('tmp' . $ds . 'aimeos-products-2.xml'); |
|
61 | 61 | |
62 | - $file1 = file_get_contents( 'tmp' . $ds . 'aimeos-products-1.xml' ); |
|
63 | - $file2 = file_get_contents( 'tmp' . $ds . 'aimeos-products-2.xml' ); |
|
62 | + $file1 = file_get_contents('tmp' . $ds . 'aimeos-products-1.xml'); |
|
63 | + $file2 = file_get_contents('tmp' . $ds . 'aimeos-products-2.xml'); |
|
64 | 64 | |
65 | - unlink( 'tmp' . $ds . 'aimeos-products-1.xml' ); |
|
66 | - unlink( 'tmp' . $ds . 'aimeos-products-2.xml' ); |
|
65 | + unlink('tmp' . $ds . 'aimeos-products-1.xml'); |
|
66 | + unlink('tmp' . $ds . 'aimeos-products-2.xml'); |
|
67 | 67 | |
68 | - $this->assertContains( 'CNE', $file1 ); |
|
69 | - $this->assertContains( 'U:BUNDLE', $file2 ); |
|
68 | + $this->assertContains('CNE', $file1); |
|
69 | + $this->assertContains('U:BUNDLE', $file2); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | \ No newline at end of file |
@@ -133,7 +133,7 @@ |
||
133 | 133 | * |
134 | 134 | * @param array $list Associative list of key/value pairs |
135 | 135 | * @param string $key Key for the value to retrieve |
136 | - * @param mixed $default Default value if key isn't found |
|
136 | + * @param string $default Default value if key isn't found |
|
137 | 137 | * @param mixed Value for the key in the list of the default value |
138 | 138 | */ |
139 | 139 | protected function getValue( array $list, $key, $default ) |
@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
33 | 33 | * @param \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $object Decorated processor |
34 | 34 | */ |
35 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
36 | - \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $object = null ) |
|
35 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
36 | + \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $object = null) |
|
37 | 37 | { |
38 | 38 | $this->context = $context; |
39 | 39 | $this->mapping = $mapping; |
@@ -48,13 +48,13 @@ discard block |
||
48 | 48 | * @param integer $pos Computed position of the list item in the associated list of items |
49 | 49 | * @return array Given associative list enriched by default values if they were not already set |
50 | 50 | */ |
51 | - protected function addListItemDefaults( array $list, $pos ) |
|
51 | + protected function addListItemDefaults(array $list, $pos) |
|
52 | 52 | { |
53 | - if( !isset( $list['catalog.lists.position'] ) ) { |
|
53 | + if (!isset($list['catalog.lists.position'])) { |
|
54 | 54 | $list['catalog.lists.position'] = $pos; |
55 | 55 | } |
56 | 56 | |
57 | - if( !isset( $list['catalog.lists.status'] ) ) { |
|
57 | + if (!isset($list['catalog.lists.status'])) { |
|
58 | 58 | $list['catalog.lists.status'] = 1; |
59 | 59 | } |
60 | 60 | |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | */ |
93 | 93 | protected function getObject() |
94 | 94 | { |
95 | - if( $this->object === null ) { |
|
96 | - throw new \Aimeos\Controller\Jobs\Exception( 'No processor object available' ); |
|
95 | + if ($this->object === null) { |
|
96 | + throw new \Aimeos\Controller\Jobs\Exception('No processor object available'); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | return $this->object; |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | * @param mixed $default Default value if key isn't found |
109 | 109 | * @param mixed Value for the key in the list of the default value |
110 | 110 | */ |
111 | - protected function getValue( array $list, $key, $default ) |
|
111 | + protected function getValue(array $list, $key, $default) |
|
112 | 112 | { |
113 | - return ( isset( $list[$key] ) ? $list[$key] : $default ); |
|
113 | + return (isset($list[$key]) ? $list[$key] : $default); |
|
114 | 114 | } |
115 | 115 | } |
@@ -248,6 +248,9 @@ |
||
248 | 248 | } |
249 | 249 | |
250 | 250 | |
251 | + /** |
|
252 | + * @param string $catcode |
|
253 | + */ |
|
251 | 254 | protected function get( $catcode, array $domains = [] ) |
252 | 255 | { |
253 | 256 | $manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( $this->context ); |
@@ -18,65 +18,65 @@ 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/catalog/import/csv/skip-lines', 1 ); |
|
28 | - $config->set( 'controller/jobs/catalog/import/csv/location', __DIR__ . '/_testfiles/valid' ); |
|
27 | + $config->set('controller/jobs/catalog/import/csv/skip-lines', 1); |
|
28 | + $config->set('controller/jobs/catalog/import/csv/location', __DIR__ . '/_testfiles/valid'); |
|
29 | 29 | |
30 | - $this->object = new \Aimeos\Controller\Jobs\Catalog\Import\Csv\Standard( $this->context, $this->aimeos ); |
|
30 | + $this->object = new \Aimeos\Controller\Jobs\Catalog\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( 'Catalog import CSV', $this->object->getName() ); |
|
49 | + $this->assertEquals('Catalog 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 categories 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 | - $catcodes = array( 'job_csv_test', 'job_csv_test2', 'job_csv_test3', 'job_csv_test4' ); |
|
63 | - $domains = array( 'media', 'text' ); |
|
62 | + $catcodes = array('job_csv_test', 'job_csv_test2', 'job_csv_test3', 'job_csv_test4'); |
|
63 | + $domains = array('media', 'text'); |
|
64 | 64 | |
65 | 65 | $convert = array( |
66 | 66 | 1 => 'Text/LatinUTF8', |
67 | 67 | ); |
68 | 68 | |
69 | - $this->context->getConfig()->set( 'controller/jobs/catalog/import/csv/converter', $convert ); |
|
69 | + $this->context->getConfig()->set('controller/jobs/catalog/import/csv/converter', $convert); |
|
70 | 70 | |
71 | 71 | $this->object->run(); |
72 | 72 | |
73 | - $tree = $this->get( 'job_csv_test', $domains ); |
|
74 | - $this->delete( $tree, $domains ); |
|
73 | + $tree = $this->get('job_csv_test', $domains); |
|
74 | + $this->delete($tree, $domains); |
|
75 | 75 | |
76 | - $this->assertEquals( 2, count( $tree->getListItems() ) ); |
|
76 | + $this->assertEquals(2, count($tree->getListItems())); |
|
77 | 77 | |
78 | - foreach( $tree->getChildren() as $node ) { |
|
79 | - $this->assertEquals( 2, count( $node->getListItems() ) ); |
|
78 | + foreach ($tree->getChildren() as $node) { |
|
79 | + $this->assertEquals(2, count($node->getListItems())); |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
@@ -86,13 +86,13 @@ discard block |
||
86 | 86 | $this->object->run(); |
87 | 87 | $this->object->run(); |
88 | 88 | |
89 | - $tree = $this->get( 'job_csv_test', ['media', 'text'] ); |
|
90 | - $this->delete( $tree, ['media', 'text'] ); |
|
89 | + $tree = $this->get('job_csv_test', ['media', 'text']); |
|
90 | + $this->delete($tree, ['media', 'text']); |
|
91 | 91 | |
92 | - $this->assertEquals( 2, count( $tree->getListItems() ) ); |
|
92 | + $this->assertEquals(2, count($tree->getListItems())); |
|
93 | 93 | |
94 | - foreach( $tree->getChildren() as $node ) { |
|
95 | - $this->assertEquals( 2, count( $node->getListItems() ) ); |
|
94 | + foreach ($tree->getChildren() as $node) { |
|
95 | + $this->assertEquals(2, count($node->getListItems())); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
@@ -100,18 +100,18 @@ discard block |
||
100 | 100 | public function testRunPosition() |
101 | 101 | { |
102 | 102 | $config = $this->context->getConfig(); |
103 | - $mapping = $config->set( 'controller/jobs/catalog/import/csv/mapping', [] ); |
|
104 | - $mapping['item'] = array( 0 => 'catalog.label', 1 => 'catalog.code', 2 => 'catalog.parent' ); |
|
103 | + $mapping = $config->set('controller/jobs/catalog/import/csv/mapping', []); |
|
104 | + $mapping['item'] = array(0 => 'catalog.label', 1 => 'catalog.code', 2 => 'catalog.parent'); |
|
105 | 105 | |
106 | - $config->set( 'controller/jobs/catalog/import/csv/mapping', $mapping ); |
|
107 | - $config->set( 'controller/jobs/catalog/import/csv/location', __DIR__ . '/_testfiles/position' ); |
|
106 | + $config->set('controller/jobs/catalog/import/csv/mapping', $mapping); |
|
107 | + $config->set('controller/jobs/catalog/import/csv/location', __DIR__ . '/_testfiles/position'); |
|
108 | 108 | |
109 | 109 | $this->object->run(); |
110 | 110 | |
111 | - $tree = $this->get( 'job_csv_test' ); |
|
112 | - $this->delete( $tree ); |
|
111 | + $tree = $this->get('job_csv_test'); |
|
112 | + $this->delete($tree); |
|
113 | 113 | |
114 | - $this->assertEquals( 1, count( $tree->getChildren() ) ); |
|
114 | + $this->assertEquals(1, count($tree->getChildren())); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | |
@@ -135,12 +135,12 @@ discard block |
||
135 | 135 | ), |
136 | 136 | ); |
137 | 137 | |
138 | - $this->context->getConfig()->set( 'controller/jobs/catalog/import/csv/mapping', $mapping ); |
|
138 | + $this->context->getConfig()->set('controller/jobs/catalog/import/csv/mapping', $mapping); |
|
139 | 139 | |
140 | 140 | $this->object->run(); |
141 | 141 | |
142 | - $tree = $this->get( 'job_csv_test' ); |
|
143 | - $this->delete( $tree ); |
|
142 | + $tree = $this->get('job_csv_test'); |
|
143 | + $this->delete($tree); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | ), |
153 | 153 | ); |
154 | 154 | |
155 | - $this->context->getConfig()->set( 'controller/jobs/catalog/import/csv/mapping', $mapping ); |
|
155 | + $this->context->getConfig()->set('controller/jobs/catalog/import/csv/mapping', $mapping); |
|
156 | 156 | |
157 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
157 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
158 | 158 | $this->object->run(); |
159 | 159 | } |
160 | 160 | |
@@ -178,15 +178,15 @@ discard block |
||
178 | 178 | ), |
179 | 179 | ); |
180 | 180 | |
181 | - $this->context->getConfig()->set( 'controller/jobs/catalog/import/csv/mapping', $mapping ); |
|
181 | + $this->context->getConfig()->set('controller/jobs/catalog/import/csv/mapping', $mapping); |
|
182 | 182 | |
183 | 183 | $config = $this->context->getConfig(); |
184 | - $config->set( 'controller/jobs/catalog/import/csv/skip-lines', 0 ); |
|
185 | - $config->set( 'controller/jobs/catalog/import/csv/location', __DIR__ . '/_testfiles/invalid' ); |
|
184 | + $config->set('controller/jobs/catalog/import/csv/skip-lines', 0); |
|
185 | + $config->set('controller/jobs/catalog/import/csv/location', __DIR__ . '/_testfiles/invalid'); |
|
186 | 186 | |
187 | - $this->object = new \Aimeos\Controller\Jobs\Catalog\Import\Csv\Standard( $this->context, $this->aimeos ); |
|
187 | + $this->object = new \Aimeos\Controller\Jobs\Catalog\Import\Csv\Standard($this->context, $this->aimeos); |
|
188 | 188 | |
189 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
189 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
190 | 190 | $this->object->run(); |
191 | 191 | } |
192 | 192 | |
@@ -194,65 +194,65 @@ discard block |
||
194 | 194 | public function testRunBackup() |
195 | 195 | { |
196 | 196 | $config = $this->context->getConfig(); |
197 | - $config->set( 'controller/jobs/catalog/import/csv/container/type', 'Zip' ); |
|
198 | - $config->set( 'controller/jobs/catalog/import/csv/location', 'tmp/import.zip' ); |
|
199 | - $config->set( 'controller/jobs/catalog/import/csv/backup', 'tmp/test-%Y-%m-%d.zip' ); |
|
197 | + $config->set('controller/jobs/catalog/import/csv/container/type', 'Zip'); |
|
198 | + $config->set('controller/jobs/catalog/import/csv/location', 'tmp/import.zip'); |
|
199 | + $config->set('controller/jobs/catalog/import/csv/backup', 'tmp/test-%Y-%m-%d.zip'); |
|
200 | 200 | |
201 | - if( copy( __DIR__ . '/_testfiles/import.zip', 'tmp/import.zip' ) === false ) { |
|
202 | - throw new \RuntimeException( 'Unable to copy test file' ); |
|
201 | + if (copy(__DIR__ . '/_testfiles/import.zip', 'tmp/import.zip') === false) { |
|
202 | + throw new \RuntimeException('Unable to copy test file'); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | $this->object->run(); |
206 | 206 | |
207 | - $filename = strftime( 'tmp/test-%Y-%m-%d.zip' ); |
|
208 | - $this->assertTrue( file_exists( $filename ) ); |
|
207 | + $filename = strftime('tmp/test-%Y-%m-%d.zip'); |
|
208 | + $this->assertTrue(file_exists($filename)); |
|
209 | 209 | |
210 | - unlink( $filename ); |
|
210 | + unlink($filename); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
214 | 214 | public function testRunBackupInvalid() |
215 | 215 | { |
216 | 216 | $config = $this->context->getConfig(); |
217 | - $config->set( 'controller/jobs/catalog/import/csv/container/type', 'Zip' ); |
|
218 | - $config->set( 'controller/jobs/catalog/import/csv/location', 'tmp/import.zip' ); |
|
219 | - $config->set( 'controller/jobs/catalog/import/csv/backup', 'tmp/notexist/import.zip' ); |
|
217 | + $config->set('controller/jobs/catalog/import/csv/container/type', 'Zip'); |
|
218 | + $config->set('controller/jobs/catalog/import/csv/location', 'tmp/import.zip'); |
|
219 | + $config->set('controller/jobs/catalog/import/csv/backup', 'tmp/notexist/import.zip'); |
|
220 | 220 | |
221 | - if( copy( __DIR__ . '/_testfiles/import.zip', 'tmp/import.zip' ) === false ) { |
|
222 | - throw new \RuntimeException( 'Unable to copy test file' ); |
|
221 | + if (copy(__DIR__ . '/_testfiles/import.zip', 'tmp/import.zip') === false) { |
|
222 | + throw new \RuntimeException('Unable to copy test file'); |
|
223 | 223 | } |
224 | 224 | |
225 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
225 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
226 | 226 | $this->object->run(); |
227 | 227 | } |
228 | 228 | |
229 | 229 | |
230 | - protected function delete( \Aimeos\MShop\Catalog\Item\Iface $tree, array $domains = [] ) |
|
230 | + protected function delete(\Aimeos\MShop\Catalog\Item\Iface $tree, array $domains = []) |
|
231 | 231 | { |
232 | - $catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( $this->context ); |
|
232 | + $catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager($this->context); |
|
233 | 233 | |
234 | - foreach( $domains as $domain ) |
|
234 | + foreach ($domains as $domain) |
|
235 | 235 | { |
236 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, $domain ); |
|
236 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, $domain); |
|
237 | 237 | |
238 | - foreach( $tree->getListItems( $domain ) as $listItem ) { |
|
239 | - $manager->deleteItem( $listItem->getRefItem()->getId() ); |
|
238 | + foreach ($tree->getListItems($domain) as $listItem) { |
|
239 | + $manager->deleteItem($listItem->getRefItem()->getId()); |
|
240 | 240 | } |
241 | 241 | } |
242 | 242 | |
243 | - foreach( $tree->getChildren() as $node ) { |
|
244 | - $this->delete( $node, $domains ); |
|
243 | + foreach ($tree->getChildren() as $node) { |
|
244 | + $this->delete($node, $domains); |
|
245 | 245 | } |
246 | 246 | |
247 | - $catalogManager->deleteItem( $tree->getId() ); |
|
247 | + $catalogManager->deleteItem($tree->getId()); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | |
251 | - protected function get( $catcode, array $domains = [] ) |
|
251 | + protected function get($catcode, array $domains = []) |
|
252 | 252 | { |
253 | - $manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( $this->context ); |
|
254 | - $root = $manager->findItem( $catcode ); |
|
253 | + $manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager($this->context); |
|
254 | + $root = $manager->findItem($catcode); |
|
255 | 255 | |
256 | - return $manager->getTree( $root->getId(), $domains, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE ); |
|
256 | + return $manager->getTree($root->getId(), $domains, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE); |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | \ No newline at end of file |
@@ -16,77 +16,77 @@ discard block |
||
16 | 16 | |
17 | 17 | protected function setUp() |
18 | 18 | { |
19 | - \Aimeos\MShop\Factory::setCache( true ); |
|
19 | + \Aimeos\MShop\Factory::setCache(true); |
|
20 | 20 | |
21 | 21 | $context = \TestHelperCntl::getContext(); |
22 | 22 | $aimeos = \TestHelperCntl::getAimeos(); |
23 | 23 | |
24 | - $this->object = new TestAbstract( $context, $aimeos ); |
|
24 | + $this->object = new TestAbstract($context, $aimeos); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | |
28 | 28 | protected function tearDown() |
29 | 29 | { |
30 | - \Aimeos\MShop\Factory::setCache( false ); |
|
30 | + \Aimeos\MShop\Factory::setCache(false); |
|
31 | 31 | \Aimeos\MShop\Factory::clear(); |
32 | 32 | } |
33 | 33 | |
34 | 34 | |
35 | 35 | public function testGetCacheInvalidType() |
36 | 36 | { |
37 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
38 | - $this->object->getCachePublic( '$' ); |
|
37 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
38 | + $this->object->getCachePublic('$'); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
42 | 42 | public function testGetCacheInvalidClass() |
43 | 43 | { |
44 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
45 | - $this->object->getCachePublic( 'unknown' ); |
|
44 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
45 | + $this->object->getCachePublic('unknown'); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
49 | 49 | public function testGetProcessors() |
50 | 50 | { |
51 | - $processor = $this->object->getProcessorsPublic( array( 'media' => [] ) ); |
|
51 | + $processor = $this->object->getProcessorsPublic(array('media' => [])); |
|
52 | 52 | |
53 | - $this->assertInstanceOf( '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\Iface', $processor ); |
|
53 | + $this->assertInstanceOf('\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\Iface', $processor); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | |
57 | 57 | public function testGetProcessorsInvalidType() |
58 | 58 | { |
59 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
60 | - $this->object->getProcessorsPublic( array( '$' => [] ) ); |
|
59 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
60 | + $this->object->getProcessorsPublic(array('$' => [])); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
64 | 64 | public function testGetProcessorsInvalidClass() |
65 | 65 | { |
66 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
67 | - $this->object->getProcessorsPublic( array( 'unknown' => [] ) ); |
|
66 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
67 | + $this->object->getProcessorsPublic(array('unknown' => [])); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | |
71 | 71 | public function testGetProcessorsInvalidInterface() |
72 | 72 | { |
73 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
74 | - $this->object->getProcessorsPublic( array( 'unknown' => [] ) ); |
|
73 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
74 | + $this->object->getProcessorsPublic(array('unknown' => [])); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
78 | 78 | public function testGetTypeId() |
79 | 79 | { |
80 | - $typeid = $this->object->getTypeIdPublic( 'text/type', 'catalog', 'name' ); |
|
80 | + $typeid = $this->object->getTypeIdPublic('text/type', 'catalog', 'name'); |
|
81 | 81 | |
82 | - $this->assertNotEquals( null, $typeid ); |
|
82 | + $this->assertNotEquals(null, $typeid); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | |
86 | 86 | public function testGetTypeIdUnknown() |
87 | 87 | { |
88 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
89 | - $this->object->getTypeIdPublic( 'text/type', 'catalog', 'unknown' ); |
|
88 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
89 | + $this->object->getTypeIdPublic('text/type', 'catalog', 'unknown'); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
@@ -94,21 +94,21 @@ discard block |
||
94 | 94 | class TestAbstract |
95 | 95 | extends \Aimeos\Controller\Common\Catalog\Import\Csv\Base |
96 | 96 | { |
97 | - public function getCachePublic( $type, $name = null ) |
|
97 | + public function getCachePublic($type, $name = null) |
|
98 | 98 | { |
99 | - return $this->getCache( $type, $name ); |
|
99 | + return $this->getCache($type, $name); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | |
103 | - public function getProcessorsPublic( array $mappings ) |
|
103 | + public function getProcessorsPublic(array $mappings) |
|
104 | 104 | { |
105 | - return $this->getProcessors( $mappings ); |
|
105 | + return $this->getProcessors($mappings); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
109 | - public function getTypeIdPublic( $path, $domain, $code ) |
|
109 | + public function getTypeIdPublic($path, $domain, $code) |
|
110 | 110 | { |
111 | - return $this->getTypeId( $path, $domain, $code ); |
|
111 | + return $this->getTypeId($path, $domain, $code); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 |