@@ -16,49 +16,49 @@ |
||
16 | 16 | |
17 | 17 | protected function setUp() |
18 | 18 | { |
19 | - \Aimeos\MShop::cache( true ); |
|
19 | + \Aimeos\MShop::cache(true); |
|
20 | 20 | |
21 | 21 | $context = \TestHelperCntl::getContext(); |
22 | - $this->object = new \Aimeos\Controller\Common\Product\Import\Csv\Cache\Attribute\Standard( $context ); |
|
22 | + $this->object = new \Aimeos\Controller\Common\Product\Import\Csv\Cache\Attribute\Standard($context); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | |
26 | 26 | protected function tearDown() |
27 | 27 | { |
28 | - \Aimeos\MShop::cache( false ); |
|
28 | + \Aimeos\MShop::cache(false); |
|
29 | 29 | \Aimeos\MShop::clear(); |
30 | 30 | } |
31 | 31 | |
32 | 32 | |
33 | 33 | public function testGet() |
34 | 34 | { |
35 | - $item = $this->object->get( 'black', 'color' ); |
|
35 | + $item = $this->object->get('black', 'color'); |
|
36 | 36 | |
37 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Attribute\\Item\\Iface', $item ); |
|
38 | - $this->assertEquals( 'black', $item->getCode() ); |
|
39 | - $this->assertEquals( 'color', $item->getType() ); |
|
37 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Attribute\\Item\\Iface', $item); |
|
38 | + $this->assertEquals('black', $item->getCode()); |
|
39 | + $this->assertEquals('color', $item->getType()); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | |
43 | 43 | public function testGetUnknown() |
44 | 44 | { |
45 | - $this->assertEquals( null, $this->object->get( 'cache-test', 'color' ) ); |
|
45 | + $this->assertEquals(null, $this->object->get('cache-test', 'color')); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
49 | 49 | public function testSet() |
50 | 50 | { |
51 | - $item = $this->object->get( 'black', 'color' ); |
|
51 | + $item = $this->object->get('black', 'color'); |
|
52 | 52 | |
53 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Attribute\\Item\\Iface', $item ); |
|
53 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Attribute\\Item\\Iface', $item); |
|
54 | 54 | |
55 | - $item->setCode( 'cache-test' ); |
|
55 | + $item->setCode('cache-test'); |
|
56 | 56 | |
57 | - $this->object->set( $item ); |
|
58 | - $item = $this->object->get( 'cache-test', 'color' ); |
|
57 | + $this->object->set($item); |
|
58 | + $item = $this->object->get('cache-test', 'color'); |
|
59 | 59 | |
60 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Attribute\\Item\\Iface', $item ); |
|
61 | - $this->assertEquals( 'cache-test', $item->getCode() ); |
|
62 | - $this->assertEquals( 'color', $item->getType() ); |
|
60 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Attribute\\Item\\Iface', $item); |
|
61 | + $this->assertEquals('cache-test', $item->getCode()); |
|
62 | + $this->assertEquals('color', $item->getType()); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | \ No newline at end of file |
@@ -16,62 +16,62 @@ discard block |
||
16 | 16 | |
17 | 17 | protected function setUp() |
18 | 18 | { |
19 | - \Aimeos\MShop::cache( true ); |
|
19 | + \Aimeos\MShop::cache(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::cache( false ); |
|
30 | + \Aimeos\MShop::cache(false); |
|
31 | 31 | \Aimeos\MShop::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 | |
@@ -79,15 +79,15 @@ discard block |
||
79 | 79 | class TestAbstract |
80 | 80 | extends \Aimeos\Controller\Common\Catalog\Import\Csv\Base |
81 | 81 | { |
82 | - public function getCachePublic( $type, $name = null ) |
|
82 | + public function getCachePublic($type, $name = null) |
|
83 | 83 | { |
84 | - return $this->getCache( $type, $name ); |
|
84 | + return $this->getCache($type, $name); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | |
88 | - public function getProcessorsPublic( array $mappings ) |
|
88 | + public function getProcessorsPublic(array $mappings) |
|
89 | 89 | { |
90 | - return $this->getProcessors( $mappings ); |
|
90 | + return $this->getProcessors($mappings); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 |
@@ -18,18 +18,18 @@ discard block |
||
18 | 18 | |
19 | 19 | protected function setUp() |
20 | 20 | { |
21 | - \Aimeos\MShop::cache( true ); |
|
21 | + \Aimeos\MShop::cache(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::cache( false ); |
|
32 | + \Aimeos\MShop::cache(false); |
|
33 | 33 | \Aimeos\MShop::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', $file2 ); |
|
69 | - $this->assertContains( 'U:BUNDLE', $file2 ); |
|
68 | + $this->assertContains('CNE', $file2); |
|
69 | + $this->assertContains('U:BUNDLE', $file2); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | \ No newline at end of file |
@@ -18,18 +18,18 @@ discard block |
||
18 | 18 | |
19 | 19 | protected function setUp() |
20 | 20 | { |
21 | - \Aimeos\MShop::cache( true ); |
|
21 | + \Aimeos\MShop::cache(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\Sitemap\Standard( $this->context, $this->aimeos ); |
|
26 | + $this->object = new \Aimeos\Controller\Jobs\Product\Export\Sitemap\Standard($this->context, $this->aimeos); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | |
30 | 30 | protected function tearDown() |
31 | 31 | { |
32 | - \Aimeos\MShop::cache( false ); |
|
32 | + \Aimeos\MShop::cache(false); |
|
33 | 33 | \Aimeos\MShop::clear(); |
34 | 34 | |
35 | 35 | $this->object = null; |
@@ -38,40 +38,40 @@ discard block |
||
38 | 38 | |
39 | 39 | public function testGetName() |
40 | 40 | { |
41 | - $this->assertEquals( 'Product site map', $this->object->getName() ); |
|
41 | + $this->assertEquals('Product site map', $this->object->getName()); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | |
45 | 45 | public function testGetDescription() |
46 | 46 | { |
47 | 47 | $text = 'Creates a product site map for search engines'; |
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/sitemap/max-items', 5 ); |
|
54 | + $this->context->getConfig()->set('controller/jobs/product/export/sitemap/max-items', 5); |
|
55 | 55 | |
56 | 56 | $this->object->run(); |
57 | 57 | |
58 | 58 | $ds = DIRECTORY_SEPARATOR; |
59 | - $this->assertFileExists( 'tmp' . $ds . 'aimeos-sitemap-1.xml.gz' ); |
|
60 | - $this->assertFileExists( 'tmp' . $ds . 'aimeos-sitemap-2.xml.gz' ); |
|
61 | - $this->assertFileExists( 'tmp' . $ds . 'aimeos-sitemap-index.xml.gz' ); |
|
59 | + $this->assertFileExists('tmp' . $ds . 'aimeos-sitemap-1.xml.gz'); |
|
60 | + $this->assertFileExists('tmp' . $ds . 'aimeos-sitemap-2.xml.gz'); |
|
61 | + $this->assertFileExists('tmp' . $ds . 'aimeos-sitemap-index.xml.gz'); |
|
62 | 62 | |
63 | - $file1 = gzread( gzopen( 'tmp' . $ds . 'aimeos-sitemap-1.xml.gz', 'rb' ), 0x1000 ); |
|
64 | - $file2 = gzread( gzopen( 'tmp' . $ds . 'aimeos-sitemap-2.xml.gz', 'rb' ), 0x1000 ); |
|
65 | - $index = gzread( gzopen( 'tmp' . $ds . 'aimeos-sitemap-index.xml.gz', 'rb' ), 0x1000 ); |
|
63 | + $file1 = gzread(gzopen('tmp' . $ds . 'aimeos-sitemap-1.xml.gz', 'rb'), 0x1000); |
|
64 | + $file2 = gzread(gzopen('tmp' . $ds . 'aimeos-sitemap-2.xml.gz', 'rb'), 0x1000); |
|
65 | + $index = gzread(gzopen('tmp' . $ds . 'aimeos-sitemap-index.xml.gz', 'rb'), 0x1000); |
|
66 | 66 | |
67 | - unlink( 'tmp' . $ds . 'aimeos-sitemap-1.xml.gz' ); |
|
68 | - unlink( 'tmp' . $ds . 'aimeos-sitemap-2.xml.gz' ); |
|
69 | - unlink( 'tmp' . $ds . 'aimeos-sitemap-index.xml.gz' ); |
|
67 | + unlink('tmp' . $ds . 'aimeos-sitemap-1.xml.gz'); |
|
68 | + unlink('tmp' . $ds . 'aimeos-sitemap-2.xml.gz'); |
|
69 | + unlink('tmp' . $ds . 'aimeos-sitemap-index.xml.gz'); |
|
70 | 70 | |
71 | - $this->assertContains( 'Cafe_Noire_Expresso', $file2 ); |
|
72 | - $this->assertContains( 'Unittest%3A_Bundle', $file2 ); |
|
71 | + $this->assertContains('Cafe_Noire_Expresso', $file2); |
|
72 | + $this->assertContains('Unittest%3A_Bundle', $file2); |
|
73 | 73 | |
74 | - $this->assertContains( 'aimeos-sitemap-1.xml.gz', $index ); |
|
75 | - $this->assertContains( 'aimeos-sitemap-2.xml.gz', $index ); |
|
74 | + $this->assertContains('aimeos-sitemap-1.xml.gz', $index); |
|
75 | + $this->assertContains('aimeos-sitemap-2.xml.gz', $index); |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | \ No newline at end of file |
@@ -19,18 +19,18 @@ discard block |
||
19 | 19 | |
20 | 20 | protected function setUp() |
21 | 21 | { |
22 | - \Aimeos\MShop::cache( true ); |
|
22 | + \Aimeos\MShop::cache(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::cache( false ); |
|
33 | + \Aimeos\MShop::cache(false); |
|
34 | 34 | \Aimeos\MShop::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::inject( $this->context, 'product/lists', $stub ); |
|
60 | + \Aimeos\MShop::inject($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 | } |
@@ -326,7 +326,7 @@ |
||
326 | 326 | * |
327 | 327 | * @param string $name One of "domain", "max-items" or "max-query" |
328 | 328 | * @param mixed $default Default value if name is unknown |
329 | - * @return mixed Configuration value |
|
329 | + * @return string Configuration value |
|
330 | 330 | */ |
331 | 331 | protected function getConfig( $name, $default = null ) |
332 | 332 | { |
@@ -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, false ); |
|
54 | + $this->export($container, false); |
|
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' ); |
|
126 | + $location = $config->get('controller/jobs/product/export/location'); |
|
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,15 +174,15 @@ 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 | - if( $location === null ) |
|
179 | + if ($location === null) |
|
180 | 180 | { |
181 | - $msg = sprintf( 'Required configuration for "%1$s" is missing', 'controller/jobs/product/export/location' ); |
|
182 | - throw new \Aimeos\Controller\Jobs\Exception( $msg ); |
|
181 | + $msg = sprintf('Required configuration for "%1$s" is missing', 'controller/jobs/product/export/location'); |
|
182 | + throw new \Aimeos\Controller\Jobs\Exception($msg); |
|
183 | 183 | } |
184 | 184 | |
185 | - return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options ); |
|
185 | + return \Aimeos\MW\Container\Factory::getContainer($location, $container, $content, $options); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | * @param integer $filenum New file number |
194 | 194 | * @return \Aimeos\MW\Container\Content\Iface New content object |
195 | 195 | */ |
196 | - protected function createContent( \Aimeos\MW\Container\Iface $container, $filenum ) |
|
196 | + protected function createContent(\Aimeos\MW\Container\Iface $container, $filenum) |
|
197 | 197 | { |
198 | 198 | /** controller/jobs/product/export/standard/template-header |
199 | 199 | * Relative path to the XML site map header template of the product site map job controller. |
@@ -223,9 +223,9 @@ discard block |
||
223 | 223 | $context = $this->getContext(); |
224 | 224 | $view = $context->getView(); |
225 | 225 | |
226 | - $content = $container->create( $this->getFilename( $filenum ) ); |
|
227 | - $content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) ); |
|
228 | - $container->add( $content ); |
|
226 | + $content = $container->create($this->getFilename($filenum)); |
|
227 | + $content->add($view->render($context->getConfig()->get($tplconf, $default))); |
|
228 | + $container->add($content); |
|
229 | 229 | |
230 | 230 | return $content; |
231 | 231 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * |
237 | 237 | * @param \Aimeos\MW\Container\Content\Iface $content |
238 | 238 | */ |
239 | - protected function closeContent( \Aimeos\MW\Container\Content\Iface $content ) |
|
239 | + protected function closeContent(\Aimeos\MW\Container\Content\Iface $content) |
|
240 | 240 | { |
241 | 241 | /** controller/jobs/product/export/standard/template-footer |
242 | 242 | * Relative path to the XML site map footer template of the product site map job controller. |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | $context = $this->getContext(); |
267 | 267 | $view = $context->getView(); |
268 | 268 | |
269 | - $content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) ); |
|
269 | + $content->add($view->render($context->getConfig()->get($tplconf, $default))); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | |
@@ -277,45 +277,45 @@ discard block |
||
277 | 277 | * @param boolean $default True to filter exported products by default criteria |
278 | 278 | * @return array List of content (file) names |
279 | 279 | */ |
280 | - protected function export( \Aimeos\MW\Container\Iface $container, $default = true ) |
|
280 | + protected function export(\Aimeos\MW\Container\Iface $container, $default = true) |
|
281 | 281 | { |
282 | - $domains = array( 'attribute', 'media', 'price', 'product', 'text' ); |
|
282 | + $domains = array('attribute', 'media', 'price', 'product', 'text'); |
|
283 | 283 | |
284 | - $domains = $this->getConfig( 'domains', $domains ); |
|
285 | - $maxItems = $this->getConfig( 'max-items', 10000 ); |
|
286 | - $maxQuery = $this->getConfig( 'max-query', 1000 ); |
|
284 | + $domains = $this->getConfig('domains', $domains); |
|
285 | + $maxItems = $this->getConfig('max-items', 10000); |
|
286 | + $maxQuery = $this->getConfig('max-query', 1000); |
|
287 | 287 | |
288 | 288 | $start = 0; $filenum = 1; |
289 | 289 | $names = []; |
290 | 290 | |
291 | - $productManager = \Aimeos\MShop::create( $this->getContext(), 'product' ); |
|
291 | + $productManager = \Aimeos\MShop::create($this->getContext(), 'product'); |
|
292 | 292 | |
293 | - $search = $productManager->createSearch( $default ); |
|
294 | - $search->setSortations( array( $search->sort( '+', 'product.id' ) ) ); |
|
295 | - $search->setSlice( 0, $maxQuery ); |
|
293 | + $search = $productManager->createSearch($default); |
|
294 | + $search->setSortations(array($search->sort('+', 'product.id'))); |
|
295 | + $search->setSlice(0, $maxQuery); |
|
296 | 296 | |
297 | - $content = $this->createContent( $container, $filenum ); |
|
297 | + $content = $this->createContent($container, $filenum); |
|
298 | 298 | $names[] = $content->getResource(); |
299 | 299 | |
300 | 300 | do |
301 | 301 | { |
302 | - $items = $productManager->searchItems( $search, $domains ); |
|
303 | - $this->addItems( $content, $items ); |
|
302 | + $items = $productManager->searchItems($search, $domains); |
|
303 | + $this->addItems($content, $items); |
|
304 | 304 | |
305 | - $count = count( $items ); |
|
305 | + $count = count($items); |
|
306 | 306 | $start += $count; |
307 | - $search->setSlice( $start, $maxQuery ); |
|
307 | + $search->setSlice($start, $maxQuery); |
|
308 | 308 | |
309 | - if( $start + $maxQuery > $maxItems * $filenum ) |
|
309 | + if ($start + $maxQuery > $maxItems * $filenum) |
|
310 | 310 | { |
311 | - $this->closeContent( $content ); |
|
312 | - $content = $this->createContent( $container, ++$filenum ); |
|
311 | + $this->closeContent($content); |
|
312 | + $content = $this->createContent($container, ++$filenum); |
|
313 | 313 | $names[] = $content->getResource(); |
314 | 314 | } |
315 | 315 | } |
316 | - while( $count >= $search->getSliceSize() ); |
|
316 | + while ($count >= $search->getSliceSize()); |
|
317 | 317 | |
318 | - $this->closeContent( $content ); |
|
318 | + $this->closeContent($content); |
|
319 | 319 | |
320 | 320 | return $names; |
321 | 321 | } |
@@ -328,11 +328,11 @@ discard block |
||
328 | 328 | * @param mixed $default Default value if name is unknown |
329 | 329 | * @return mixed Configuration value |
330 | 330 | */ |
331 | - protected function getConfig( $name, $default = null ) |
|
331 | + protected function getConfig($name, $default = null) |
|
332 | 332 | { |
333 | 333 | $config = $this->getContext()->getConfig(); |
334 | 334 | |
335 | - switch( $name ) |
|
335 | + switch ($name) |
|
336 | 336 | { |
337 | 337 | case 'domain': |
338 | 338 | /** controller/jobs/product/export/domains |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | * @see controller/jobs/product/export/max-items |
356 | 356 | * @see controller/jobs/product/export/max-query |
357 | 357 | */ |
358 | - return $config->get( 'controller/jobs/product/export/domains', $default ); |
|
358 | + return $config->get('controller/jobs/product/export/domains', $default); |
|
359 | 359 | |
360 | 360 | case 'max-items': |
361 | 361 | /** controller/jobs/product/export/max-items |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | * @see controller/jobs/product/export/max-query |
379 | 379 | * @see controller/jobs/product/export/domains |
380 | 380 | */ |
381 | - return $config->get( 'controller/jobs/product/export/max-items', $default ); |
|
381 | + return $config->get('controller/jobs/product/export/max-items', $default); |
|
382 | 382 | |
383 | 383 | case 'max-query': |
384 | 384 | /** controller/jobs/product/export/max-query |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | * @see controller/jobs/product/export/max-items |
402 | 402 | * @see controller/jobs/product/export/domains |
403 | 403 | */ |
404 | - return $config->get( 'controller/jobs/product/export/max-query', $default ); |
|
404 | + return $config->get('controller/jobs/product/export/max-query', $default); |
|
405 | 405 | |
406 | 406 | case 'filename': |
407 | 407 | /** controller/jobs/product/export/filename |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * @see controller/jobs/product/export/max-query |
423 | 423 | * @see controller/jobs/product/export/domains |
424 | 424 | */ |
425 | - return $config->get( 'controller/jobs/product/export/filename', $default ); |
|
425 | + return $config->get('controller/jobs/product/export/filename', $default); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | return $default; |
@@ -435,8 +435,8 @@ discard block |
||
435 | 435 | * @param integer $number Current file number |
436 | 436 | * @return string New file name |
437 | 437 | */ |
438 | - protected function getFilename( $number ) |
|
438 | + protected function getFilename($number) |
|
439 | 439 | { |
440 | - return sprintf( $this->getConfig( 'filename', 'aimeos-products-%1$d_%2$s.xml' ), $number, date( 'Y-m-d_H:i:s' ) ); |
|
440 | + return sprintf($this->getConfig('filename', 'aimeos-products-%1$d_%2$s.xml'), $number, date('Y-m-d_H:i:s')); |
|
441 | 441 | } |
442 | 442 | } |
@@ -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::create( $this->context ); |
@@ -18,65 +18,65 @@ discard block |
||
18 | 18 | |
19 | 19 | protected function setUp() |
20 | 20 | { |
21 | - \Aimeos\MShop::cache( true ); |
|
21 | + \Aimeos\MShop::cache(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::cache( false ); |
|
36 | + \Aimeos\MShop::cache(false); |
|
37 | 37 | \Aimeos\MShop::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::create( $this->context ); |
|
232 | + $catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::create($this->context); |
|
233 | 233 | |
234 | - foreach( $domains as $domain ) |
|
234 | + foreach ($domains as $domain) |
|
235 | 235 | { |
236 | - $manager = \Aimeos\MShop::create( $this->context, $domain ); |
|
236 | + $manager = \Aimeos\MShop::create($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::create( $this->context ); |
|
254 | - $root = $manager->findItem( $catcode ); |
|
253 | + $manager = \Aimeos\MShop\Catalog\Manager\Factory::create($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 |
@@ -73,6 +73,9 @@ discard block |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | |
76 | + /** |
|
77 | + * @param integer $cnt |
|
78 | + */ |
|
76 | 79 | protected function addAttribute( array $data, $cnt ) |
77 | 80 | { |
78 | 81 | $data[] = 'length'; // type |
@@ -86,6 +89,9 @@ discard block |
||
86 | 89 | } |
87 | 90 | |
88 | 91 | |
92 | + /** |
|
93 | + * @param integer $cnt |
|
94 | + */ |
|
89 | 95 | protected function addMedia( array $data, $cnt ) |
90 | 96 | { |
91 | 97 | $data[] = "/path/to/image-$cnt.jpg"; // url |
@@ -94,6 +100,9 @@ discard block |
||
94 | 100 | } |
95 | 101 | |
96 | 102 | |
103 | + /** |
|
104 | + * @param integer $cnt |
|
105 | + */ |
|
97 | 106 | protected function addPrice( array $data, $cnt ) |
98 | 107 | { |
99 | 108 | $data[] = 1; // quantity |
@@ -105,6 +114,9 @@ discard block |
||
105 | 114 | } |
106 | 115 | |
107 | 116 | |
117 | + /** |
|
118 | + * @param integer $cnt |
|
119 | + */ |
|
108 | 120 | protected function addProduct( array $data, $cnt ) |
109 | 121 | { |
110 | 122 | $data[] = 'import-' . $cnt; // code |
@@ -116,6 +128,9 @@ discard block |
||
116 | 128 | } |
117 | 129 | |
118 | 130 | |
131 | + /** |
|
132 | + * @param integer $cnt |
|
133 | + */ |
|
119 | 134 | protected function addProductRef( array $data, $cnt ) |
120 | 135 | { |
121 | 136 | $data[] = 'import-' . ($cnt % 100); // code |
@@ -125,6 +140,9 @@ discard block |
||
125 | 140 | } |
126 | 141 | |
127 | 142 | |
143 | + /** |
|
144 | + * @param integer $cnt |
|
145 | + */ |
|
128 | 146 | protected function addProperty( array $data, $cnt ) |
129 | 147 | { |
130 | 148 | $data[] = 'package-weight'; // type |
@@ -134,6 +152,9 @@ discard block |
||
134 | 152 | } |
135 | 153 | |
136 | 154 | |
155 | + /** |
|
156 | + * @param integer $cnt |
|
157 | + */ |
|
137 | 158 | protected function addText( array $data, $cnt ) |
138 | 159 | { |
139 | 160 | $data[] = 'name'; // type |
@@ -17,31 +17,31 @@ discard block |
||
17 | 17 | $this->context = \TestHelperJobs::getContext('unitperf'); |
18 | 18 | |
19 | 19 | $config = $this->context->getConfig(); |
20 | - $config->set( 'controller/jobs/product/import/csv/location', 'tmp/product-import.zip' ); |
|
21 | - $config->set( 'controller/jobs/product/import/csv/container/type', 'Zip' ); |
|
22 | - $config->set( 'controller/jobs/product/import/csv/container/content', 'CSV' ); |
|
23 | - $config->set( 'controller/jobs/product/import/csv/mapping', $this->getMapping() ); |
|
20 | + $config->set('controller/jobs/product/import/csv/location', 'tmp/product-import.zip'); |
|
21 | + $config->set('controller/jobs/product/import/csv/container/type', 'Zip'); |
|
22 | + $config->set('controller/jobs/product/import/csv/container/content', 'CSV'); |
|
23 | + $config->set('controller/jobs/product/import/csv/mapping', $this->getMapping()); |
|
24 | 24 | |
25 | - $container = \Aimeos\MW\Container\Factory::getContainer( 'tmp/product-import.zip', 'Zip', 'CSV', [] ); |
|
25 | + $container = \Aimeos\MW\Container\Factory::getContainer('tmp/product-import.zip', 'Zip', 'CSV', []); |
|
26 | 26 | |
27 | - $content = $container->create( 'product.csv' ); |
|
27 | + $content = $container->create('product.csv'); |
|
28 | 28 | |
29 | - for( $i = 0; $i < 1000; $i++ ) |
|
29 | + for ($i = 0; $i < 1000; $i++) |
|
30 | 30 | { |
31 | 31 | $data = []; |
32 | 32 | |
33 | - $data = $this->addProduct( $data, $i ); |
|
34 | - $data = $this->addText( $data, $i ); |
|
35 | - $data = $this->addMedia( $data, $i ); |
|
36 | - $data = $this->addPrice( $data, $i ); |
|
37 | - $data = $this->addAttribute( $data, $i ); |
|
38 | - $data = $this->addProductRef( $data, $i ); |
|
39 | - $data = $this->addProperty( $data, $i ); |
|
33 | + $data = $this->addProduct($data, $i); |
|
34 | + $data = $this->addText($data, $i); |
|
35 | + $data = $this->addMedia($data, $i); |
|
36 | + $data = $this->addPrice($data, $i); |
|
37 | + $data = $this->addAttribute($data, $i); |
|
38 | + $data = $this->addProductRef($data, $i); |
|
39 | + $data = $this->addProperty($data, $i); |
|
40 | 40 | |
41 | - $content->add( $data ); |
|
41 | + $content->add($data); |
|
42 | 42 | } |
43 | 43 | |
44 | - $container->add( $content ); |
|
44 | + $container->add($content); |
|
45 | 45 | |
46 | 46 | $container->close(); |
47 | 47 | } |
@@ -55,25 +55,25 @@ discard block |
||
55 | 55 | $this->cleanupPrice(); |
56 | 56 | $this->cleanupProduct(); |
57 | 57 | |
58 | - unlink( 'tmp/product-import.zip' ); |
|
58 | + unlink('tmp/product-import.zip'); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
62 | 62 | public function testImport() |
63 | 63 | { |
64 | 64 | $aimeos = \TestHelperJobs::getAimeos(); |
65 | - $cntl = \Aimeos\Controller\Jobs\Product\Import\Csv\Factory::create( $this->context, $aimeos, 'Standard' ); |
|
65 | + $cntl = \Aimeos\Controller\Jobs\Product\Import\Csv\Factory::create($this->context, $aimeos, 'Standard'); |
|
66 | 66 | |
67 | - $start = microtime( true ); |
|
67 | + $start = microtime(true); |
|
68 | 68 | |
69 | 69 | $cntl->run(); |
70 | 70 | |
71 | - $stop = microtime( true ); |
|
72 | - echo "\n product import CSV: " . ( ( $stop - $start ) ) . " sec\n"; |
|
71 | + $stop = microtime(true); |
|
72 | + echo "\n product import CSV: " . (($stop - $start)) . " sec\n"; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
76 | - protected function addAttribute( array $data, $cnt ) |
|
76 | + protected function addAttribute(array $data, $cnt) |
|
77 | 77 | { |
78 | 78 | $data[] = 'length'; // type |
79 | 79 | $data[] = 'import-' . ($cnt % 30); // code |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | |
89 | - protected function addMedia( array $data, $cnt ) |
|
89 | + protected function addMedia(array $data, $cnt) |
|
90 | 90 | { |
91 | 91 | $data[] = "/path/to/image-$cnt.jpg"; // url |
92 | 92 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | } |
95 | 95 | |
96 | 96 | |
97 | - protected function addPrice( array $data, $cnt ) |
|
97 | + protected function addPrice(array $data, $cnt) |
|
98 | 98 | { |
99 | 99 | $data[] = 1; // quantity |
100 | 100 | $data[] = 'import-' . $cnt; // label |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | } |
106 | 106 | |
107 | 107 | |
108 | - protected function addProduct( array $data, $cnt ) |
|
108 | + protected function addProduct(array $data, $cnt) |
|
109 | 109 | { |
110 | 110 | $data[] = 'import-' . $cnt; // code |
111 | 111 | $data[] = 'import-' . $cnt; // label |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | } |
117 | 117 | |
118 | 118 | |
119 | - protected function addProductRef( array $data, $cnt ) |
|
119 | + protected function addProductRef(array $data, $cnt) |
|
120 | 120 | { |
121 | 121 | $data[] = 'import-' . ($cnt % 100); // code |
122 | 122 | $data[] = 'suggestion'; // type |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | } |
126 | 126 | |
127 | 127 | |
128 | - protected function addProperty( array $data, $cnt ) |
|
128 | + protected function addProperty(array $data, $cnt) |
|
129 | 129 | { |
130 | 130 | $data[] = 'package-weight'; // type |
131 | 131 | $data[] = '0.5'; // value |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | } |
135 | 135 | |
136 | 136 | |
137 | - protected function addText( array $data, $cnt ) |
|
137 | + protected function addText(array $data, $cnt) |
|
138 | 138 | { |
139 | 139 | $data[] = 'name'; // type |
140 | 140 | $data[] = 'import-name-' . $cnt; //content |
@@ -149,132 +149,132 @@ discard block |
||
149 | 149 | |
150 | 150 | protected function cleanupAttribute() |
151 | 151 | { |
152 | - $manager = \Aimeos\MShop\Attribute\Manager\Factory::create( $this->context ); |
|
152 | + $manager = \Aimeos\MShop\Attribute\Manager\Factory::create($this->context); |
|
153 | 153 | |
154 | 154 | $search = $manager->createSearch(); |
155 | 155 | $expr = array( |
156 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
157 | - $search->compare( '==', 'attribute.label', 'import-%' ), |
|
156 | + $search->compare('==', 'attribute.domain', 'product'), |
|
157 | + $search->compare('==', 'attribute.label', 'import-%'), |
|
158 | 158 | ); |
159 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
160 | - $search->setSortations( array( $search->sort( '+', 'attribute.id' ) ) ); |
|
159 | + $search->setConditions($search->combine('&&', $expr)); |
|
160 | + $search->setSortations(array($search->sort('+', 'attribute.id'))); |
|
161 | 161 | |
162 | 162 | $start = 0; |
163 | 163 | |
164 | 164 | do |
165 | 165 | { |
166 | - $result = $manager->searchItems( $search ); |
|
167 | - $manager->deleteItems( array_keys( $result ) ); |
|
166 | + $result = $manager->searchItems($search); |
|
167 | + $manager->deleteItems(array_keys($result)); |
|
168 | 168 | |
169 | - $count = count( $result ); |
|
169 | + $count = count($result); |
|
170 | 170 | $start += $count; |
171 | - $search->setSlice( $start ); |
|
171 | + $search->setSlice($start); |
|
172 | 172 | } |
173 | - while( $count == $search->getSliceSize() ); |
|
173 | + while ($count == $search->getSliceSize()); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | |
177 | 177 | protected function cleanupMedia() |
178 | 178 | { |
179 | - $manager = \Aimeos\MShop\Media\Manager\Factory::create( $this->context ); |
|
179 | + $manager = \Aimeos\MShop\Media\Manager\Factory::create($this->context); |
|
180 | 180 | |
181 | 181 | $search = $manager->createSearch(); |
182 | 182 | $expr = array( |
183 | - $search->compare( '==', 'media.domain', 'product' ), |
|
184 | - $search->compare( '==', 'media.label', 'import-%' ), |
|
183 | + $search->compare('==', 'media.domain', 'product'), |
|
184 | + $search->compare('==', 'media.label', 'import-%'), |
|
185 | 185 | ); |
186 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
187 | - $search->setSortations( array( $search->sort( '+', 'media.id' ) ) ); |
|
186 | + $search->setConditions($search->combine('&&', $expr)); |
|
187 | + $search->setSortations(array($search->sort('+', 'media.id'))); |
|
188 | 188 | |
189 | 189 | $start = 0; |
190 | 190 | |
191 | 191 | do |
192 | 192 | { |
193 | - $result = $manager->searchItems( $search ); |
|
194 | - $manager->deleteItems( array_keys( $result ) ); |
|
193 | + $result = $manager->searchItems($search); |
|
194 | + $manager->deleteItems(array_keys($result)); |
|
195 | 195 | |
196 | - $count = count( $result ); |
|
196 | + $count = count($result); |
|
197 | 197 | $start += $count; |
198 | - $search->setSlice( $start ); |
|
198 | + $search->setSlice($start); |
|
199 | 199 | } |
200 | - while( $count == $search->getSliceSize() ); |
|
200 | + while ($count == $search->getSliceSize()); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | |
204 | 204 | protected function cleanupPrice() |
205 | 205 | { |
206 | - $manager = \Aimeos\MShop\Price\Manager\Factory::create( $this->context ); |
|
206 | + $manager = \Aimeos\MShop\Price\Manager\Factory::create($this->context); |
|
207 | 207 | |
208 | 208 | $search = $manager->createSearch(); |
209 | 209 | $expr = array( |
210 | - $search->compare( '==', 'price.domain', 'product' ), |
|
211 | - $search->compare( '==', 'price.label', 'import-%' ), |
|
210 | + $search->compare('==', 'price.domain', 'product'), |
|
211 | + $search->compare('==', 'price.label', 'import-%'), |
|
212 | 212 | ); |
213 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
214 | - $search->setSortations( array( $search->sort( '+', 'price.id' ) ) ); |
|
213 | + $search->setConditions($search->combine('&&', $expr)); |
|
214 | + $search->setSortations(array($search->sort('+', 'price.id'))); |
|
215 | 215 | |
216 | 216 | $start = 0; |
217 | 217 | |
218 | 218 | do |
219 | 219 | { |
220 | - $result = $manager->searchItems( $search ); |
|
221 | - $manager->deleteItems( array_keys( $result ) ); |
|
220 | + $result = $manager->searchItems($search); |
|
221 | + $manager->deleteItems(array_keys($result)); |
|
222 | 222 | |
223 | - $count = count( $result ); |
|
223 | + $count = count($result); |
|
224 | 224 | $start += $count; |
225 | - $search->setSlice( $start ); |
|
225 | + $search->setSlice($start); |
|
226 | 226 | } |
227 | - while( $count == $search->getSliceSize() ); |
|
227 | + while ($count == $search->getSliceSize()); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | |
231 | 231 | protected function cleanupProduct() |
232 | 232 | { |
233 | - $manager = \Aimeos\MShop\Product\Manager\Factory::create( $this->context ); |
|
233 | + $manager = \Aimeos\MShop\Product\Manager\Factory::create($this->context); |
|
234 | 234 | |
235 | 235 | $search = $manager->createSearch(); |
236 | - $search->setConditions( $search->compare( '==', 'product.code', 'import-%' ) ); |
|
237 | - $search->setSortations( array( $search->sort( '+', 'product.id' ) ) ); |
|
236 | + $search->setConditions($search->compare('==', 'product.code', 'import-%')); |
|
237 | + $search->setSortations(array($search->sort('+', 'product.id'))); |
|
238 | 238 | |
239 | 239 | $start = 0; |
240 | 240 | |
241 | 241 | do |
242 | 242 | { |
243 | - $result = $manager->searchItems( $search ); |
|
244 | - $manager->deleteItems( array_keys( $result ) ); |
|
243 | + $result = $manager->searchItems($search); |
|
244 | + $manager->deleteItems(array_keys($result)); |
|
245 | 245 | |
246 | - $count = count( $result ); |
|
246 | + $count = count($result); |
|
247 | 247 | $start += $count; |
248 | - $search->setSlice( $start ); |
|
248 | + $search->setSlice($start); |
|
249 | 249 | } |
250 | - while( $count == $search->getSliceSize() ); |
|
250 | + while ($count == $search->getSliceSize()); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | |
254 | 254 | protected function cleanupText() |
255 | 255 | { |
256 | - $manager = \Aimeos\MShop\Text\Manager\Factory::create( $this->context ); |
|
256 | + $manager = \Aimeos\MShop\Text\Manager\Factory::create($this->context); |
|
257 | 257 | |
258 | 258 | $search = $manager->createSearch(); |
259 | 259 | $expr = array( |
260 | - $search->compare( '==', 'text.domain', 'product' ), |
|
261 | - $search->compare( '==', 'text.label', 'import-%' ), |
|
260 | + $search->compare('==', 'text.domain', 'product'), |
|
261 | + $search->compare('==', 'text.label', 'import-%'), |
|
262 | 262 | ); |
263 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
264 | - $search->setSortations( array( $search->sort( '+', 'text.id' ) ) ); |
|
263 | + $search->setConditions($search->combine('&&', $expr)); |
|
264 | + $search->setSortations(array($search->sort('+', 'text.id'))); |
|
265 | 265 | |
266 | 266 | $start = 0; |
267 | 267 | |
268 | 268 | do |
269 | 269 | { |
270 | - $result = $manager->searchItems( $search ); |
|
271 | - $manager->deleteItems( array_keys( $result ) ); |
|
270 | + $result = $manager->searchItems($search); |
|
271 | + $manager->deleteItems(array_keys($result)); |
|
272 | 272 | |
273 | - $count = count( $result ); |
|
273 | + $count = count($result); |
|
274 | 274 | $start += $count; |
275 | - $search->setSlice( $start ); |
|
275 | + $search->setSlice($start); |
|
276 | 276 | } |
277 | - while( $count == $search->getSliceSize() ); |
|
277 | + while ($count == $search->getSliceSize()); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 |
@@ -42,20 +42,20 @@ discard block |
||
42 | 42 | * @param string|null $type Attribute type |
43 | 43 | * @return string|null Product ID or null if not found |
44 | 44 | */ |
45 | - public function get( $code, $type = null ) |
|
45 | + public function get($code, $type = null) |
|
46 | 46 | { |
47 | - if( isset( $this->prodmap[$code] ) ) { |
|
47 | + if (isset($this->prodmap[$code])) { |
|
48 | 48 | return $this->prodmap[$code]; |
49 | 49 | } |
50 | 50 | |
51 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'product' ); |
|
51 | + $manager = \Aimeos\MShop::create($this->getContext(), 'product'); |
|
52 | 52 | |
53 | 53 | $search = $manager->createSearch(); |
54 | - $search->setConditions( $search->compare( '==', 'product.code', $code ) ); |
|
54 | + $search->setConditions($search->compare('==', 'product.code', $code)); |
|
55 | 55 | |
56 | - $result = $manager->searchItems( $search ); |
|
56 | + $result = $manager->searchItems($search); |
|
57 | 57 | |
58 | - if( ( $item = reset( $result ) ) !== false ) |
|
58 | + if (($item = reset($result)) !== false) |
|
59 | 59 | { |
60 | 60 | $this->prodmap[$code] = $item->getId(); |
61 | 61 | return $this->prodmap[$code]; |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @param \Aimeos\MShop\Common\Item\Iface $item Product object |
70 | 70 | */ |
71 | - public function set( \Aimeos\MShop\Common\Item\Iface $item ) |
|
71 | + public function set(\Aimeos\MShop\Common\Item\Iface $item) |
|
72 | 72 | { |
73 | - $this->prodmap[ $item->getCode() ] = $item->getId(); |
|
73 | + $this->prodmap[$item->getCode()] = $item->getId(); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | \ No newline at end of file |