@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function getName() |
31 | 31 | { |
32 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Index optimization' ); |
|
32 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Index optimization'); |
|
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', 'Optimizes the index for searching products faster' ); |
|
43 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Optimizes the index for searching products faster'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -51,6 +51,6 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function run() |
53 | 53 | { |
54 | - \Aimeos\MShop\Index\Manager\Factory::create( $this->getContext() )->optimize(); |
|
54 | + \Aimeos\MShop\Index\Manager\Factory::create($this->getContext())->optimize(); |
|
55 | 55 | } |
56 | 56 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function getName() |
31 | 31 | { |
32 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Index rebuild' ); |
|
32 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Index rebuild'); |
|
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', 'Rebuilds the index for searching products' ); |
|
43 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Rebuilds the index for searching products'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -51,15 +51,15 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function run() |
53 | 53 | { |
54 | - $timestamp = date( 'Y-m-d H:i:s' ); |
|
54 | + $timestamp = date('Y-m-d H:i:s'); |
|
55 | 55 | $context = clone $this->getContext(); |
56 | 56 | |
57 | - $context->getLocale()->setLanguageId( null ); |
|
58 | - $context->getLocale()->setCurrencyId( null ); |
|
57 | + $context->getLocale()->setLanguageId(null); |
|
58 | + $context->getLocale()->setCurrencyId(null); |
|
59 | 59 | |
60 | - $manager = \Aimeos\MShop\Index\Manager\Factory::create( $context ); |
|
60 | + $manager = \Aimeos\MShop\Index\Manager\Factory::create($context); |
|
61 | 61 | |
62 | 62 | $manager->rebuildIndex(); |
63 | - $manager->cleanupIndex( $timestamp ); |
|
63 | + $manager->cleanupIndex($timestamp); |
|
64 | 64 | } |
65 | 65 | } |
@@ -15,14 +15,14 @@ discard block |
||
15 | 15 | public static function bootstrap() |
16 | 16 | { |
17 | 17 | self::getAimeos(); |
18 | - \Aimeos\MShop::cache( false ); |
|
18 | + \Aimeos\MShop::cache(false); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | |
22 | - public static function getContext( $site = 'unittest' ) |
|
22 | + public static function getContext($site = 'unittest') |
|
23 | 23 | { |
24 | - if( !isset( self::$context[$site] ) ) { |
|
25 | - self::$context[$site] = self::createContext( $site ); |
|
24 | + if (!isset(self::$context[$site])) { |
|
25 | + self::$context[$site] = self::createContext($site); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | return clone self::$context[$site]; |
@@ -31,13 +31,13 @@ discard block |
||
31 | 31 | |
32 | 32 | public static function getAimeos() |
33 | 33 | { |
34 | - if( !isset( self::$aimeos ) ) |
|
34 | + if (!isset(self::$aimeos)) |
|
35 | 35 | { |
36 | 36 | require_once 'Bootstrap.php'; |
37 | - spl_autoload_register( 'Aimeos\\Bootstrap::autoload' ); |
|
37 | + spl_autoload_register('Aimeos\\Bootstrap::autoload'); |
|
38 | 38 | |
39 | - $extdir = dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) ); |
|
40 | - self::$aimeos = new \Aimeos\Bootstrap( array( $extdir ), true ); |
|
39 | + $extdir = dirname(dirname(dirname(dirname(dirname(__FILE__))))); |
|
40 | + self::$aimeos = new \Aimeos\Bootstrap(array($extdir), true); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | return self::$aimeos; |
@@ -46,14 +46,14 @@ discard block |
||
46 | 46 | |
47 | 47 | public static function getControllerPaths() |
48 | 48 | { |
49 | - return self::getAimeos()->getCustomPaths( 'controller/jobs' ); |
|
49 | + return self::getAimeos()->getCustomPaths('controller/jobs'); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | |
53 | 53 | /** |
54 | 54 | * @param string $site |
55 | 55 | */ |
56 | - private static function createContext( $site ) |
|
56 | + private static function createContext($site) |
|
57 | 57 | { |
58 | 58 | $ctx = new \Aimeos\MShop\Context\Item\Standard(); |
59 | 59 | $aimeos = self::getAimeos(); |
@@ -63,80 +63,80 @@ discard block |
||
63 | 63 | $paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config'; |
64 | 64 | $file = __DIR__ . DIRECTORY_SEPARATOR . 'confdoc.ser'; |
65 | 65 | |
66 | - $conf = new \Aimeos\MW\Config\PHPArray( [], $paths ); |
|
67 | - $conf = new \Aimeos\MW\Config\Decorator\Memory( $conf ); |
|
68 | - $conf = new \Aimeos\MW\Config\Decorator\Documentor( $conf, $file ); |
|
69 | - $ctx->setConfig( $conf ); |
|
66 | + $conf = new \Aimeos\MW\Config\PHPArray([], $paths); |
|
67 | + $conf = new \Aimeos\MW\Config\Decorator\Memory($conf); |
|
68 | + $conf = new \Aimeos\MW\Config\Decorator\Documentor($conf, $file); |
|
69 | + $ctx->setConfig($conf); |
|
70 | 70 | |
71 | 71 | |
72 | - $logger = new \Aimeos\MW\Logger\File( $site . '.log', \Aimeos\MW\Logger\Base::DEBUG ); |
|
73 | - $ctx->setLogger( $logger ); |
|
72 | + $logger = new \Aimeos\MW\Logger\File($site . '.log', \Aimeos\MW\Logger\Base::DEBUG); |
|
73 | + $ctx->setLogger($logger); |
|
74 | 74 | |
75 | 75 | |
76 | - $dbm = new \Aimeos\MW\DB\Manager\PDO( $conf ); |
|
77 | - $ctx->setDatabaseManager( $dbm ); |
|
76 | + $dbm = new \Aimeos\MW\DB\Manager\PDO($conf); |
|
77 | + $ctx->setDatabaseManager($dbm); |
|
78 | 78 | |
79 | 79 | |
80 | - $fs = new \Aimeos\MW\Filesystem\Manager\Standard( $conf ); |
|
81 | - $ctx->setFilesystemManager( $fs ); |
|
80 | + $fs = new \Aimeos\MW\Filesystem\Manager\Standard($conf); |
|
81 | + $ctx->setFilesystemManager($fs); |
|
82 | 82 | |
83 | 83 | |
84 | - $mq = new \Aimeos\MW\MQueue\Manager\Standard( $conf ); |
|
85 | - $ctx->setMessageQueueManager( $mq ); |
|
84 | + $mq = new \Aimeos\MW\MQueue\Manager\Standard($conf); |
|
85 | + $ctx->setMessageQueueManager($mq); |
|
86 | 86 | |
87 | 87 | |
88 | 88 | $cache = new \Aimeos\MW\Cache\None(); |
89 | - $ctx->setCache( $cache ); |
|
89 | + $ctx->setCache($cache); |
|
90 | 90 | |
91 | 91 | |
92 | 92 | $session = new \Aimeos\MW\Session\None(); |
93 | - $ctx->setSession( $session ); |
|
93 | + $ctx->setSession($session); |
|
94 | 94 | |
95 | 95 | |
96 | - $i18n = new \Aimeos\MW\Translation\None( 'de' ); |
|
97 | - $ctx->setI18n( array( 'de' => $i18n ) ); |
|
96 | + $i18n = new \Aimeos\MW\Translation\None('de'); |
|
97 | + $ctx->setI18n(array('de' => $i18n)); |
|
98 | 98 | |
99 | 99 | |
100 | - $localeManager = \Aimeos\MShop\Locale\Manager\Factory::create( $ctx ); |
|
101 | - $locale = $localeManager->bootstrap( $site, 'de', '', false ); |
|
102 | - $ctx->setLocale( $locale ); |
|
100 | + $localeManager = \Aimeos\MShop\Locale\Manager\Factory::create($ctx); |
|
101 | + $locale = $localeManager->bootstrap($site, 'de', '', false); |
|
102 | + $ctx->setLocale($locale); |
|
103 | 103 | |
104 | 104 | |
105 | - $view = self::createView( $conf ); |
|
106 | - $ctx->setView( $view ); |
|
105 | + $view = self::createView($conf); |
|
106 | + $ctx->setView($view); |
|
107 | 107 | |
108 | 108 | |
109 | - $ctx->setEditor( 'core:controller/jobs' ); |
|
109 | + $ctx->setEditor('core:controller/jobs'); |
|
110 | 110 | |
111 | 111 | return $ctx; |
112 | 112 | } |
113 | 113 | |
114 | 114 | |
115 | - protected static function createView( \Aimeos\MW\Config\Iface $config ) |
|
115 | + protected static function createView(\Aimeos\MW\Config\Iface $config) |
|
116 | 116 | { |
117 | 117 | $tmplpaths = array_merge_recursive( |
118 | - self::getAimeos()->getCustomPaths( 'client/html/templates' ), |
|
119 | - self::getAimeos()->getCustomPaths( 'controller/jobs/templates' ) |
|
118 | + self::getAimeos()->getCustomPaths('client/html/templates'), |
|
119 | + self::getAimeos()->getCustomPaths('controller/jobs/templates') |
|
120 | 120 | ); |
121 | 121 | |
122 | - $view = new \Aimeos\MW\View\Standard( $tmplpaths ); |
|
122 | + $view = new \Aimeos\MW\View\Standard($tmplpaths); |
|
123 | 123 | |
124 | - $trans = new \Aimeos\MW\Translation\None( 'de_DE' ); |
|
125 | - $helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $trans ); |
|
126 | - $view->addHelper( 'translate', $helper ); |
|
124 | + $trans = new \Aimeos\MW\Translation\None('de_DE'); |
|
125 | + $helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $trans); |
|
126 | + $view->addHelper('translate', $helper); |
|
127 | 127 | |
128 | - $helper = new \Aimeos\MW\View\Helper\Url\Standard( $view, 'http://baseurl' ); |
|
129 | - $view->addHelper( 'url', $helper ); |
|
128 | + $helper = new \Aimeos\MW\View\Helper\Url\Standard($view, 'http://baseurl'); |
|
129 | + $view->addHelper('url', $helper); |
|
130 | 130 | |
131 | - $helper = new \Aimeos\MW\View\Helper\Number\Standard( $view, '.', '' ); |
|
132 | - $view->addHelper( 'number', $helper ); |
|
131 | + $helper = new \Aimeos\MW\View\Helper\Number\Standard($view, '.', ''); |
|
132 | + $view->addHelper('number', $helper); |
|
133 | 133 | |
134 | - $helper = new \Aimeos\MW\View\Helper\Date\Standard( $view, 'Y-m-d' ); |
|
135 | - $view->addHelper( 'date', $helper ); |
|
134 | + $helper = new \Aimeos\MW\View\Helper\Date\Standard($view, 'Y-m-d'); |
|
135 | + $view->addHelper('date', $helper); |
|
136 | 136 | |
137 | - $config = new \Aimeos\MW\Config\Decorator\Protect( $config, array( 'controller/jobs', 'client/html' ) ); |
|
138 | - $helper = new \Aimeos\MW\View\Helper\Config\Standard( $view, $config ); |
|
139 | - $view->addHelper( 'config', $helper ); |
|
137 | + $config = new \Aimeos\MW\Config\Decorator\Protect($config, array('controller/jobs', 'client/html')); |
|
138 | + $helper = new \Aimeos\MW\View\Helper\Config\Standard($view, $config); |
|
139 | + $view->addHelper('config', $helper); |
|
140 | 140 | |
141 | 141 | return $view; |
142 | 142 | } |
@@ -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::createController( $this->context, $aimeos, 'Standard' ); |
|
65 | + $cntl = \Aimeos\Controller\Jobs\Product\Import\Csv\Factory::createController($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 |
@@ -18,119 +18,119 @@ 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/product/import/csv/skip-lines', 1 ); |
|
28 | - $config->set( 'controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/valid' ); |
|
27 | + $config->set('controller/jobs/product/import/csv/skip-lines', 1); |
|
28 | + $config->set('controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/valid'); |
|
29 | 29 | |
30 | - $this->object = new \Aimeos\Controller\Jobs\Product\Import\Csv\Standard( $this->context, $this->aimeos ); |
|
30 | + $this->object = new \Aimeos\Controller\Jobs\Product\Import\Csv\Standard($this->context, $this->aimeos); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
34 | 34 | protected function tearDown() |
35 | 35 | { |
36 | - \Aimeos\MShop::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( 'Product import CSV', $this->object->getName() ); |
|
49 | + $this->assertEquals('Product import CSV', $this->object->getName()); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | |
53 | 53 | public function testGetDescription() |
54 | 54 | { |
55 | 55 | $text = 'Imports new and updates existing products from CSV files'; |
56 | - $this->assertEquals( $text, $this->object->getDescription() ); |
|
56 | + $this->assertEquals($text, $this->object->getDescription()); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | |
60 | 60 | public function testRun() |
61 | 61 | { |
62 | - $prodcodes = array( 'job_csv_test', 'job_csv_test2' ); |
|
63 | - $nondelete = array( 'attribute', 'product' ); |
|
64 | - $delete = array( 'media', 'price', 'text' ); |
|
62 | + $prodcodes = array('job_csv_test', 'job_csv_test2'); |
|
63 | + $nondelete = array('attribute', 'product'); |
|
64 | + $delete = array('media', 'price', 'text'); |
|
65 | 65 | |
66 | 66 | $convert = array( |
67 | 67 | 1 => 'Text/LatinUTF8', |
68 | 68 | ); |
69 | 69 | |
70 | - $this->context->getConfig()->set( 'controller/jobs/product/import/csv/converter', $convert ); |
|
70 | + $this->context->getConfig()->set('controller/jobs/product/import/csv/converter', $convert); |
|
71 | 71 | |
72 | 72 | $this->object->run(); |
73 | 73 | |
74 | - $result = $this->get( $prodcodes, array_merge( $delete, $nondelete ) ); |
|
75 | - $properties = $this->getProperties( array_keys( $result ) ); |
|
76 | - $this->delete( $prodcodes, $delete, $nondelete ); |
|
74 | + $result = $this->get($prodcodes, array_merge($delete, $nondelete)); |
|
75 | + $properties = $this->getProperties(array_keys($result)); |
|
76 | + $this->delete($prodcodes, $delete, $nondelete); |
|
77 | 77 | |
78 | - $this->assertEquals( 2, count( $result ) ); |
|
79 | - $this->assertEquals( 2, count( $properties ) ); |
|
78 | + $this->assertEquals(2, count($result)); |
|
79 | + $this->assertEquals(2, count($properties)); |
|
80 | 80 | |
81 | - foreach( $result as $product ) { |
|
82 | - $this->assertEquals( 5, count( $product->getListItems() ) ); |
|
81 | + foreach ($result as $product) { |
|
82 | + $this->assertEquals(5, count($product->getListItems())); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | 86 | |
87 | 87 | public function testRunUpdate() |
88 | 88 | { |
89 | - $prodcodes = array( 'job_csv_test', 'job_csv_test2' ); |
|
90 | - $nondelete = array( 'attribute', 'product' ); |
|
91 | - $delete = array( 'media', 'price', 'text' ); |
|
89 | + $prodcodes = array('job_csv_test', 'job_csv_test2'); |
|
90 | + $nondelete = array('attribute', 'product'); |
|
91 | + $delete = array('media', 'price', 'text'); |
|
92 | 92 | |
93 | 93 | $this->object->run(); |
94 | 94 | $this->object->run(); |
95 | 95 | |
96 | - $result = $this->get( $prodcodes, array_merge( $delete, $nondelete ) ); |
|
97 | - $properties = $this->getProperties( array_keys( $result ) ); |
|
98 | - $this->delete( $prodcodes, $delete, $nondelete ); |
|
96 | + $result = $this->get($prodcodes, array_merge($delete, $nondelete)); |
|
97 | + $properties = $this->getProperties(array_keys($result)); |
|
98 | + $this->delete($prodcodes, $delete, $nondelete); |
|
99 | 99 | |
100 | - $this->assertEquals( 2, count( $result ) ); |
|
101 | - $this->assertEquals( 2, count( $properties ) ); |
|
100 | + $this->assertEquals(2, count($result)); |
|
101 | + $this->assertEquals(2, count($properties)); |
|
102 | 102 | |
103 | - foreach( $result as $product ) { |
|
104 | - $this->assertEquals( 5, count( $product->getListItems() ) ); |
|
103 | + foreach ($result as $product) { |
|
104 | + $this->assertEquals(5, count($product->getListItems())); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
108 | 108 | |
109 | 109 | public function testRunPosition() |
110 | 110 | { |
111 | - $prodcodes = array( 'job_csv_test', 'job_csv_test2' ); |
|
112 | - $nondelete = array( 'attribute', 'product' ); |
|
113 | - $delete = array( 'media', 'price', 'text' ); |
|
111 | + $prodcodes = array('job_csv_test', 'job_csv_test2'); |
|
112 | + $nondelete = array('attribute', 'product'); |
|
113 | + $delete = array('media', 'price', 'text'); |
|
114 | 114 | |
115 | 115 | $config = $this->context->getConfig(); |
116 | - $mapping = $config->set( 'controller/jobs/product/import/csv/mapping', [] ); |
|
117 | - $mapping['item'] = array( 0 => 'product.label', 1 => 'product.code' ); |
|
116 | + $mapping = $config->set('controller/jobs/product/import/csv/mapping', []); |
|
117 | + $mapping['item'] = array(0 => 'product.label', 1 => 'product.code'); |
|
118 | 118 | |
119 | - $config->set( 'controller/jobs/product/import/csv/mapping', $mapping ); |
|
120 | - $config->set( 'controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/position' ); |
|
119 | + $config->set('controller/jobs/product/import/csv/mapping', $mapping); |
|
120 | + $config->set('controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/position'); |
|
121 | 121 | |
122 | 122 | $this->object->run(); |
123 | 123 | |
124 | - $result = $this->get( $prodcodes, array_merge( $delete, $nondelete ) ); |
|
125 | - $this->delete( $prodcodes, $delete, $nondelete ); |
|
124 | + $result = $this->get($prodcodes, array_merge($delete, $nondelete)); |
|
125 | + $this->delete($prodcodes, $delete, $nondelete); |
|
126 | 126 | |
127 | - $this->assertEquals( 2, count( $result ) ); |
|
127 | + $this->assertEquals(2, count($result)); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | |
131 | 131 | public function testRunProcessorInvalidPosition() |
132 | 132 | { |
133 | - $prodcodes = array( 'job_csv_test', 'job_csv_test2' ); |
|
133 | + $prodcodes = array('job_csv_test', 'job_csv_test2'); |
|
134 | 134 | |
135 | 135 | $mapping = array( |
136 | 136 | 'item' => array( |
@@ -150,11 +150,11 @@ discard block |
||
150 | 150 | ), |
151 | 151 | ); |
152 | 152 | |
153 | - $this->context->getConfig()->set( 'controller/jobs/product/import/csv/mapping', $mapping ); |
|
153 | + $this->context->getConfig()->set('controller/jobs/product/import/csv/mapping', $mapping); |
|
154 | 154 | |
155 | 155 | $this->object->run(); |
156 | 156 | |
157 | - $this->delete( $prodcodes, array( 'text', 'media' ), [] ); |
|
157 | + $this->delete($prodcodes, array('text', 'media'), []); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | ), |
167 | 167 | ); |
168 | 168 | |
169 | - $this->context->getConfig()->set( 'controller/jobs/product/import/csv/mapping', $mapping ); |
|
169 | + $this->context->getConfig()->set('controller/jobs/product/import/csv/mapping', $mapping); |
|
170 | 170 | |
171 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
171 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
172 | 172 | $this->object->run(); |
173 | 173 | } |
174 | 174 | |
@@ -208,15 +208,15 @@ discard block |
||
208 | 208 | ), |
209 | 209 | ); |
210 | 210 | |
211 | - $this->context->getConfig()->set( 'controller/jobs/product/import/csv/mapping', $mapping ); |
|
211 | + $this->context->getConfig()->set('controller/jobs/product/import/csv/mapping', $mapping); |
|
212 | 212 | |
213 | 213 | $config = $this->context->getConfig(); |
214 | - $config->set( 'controller/jobs/product/import/csv/skip-lines', 0 ); |
|
215 | - $config->set( 'controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/invalid' ); |
|
214 | + $config->set('controller/jobs/product/import/csv/skip-lines', 0); |
|
215 | + $config->set('controller/jobs/product/import/csv/location', __DIR__ . '/_testfiles/invalid'); |
|
216 | 216 | |
217 | - $this->object = new \Aimeos\Controller\Jobs\Product\Import\Csv\Standard( $this->context, $this->aimeos ); |
|
217 | + $this->object = new \Aimeos\Controller\Jobs\Product\Import\Csv\Standard($this->context, $this->aimeos); |
|
218 | 218 | |
219 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
219 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
220 | 220 | $this->object->run(); |
221 | 221 | } |
222 | 222 | |
@@ -224,104 +224,104 @@ discard block |
||
224 | 224 | public function testRunBackup() |
225 | 225 | { |
226 | 226 | $config = $this->context->getConfig(); |
227 | - $config->set( 'controller/jobs/product/import/csv/container/type', 'Zip' ); |
|
228 | - $config->set( 'controller/jobs/product/import/csv/location', 'tmp/import.zip' ); |
|
229 | - $config->set( 'controller/jobs/product/import/csv/backup', 'tmp/test-%Y-%m-%d.zip' ); |
|
227 | + $config->set('controller/jobs/product/import/csv/container/type', 'Zip'); |
|
228 | + $config->set('controller/jobs/product/import/csv/location', 'tmp/import.zip'); |
|
229 | + $config->set('controller/jobs/product/import/csv/backup', 'tmp/test-%Y-%m-%d.zip'); |
|
230 | 230 | |
231 | - if( copy( __DIR__ . '/_testfiles/import.zip', 'tmp/import.zip' ) === false ) { |
|
232 | - throw new \RuntimeException( 'Unable to copy test file' ); |
|
231 | + if (copy(__DIR__ . '/_testfiles/import.zip', 'tmp/import.zip') === false) { |
|
232 | + throw new \RuntimeException('Unable to copy test file'); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | $this->object->run(); |
236 | 236 | |
237 | - $filename = strftime( 'tmp/test-%Y-%m-%d.zip' ); |
|
238 | - $this->assertTrue( file_exists( $filename ) ); |
|
237 | + $filename = strftime('tmp/test-%Y-%m-%d.zip'); |
|
238 | + $this->assertTrue(file_exists($filename)); |
|
239 | 239 | |
240 | - unlink( $filename ); |
|
240 | + unlink($filename); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | |
244 | 244 | public function testRunBackupInvalid() |
245 | 245 | { |
246 | 246 | $config = $this->context->getConfig(); |
247 | - $config->set( 'controller/jobs/product/import/csv/container/type', 'Zip' ); |
|
248 | - $config->set( 'controller/jobs/product/import/csv/location', 'tmp/import.zip' ); |
|
249 | - $config->set( 'controller/jobs/product/import/csv/backup', 'tmp/notexist/import.zip' ); |
|
247 | + $config->set('controller/jobs/product/import/csv/container/type', 'Zip'); |
|
248 | + $config->set('controller/jobs/product/import/csv/location', 'tmp/import.zip'); |
|
249 | + $config->set('controller/jobs/product/import/csv/backup', 'tmp/notexist/import.zip'); |
|
250 | 250 | |
251 | - if( copy( __DIR__ . '/_testfiles/import.zip', 'tmp/import.zip' ) === false ) { |
|
252 | - throw new \RuntimeException( 'Unable to copy test file' ); |
|
251 | + if (copy(__DIR__ . '/_testfiles/import.zip', 'tmp/import.zip') === false) { |
|
252 | + throw new \RuntimeException('Unable to copy test file'); |
|
253 | 253 | } |
254 | 254 | |
255 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
255 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
256 | 256 | $this->object->run(); |
257 | 257 | } |
258 | 258 | |
259 | 259 | |
260 | - protected function delete( array $prodcodes, array $delete, array $nondelete ) |
|
260 | + protected function delete(array $prodcodes, array $delete, array $nondelete) |
|
261 | 261 | { |
262 | - $catListManager = \Aimeos\MShop\Catalog\Manager\Factory::create( $this->context )->getSubmanager( 'lists' ); |
|
263 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::create( $this->context ); |
|
264 | - $listManager = $productManager->getSubManager( 'lists' ); |
|
262 | + $catListManager = \Aimeos\MShop\Catalog\Manager\Factory::create($this->context)->getSubmanager('lists'); |
|
263 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::create($this->context); |
|
264 | + $listManager = $productManager->getSubManager('lists'); |
|
265 | 265 | |
266 | - foreach( $this->get( $prodcodes, $delete + $nondelete ) as $id => $product ) |
|
266 | + foreach ($this->get($prodcodes, $delete + $nondelete) as $id => $product) |
|
267 | 267 | { |
268 | - foreach( $delete as $domain ) |
|
268 | + foreach ($delete as $domain) |
|
269 | 269 | { |
270 | - $manager = \Aimeos\MShop::create( $this->context, $domain ); |
|
270 | + $manager = \Aimeos\MShop::create($this->context, $domain); |
|
271 | 271 | |
272 | - foreach( $product->getListItems( $domain ) as $listItem ) |
|
272 | + foreach ($product->getListItems($domain) as $listItem) |
|
273 | 273 | { |
274 | - $manager->deleteItem( $listItem->getRefItem()->getId() ); |
|
275 | - $listManager->deleteItem( $listItem->getId() ); |
|
274 | + $manager->deleteItem($listItem->getRefItem()->getId()); |
|
275 | + $listManager->deleteItem($listItem->getId()); |
|
276 | 276 | } |
277 | 277 | } |
278 | 278 | |
279 | - foreach( $nondelete as $domain ) |
|
279 | + foreach ($nondelete as $domain) |
|
280 | 280 | { |
281 | - $ids = array_keys( $product->getListItems( $domain ) ); |
|
282 | - $listManager->deleteItems( $ids ); |
|
281 | + $ids = array_keys($product->getListItems($domain)); |
|
282 | + $listManager->deleteItems($ids); |
|
283 | 283 | } |
284 | 284 | |
285 | - $productManager->deleteItem( $product->getId() ); |
|
285 | + $productManager->deleteItem($product->getId()); |
|
286 | 286 | |
287 | 287 | $search = $catListManager->createSearch(); |
288 | - $search->setConditions( $search->compare( '==', 'catalog.lists.refid', $id ) ); |
|
289 | - $result = $catListManager->searchItems( $search ); |
|
288 | + $search->setConditions($search->compare('==', 'catalog.lists.refid', $id)); |
|
289 | + $result = $catListManager->searchItems($search); |
|
290 | 290 | |
291 | - $catListManager->deleteItems( array_keys( $result ) ); |
|
291 | + $catListManager->deleteItems(array_keys($result)); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | |
295 | - $attrManager = \Aimeos\MShop\Attribute\Manager\Factory::create( $this->context ); |
|
295 | + $attrManager = \Aimeos\MShop\Attribute\Manager\Factory::create($this->context); |
|
296 | 296 | |
297 | 297 | $search = $attrManager->createSearch(); |
298 | - $search->setConditions( $search->compare( '==', 'attribute.code', 'import-test' ) ); |
|
298 | + $search->setConditions($search->compare('==', 'attribute.code', 'import-test')); |
|
299 | 299 | |
300 | - $result = $attrManager->searchItems( $search ); |
|
300 | + $result = $attrManager->searchItems($search); |
|
301 | 301 | |
302 | - $attrManager->deleteItems( array_keys( $result ) ); |
|
302 | + $attrManager->deleteItems(array_keys($result)); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | |
306 | - protected function get( array $prodcodes, array $domains ) |
|
306 | + protected function get(array $prodcodes, array $domains) |
|
307 | 307 | { |
308 | - $productManager = \Aimeos\MShop\Product\Manager\Factory::create( $this->context ); |
|
308 | + $productManager = \Aimeos\MShop\Product\Manager\Factory::create($this->context); |
|
309 | 309 | |
310 | 310 | $search = $productManager->createSearch(); |
311 | - $search->setConditions( $search->compare( '==', 'product.code', $prodcodes ) ); |
|
311 | + $search->setConditions($search->compare('==', 'product.code', $prodcodes)); |
|
312 | 312 | |
313 | - return $productManager->searchItems( $search, $domains ); |
|
313 | + return $productManager->searchItems($search, $domains); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | |
317 | - protected function getProperties( array $prodids ) |
|
317 | + protected function getProperties(array $prodids) |
|
318 | 318 | { |
319 | - $manager = \Aimeos\MShop\Product\Manager\Factory::create( $this->context )->getSubManager( 'property' ); |
|
319 | + $manager = \Aimeos\MShop\Product\Manager\Factory::create($this->context)->getSubManager('property'); |
|
320 | 320 | |
321 | 321 | $search = $manager->createSearch(); |
322 | - $search->setConditions( $search->compare( '==', 'product.property.parentid', $prodids ) ); |
|
323 | - $search->setSortations( array( $search->sort( '+', 'product.property.type' ) ) ); |
|
322 | + $search->setConditions($search->compare('==', 'product.property.parentid', $prodids)); |
|
323 | + $search->setSortations(array($search->sort('+', 'product.property.type'))); |
|
324 | 324 | |
325 | - return $manager->searchItems( $search ); |
|
325 | + return $manager->searchItems($search); |
|
326 | 326 | } |
327 | 327 | } |
328 | 328 | \ No newline at end of file |
@@ -20,95 +20,95 @@ |
||
20 | 20 | $this->context = \TestHelperJobs::getContext(); |
21 | 21 | $aimeos = \TestHelperJobs::getAimeos(); |
22 | 22 | |
23 | - $this->object = new \Aimeos\Controller\Jobs\Subscription\Export\Csv\Standard( $this->context, $aimeos ); |
|
23 | + $this->object = new \Aimeos\Controller\Jobs\Subscription\Export\Csv\Standard($this->context, $aimeos); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | |
27 | 27 | protected function tearDown() |
28 | 28 | { |
29 | - unset( $this->object, $this->context ); |
|
29 | + unset($this->object, $this->context); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | |
33 | 33 | public function testGetName() |
34 | 34 | { |
35 | - $this->assertEquals( 'Subscription export CSV', $this->object->getName() ); |
|
35 | + $this->assertEquals('Subscription export CSV', $this->object->getName()); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
39 | 39 | public function testGetDescription() |
40 | 40 | { |
41 | - $this->assertEquals( 'Exports subscriptions to CSV file', $this->object->getDescription() ); |
|
41 | + $this->assertEquals('Exports subscriptions to CSV file', $this->object->getDescription()); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | |
45 | 45 | public function testRun() |
46 | 46 | { |
47 | - $mqmStub = $this->getMockBuilder( '\\Aimeos\\MW\\MQueue\\Manager\\Standard' ) |
|
48 | - ->setConstructorArgs( [$this->context->getConfig()] ) |
|
49 | - ->setMethods( ['get'] ) |
|
47 | + $mqmStub = $this->getMockBuilder('\\Aimeos\\MW\\MQueue\\Manager\\Standard') |
|
48 | + ->setConstructorArgs([$this->context->getConfig()]) |
|
49 | + ->setMethods(['get']) |
|
50 | 50 | ->getMock(); |
51 | 51 | |
52 | - $mqStub = $this->getMockBuilder( '\\Aimeos\\MW\\MQueue\\Standard' ) |
|
52 | + $mqStub = $this->getMockBuilder('\\Aimeos\\MW\\MQueue\\Standard') |
|
53 | 53 | ->disableOriginalConstructor() |
54 | - ->setMethods( ['getQueue'] ) |
|
54 | + ->setMethods(['getQueue']) |
|
55 | 55 | ->getMock(); |
56 | 56 | |
57 | - $queueStub = $this->getMockBuilder( '\\Aimeos\\MW\\MQueue\\Queue\\Standard' ) |
|
57 | + $queueStub = $this->getMockBuilder('\\Aimeos\\MW\\MQueue\\Queue\\Standard') |
|
58 | 58 | ->disableOriginalConstructor() |
59 | - ->setMethods( ['del', 'get'] ) |
|
59 | + ->setMethods(['del', 'get']) |
|
60 | 60 | ->getMock(); |
61 | 61 | |
62 | - $msgStub = $this->getMockBuilder( '\\Aimeos\\MW\\MQueue\\Message\\Standard' ) |
|
62 | + $msgStub = $this->getMockBuilder('\\Aimeos\\MW\\MQueue\\Message\\Standard') |
|
63 | 63 | ->disableOriginalConstructor() |
64 | - ->setMethods( ['getBody'] ) |
|
64 | + ->setMethods(['getBody']) |
|
65 | 65 | ->getMock(); |
66 | 66 | |
67 | 67 | |
68 | - $this->context->setMessageQueueManager( $mqmStub ); |
|
68 | + $this->context->setMessageQueueManager($mqmStub); |
|
69 | 69 | |
70 | 70 | |
71 | - $mqmStub->expects( $this->once() )->method( 'get' ) |
|
72 | - ->will( $this->returnValue( $mqStub ) ); |
|
71 | + $mqmStub->expects($this->once())->method('get') |
|
72 | + ->will($this->returnValue($mqStub)); |
|
73 | 73 | |
74 | - $mqStub->expects( $this->once() )->method( 'getQueue' ) |
|
75 | - ->will( $this->returnValue( $queueStub ) ); |
|
74 | + $mqStub->expects($this->once())->method('getQueue') |
|
75 | + ->will($this->returnValue($queueStub)); |
|
76 | 76 | |
77 | - $queueStub->expects( $this->exactly( 2 ) )->method( 'get' ) |
|
78 | - ->will( $this->onConsecutiveCalls( $msgStub, null ) ); |
|
77 | + $queueStub->expects($this->exactly(2))->method('get') |
|
78 | + ->will($this->onConsecutiveCalls($msgStub, null)); |
|
79 | 79 | |
80 | - $queueStub->expects( $this->once() )->method( 'del' ); |
|
80 | + $queueStub->expects($this->once())->method('del'); |
|
81 | 81 | |
82 | - $msgStub->expects( $this->once() )->method( 'getBody' ) |
|
83 | - ->will( $this->returnValue( '{"sitecode":"unittest"}' ) ); |
|
82 | + $msgStub->expects($this->once())->method('getBody') |
|
83 | + ->will($this->returnValue('{"sitecode":"unittest"}')); |
|
84 | 84 | |
85 | 85 | |
86 | 86 | $this->object->run(); |
87 | 87 | |
88 | 88 | |
89 | - $jobManager = \Aimeos\MAdmin::create( $this->context, 'job' ); |
|
89 | + $jobManager = \Aimeos\MAdmin::create($this->context, 'job'); |
|
90 | 90 | $jobSearch = $jobManager->createSearch(); |
91 | - $jobSearch->setConditions( $jobSearch->compare( '=~', 'job.label', 'subscription-export_' ) ); |
|
92 | - $jobItems = $jobManager->searchItems( $jobSearch ); |
|
93 | - $jobManager->deleteItems( array_keys( $jobItems ) ); |
|
91 | + $jobSearch->setConditions($jobSearch->compare('=~', 'job.label', 'subscription-export_')); |
|
92 | + $jobItems = $jobManager->searchItems($jobSearch); |
|
93 | + $jobManager->deleteItems(array_keys($jobItems)); |
|
94 | 94 | |
95 | - $this->assertEquals( 1, count( $jobItems ) ); |
|
95 | + $this->assertEquals(1, count($jobItems)); |
|
96 | 96 | |
97 | 97 | |
98 | - $filename = dirname( dirname( dirname( dirname( dirname( __DIR__ ) ) ) ) ) . '/tmp/' . reset( $jobItems )->getLabel(); |
|
99 | - $fp = fopen( $filename, 'r' ); |
|
98 | + $filename = dirname(dirname(dirname(dirname(dirname(__DIR__))))) . '/tmp/' . reset($jobItems)->getLabel(); |
|
99 | + $fp = fopen($filename, 'r'); |
|
100 | 100 | |
101 | - $subscription = fgetcsv( $fp ); |
|
102 | - $address1 = fgetcsv( $fp ); |
|
103 | - $address2 = fgetcsv( $fp ); |
|
104 | - $product1 = fgetcsv( $fp ); |
|
101 | + $subscription = fgetcsv($fp); |
|
102 | + $address1 = fgetcsv($fp); |
|
103 | + $address2 = fgetcsv($fp); |
|
104 | + $product1 = fgetcsv($fp); |
|
105 | 105 | |
106 | - fclose( $fp ); |
|
107 | - unlink( $filename ); |
|
106 | + fclose($fp); |
|
107 | + unlink($filename); |
|
108 | 108 | |
109 | - $this->assertEquals( 'subscription', $subscription[0] ); |
|
110 | - $this->assertEquals( 'address', $address1[0] ); |
|
111 | - $this->assertEquals( 'address', $address2[0] ); |
|
112 | - $this->assertEquals( 'product', $product1[0] ); |
|
109 | + $this->assertEquals('subscription', $subscription[0]); |
|
110 | + $this->assertEquals('address', $address1[0]); |
|
111 | + $this->assertEquals('address', $address2[0]); |
|
112 | + $this->assertEquals('product', $product1[0]); |
|
113 | 113 | } |
114 | 114 | } |
@@ -20,49 +20,49 @@ discard block |
||
20 | 20 | $aimeos = \TestHelperJobs::getAimeos(); |
21 | 21 | $this->context = \TestHelperJobs::getContext(); |
22 | 22 | |
23 | - $this->object = new \Aimeos\Controller\Jobs\Subscription\Process\End\Standard( $this->context, $aimeos ); |
|
23 | + $this->object = new \Aimeos\Controller\Jobs\Subscription\Process\End\Standard($this->context, $aimeos); |
|
24 | 24 | |
25 | - \Aimeos\MShop::cache( true ); |
|
25 | + \Aimeos\MShop::cache(true); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
29 | 29 | protected function tearDown() |
30 | 30 | { |
31 | - \Aimeos\MShop::cache( false ); |
|
31 | + \Aimeos\MShop::cache(false); |
|
32 | 32 | \Aimeos\MShop::clear(); |
33 | 33 | |
34 | - unset( $this->object, $this->context ); |
|
34 | + unset($this->object, $this->context); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
38 | 38 | public function testGetName() |
39 | 39 | { |
40 | - $this->assertEquals( 'Subscription process end', $this->object->getName() ); |
|
40 | + $this->assertEquals('Subscription process end', $this->object->getName()); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
44 | 44 | public function testGetDescription() |
45 | 45 | { |
46 | - $this->assertEquals( 'Terminates expired subscriptions', $this->object->getDescription() ); |
|
46 | + $this->assertEquals('Terminates expired subscriptions', $this->object->getDescription()); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
50 | 50 | public function testRun() |
51 | 51 | { |
52 | - $this->context->getConfig()->set( 'controller/common/subscription/process/processors', ['cgroup'] ); |
|
52 | + $this->context->getConfig()->set('controller/common/subscription/process/processors', ['cgroup']); |
|
53 | 53 | $item = $this->getSubscription(); |
54 | 54 | |
55 | - $managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Subscription\\Manager\\Standard' ) |
|
56 | - ->setConstructorArgs( [$this->context] ) |
|
57 | - ->setMethods( ['searchItems', 'saveItem'] ) |
|
55 | + $managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Subscription\\Manager\\Standard') |
|
56 | + ->setConstructorArgs([$this->context]) |
|
57 | + ->setMethods(['searchItems', 'saveItem']) |
|
58 | 58 | ->getMock(); |
59 | 59 | |
60 | - \Aimeos\MShop::inject( $this->context, 'subscription', $managerStub ); |
|
60 | + \Aimeos\MShop::inject($this->context, 'subscription', $managerStub); |
|
61 | 61 | |
62 | - $managerStub->expects( $this->once() )->method( 'searchItems' ) |
|
63 | - ->will( $this->returnValue( [$item] ) ); |
|
62 | + $managerStub->expects($this->once())->method('searchItems') |
|
63 | + ->will($this->returnValue([$item])); |
|
64 | 64 | |
65 | - $managerStub->expects( $this->once() )->method( 'saveItem' ); |
|
65 | + $managerStub->expects($this->once())->method('saveItem'); |
|
66 | 66 | |
67 | 67 | $this->object->run(); |
68 | 68 | } |
@@ -70,20 +70,20 @@ discard block |
||
70 | 70 | |
71 | 71 | public function testRunException() |
72 | 72 | { |
73 | - $this->context->getConfig()->set( 'controller/common/subscription/process/processors', ['cgroup'] ); |
|
74 | - $this->context->getConfig()->set( 'controller/common/subscription/process/processor/cgroup/groupids', ['1'] ); |
|
73 | + $this->context->getConfig()->set('controller/common/subscription/process/processors', ['cgroup']); |
|
74 | + $this->context->getConfig()->set('controller/common/subscription/process/processor/cgroup/groupids', ['1']); |
|
75 | 75 | |
76 | - $managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Subscription\\Manager\\Standard' ) |
|
77 | - ->setConstructorArgs( [$this->context] ) |
|
78 | - ->setMethods( ['searchItems', 'saveItem'] ) |
|
76 | + $managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Subscription\\Manager\\Standard') |
|
77 | + ->setConstructorArgs([$this->context]) |
|
78 | + ->setMethods(['searchItems', 'saveItem']) |
|
79 | 79 | ->getMock(); |
80 | 80 | |
81 | - \Aimeos\MShop::inject( $this->context, 'subscription', $managerStub ); |
|
81 | + \Aimeos\MShop::inject($this->context, 'subscription', $managerStub); |
|
82 | 82 | |
83 | - $managerStub->expects( $this->once() )->method( 'searchItems' ) |
|
84 | - ->will( $this->returnValue( [$managerStub->createItem()] ) ); |
|
83 | + $managerStub->expects($this->once())->method('searchItems') |
|
84 | + ->will($this->returnValue([$managerStub->createItem()])); |
|
85 | 85 | |
86 | - $managerStub->expects( $this->never() )->method( 'saveItem' ); |
|
86 | + $managerStub->expects($this->never())->method('saveItem'); |
|
87 | 87 | |
88 | 88 | $this->object->run(); |
89 | 89 | } |
@@ -91,17 +91,17 @@ discard block |
||
91 | 91 | |
92 | 92 | protected function getSubscription() |
93 | 93 | { |
94 | - $manager = \Aimeos\MShop::create( $this->context, 'subscription' ); |
|
94 | + $manager = \Aimeos\MShop::create($this->context, 'subscription'); |
|
95 | 95 | |
96 | 96 | $search = $manager->createSearch(); |
97 | - $search->setConditions( $search->compare( '==', 'subscription.dateend', '2010-01-01' ) ); |
|
97 | + $search->setConditions($search->compare('==', 'subscription.dateend', '2010-01-01')); |
|
98 | 98 | |
99 | - $items = $manager->searchItems( $search ); |
|
99 | + $items = $manager->searchItems($search); |
|
100 | 100 | |
101 | - if( ( $item = reset( $items ) ) !== false ) { |
|
101 | + if (($item = reset($items)) !== false) { |
|
102 | 102 | return $item; |
103 | 103 | } |
104 | 104 | |
105 | - throw new \Exception( 'No subscription item found' ); |
|
105 | + throw new \Exception('No subscription item found'); |
|
106 | 106 | } |
107 | 107 | } |
@@ -21,62 +21,62 @@ discard block |
||
21 | 21 | $this->aimeos = \TestHelperJobs::getAimeos(); |
22 | 22 | $this->context = \TestHelperJobs::getContext(); |
23 | 23 | |
24 | - $this->object = new \Aimeos\Controller\Jobs\Subscription\Process\Renew\Standard( $this->context, $this->aimeos ); |
|
24 | + $this->object = new \Aimeos\Controller\Jobs\Subscription\Process\Renew\Standard($this->context, $this->aimeos); |
|
25 | 25 | |
26 | - \Aimeos\MShop::cache( true ); |
|
26 | + \Aimeos\MShop::cache(true); |
|
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 | - unset( $this->object, $this->context, $this->aimeos ); |
|
35 | + unset($this->object, $this->context, $this->aimeos); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
39 | 39 | public function testGetName() |
40 | 40 | { |
41 | - $this->assertEquals( 'Subscription process renew', $this->object->getName() ); |
|
41 | + $this->assertEquals('Subscription process renew', $this->object->getName()); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | |
45 | 45 | public function testGetDescription() |
46 | 46 | { |
47 | - $this->assertEquals( 'Renews subscriptions at next date', $this->object->getDescription() ); |
|
47 | + $this->assertEquals('Renews subscriptions at next date', $this->object->getDescription()); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | |
51 | 51 | public function testRun() |
52 | 52 | { |
53 | - $this->context->getConfig()->set( 'controller/common/subscription/process/processors', ['cgroup'] ); |
|
53 | + $this->context->getConfig()->set('controller/common/subscription/process/processors', ['cgroup']); |
|
54 | 54 | $item = $this->getSubscription(); |
55 | 55 | |
56 | - $object = $this->getMockBuilder( '\\Aimeos\\Controller\\Jobs\\Subscription\\Process\\Renew\\Standard' ) |
|
57 | - ->setConstructorArgs( [$this->context, $this->aimeos] ) |
|
58 | - ->setMethods( ['createOrderBase', 'createOrderInvoice', 'createPayment'] ) |
|
56 | + $object = $this->getMockBuilder('\\Aimeos\\Controller\\Jobs\\Subscription\\Process\\Renew\\Standard') |
|
57 | + ->setConstructorArgs([$this->context, $this->aimeos]) |
|
58 | + ->setMethods(['createOrderBase', 'createOrderInvoice', 'createPayment']) |
|
59 | 59 | ->getMock(); |
60 | 60 | |
61 | - $managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Subscription\\Manager\\Standard' ) |
|
62 | - ->setConstructorArgs( [$this->context] ) |
|
63 | - ->setMethods( ['searchItems', 'saveItem'] ) |
|
61 | + $managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Subscription\\Manager\\Standard') |
|
62 | + ->setConstructorArgs([$this->context]) |
|
63 | + ->setMethods(['searchItems', 'saveItem']) |
|
64 | 64 | ->getMock(); |
65 | 65 | |
66 | - \Aimeos\MShop::inject( $this->context, 'subscription', $managerStub ); |
|
66 | + \Aimeos\MShop::inject($this->context, 'subscription', $managerStub); |
|
67 | 67 | |
68 | - $object->expects( $this->once() )->method( 'createOrderBase' ) |
|
69 | - ->will( $this->returnValue( $this->getOrderBaseItem( $item->getOrderBaseId() ) ) ); |
|
68 | + $object->expects($this->once())->method('createOrderBase') |
|
69 | + ->will($this->returnValue($this->getOrderBaseItem($item->getOrderBaseId()))); |
|
70 | 70 | |
71 | - $object->expects( $this->once() )->method( 'createOrderInvoice' ) |
|
72 | - ->will( $this->returnValue( $this->getOrderItem() ) ); |
|
71 | + $object->expects($this->once())->method('createOrderInvoice') |
|
72 | + ->will($this->returnValue($this->getOrderItem())); |
|
73 | 73 | |
74 | - $object->expects( $this->once() )->method( 'createPayment' ); |
|
74 | + $object->expects($this->once())->method('createPayment'); |
|
75 | 75 | |
76 | - $managerStub->expects( $this->once() )->method( 'searchItems' ) |
|
77 | - ->will( $this->returnValue( [$item] ) ); |
|
76 | + $managerStub->expects($this->once())->method('searchItems') |
|
77 | + ->will($this->returnValue([$item])); |
|
78 | 78 | |
79 | - $managerStub->expects( $this->once() )->method( 'saveItem' ); |
|
79 | + $managerStub->expects($this->once())->method('saveItem'); |
|
80 | 80 | |
81 | 81 | $object->run(); |
82 | 82 | } |
@@ -84,19 +84,19 @@ discard block |
||
84 | 84 | |
85 | 85 | public function testRunException() |
86 | 86 | { |
87 | - $this->context->getConfig()->set( 'controller/common/subscription/process/processors', ['cgroup'] ); |
|
87 | + $this->context->getConfig()->set('controller/common/subscription/process/processors', ['cgroup']); |
|
88 | 88 | |
89 | - $managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Subscription\\Manager\\Standard' ) |
|
90 | - ->setConstructorArgs( [$this->context] ) |
|
91 | - ->setMethods( ['searchItems', 'saveItem'] ) |
|
89 | + $managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Subscription\\Manager\\Standard') |
|
90 | + ->setConstructorArgs([$this->context]) |
|
91 | + ->setMethods(['searchItems', 'saveItem']) |
|
92 | 92 | ->getMock(); |
93 | 93 | |
94 | - \Aimeos\MShop::inject( $this->context, 'subscription', $managerStub ); |
|
94 | + \Aimeos\MShop::inject($this->context, 'subscription', $managerStub); |
|
95 | 95 | |
96 | - $managerStub->expects( $this->once() )->method( 'searchItems' ) |
|
97 | - ->will( $this->returnValue( [$managerStub->createItem()] ) ); |
|
96 | + $managerStub->expects($this->once())->method('searchItems') |
|
97 | + ->will($this->returnValue([$managerStub->createItem()])); |
|
98 | 98 | |
99 | - $managerStub->expects( $this->never() )->method( 'saveItem' ); |
|
99 | + $managerStub->expects($this->never())->method('saveItem'); |
|
100 | 100 | |
101 | 101 | $this->object->run(); |
102 | 102 | } |
@@ -104,79 +104,79 @@ discard block |
||
104 | 104 | |
105 | 105 | public function testAddBasketAddresses() |
106 | 106 | { |
107 | - $basket = \Aimeos\MShop::create( $this->context, 'order/base' )->createItem(); |
|
108 | - $address = \Aimeos\MShop::create( $this->context, 'order/base/address' )->createItem(); |
|
107 | + $basket = \Aimeos\MShop::create($this->context, 'order/base')->createItem(); |
|
108 | + $address = \Aimeos\MShop::create($this->context, 'order/base/address')->createItem(); |
|
109 | 109 | |
110 | 110 | $addresses = ['payment' => $address]; |
111 | - $basket = $this->access( 'addBasketAddresses' )->invokeArgs( $this->object, [$this->context, $basket, $addresses] ); |
|
111 | + $basket = $this->access('addBasketAddresses')->invokeArgs($this->object, [$this->context, $basket, $addresses]); |
|
112 | 112 | |
113 | - $this->assertEquals( 1, count( $basket->getAddresses() ) ); |
|
114 | - $this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Address\Iface::class, $basket->getAddress( 'payment' ) ); |
|
113 | + $this->assertEquals(1, count($basket->getAddresses())); |
|
114 | + $this->assertInstanceOf(\Aimeos\MShop\Order\Item\Base\Address\Iface::class, $basket->getAddress('payment')); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | |
118 | 118 | public function testAddBasketCoupons() |
119 | 119 | { |
120 | - $this->context->getConfig()->set( 'controller/jobs/subcription/process/renew/standard/use-coupons', true ); |
|
120 | + $this->context->getConfig()->set('controller/jobs/subcription/process/renew/standard/use-coupons', true); |
|
121 | 121 | |
122 | - $basket = \Aimeos\MShop::create( $this->context, 'order/base' )->createItem(); |
|
123 | - $product = \Aimeos\MShop::create( $this->context, 'product' )->findItem( 'CNC', ['price'] ); |
|
124 | - $orderProduct = \Aimeos\MShop::create( $this->context, 'order/base/product' )->createItem(); |
|
122 | + $basket = \Aimeos\MShop::create($this->context, 'order/base')->createItem(); |
|
123 | + $product = \Aimeos\MShop::create($this->context, 'product')->findItem('CNC', ['price']); |
|
124 | + $orderProduct = \Aimeos\MShop::create($this->context, 'order/base/product')->createItem(); |
|
125 | 125 | |
126 | - $price = $product->getRefItems( 'price', 'default', 'default' ); |
|
127 | - $basket->addProduct( $orderProduct->copyFrom( $product )->setPrice( reset( $price ) ) ); |
|
126 | + $price = $product->getRefItems('price', 'default', 'default'); |
|
127 | + $basket->addProduct($orderProduct->copyFrom($product)->setPrice(reset($price))); |
|
128 | 128 | |
129 | - $this->assertEquals( '600.00', $basket->getPrice()->getValue() ); |
|
130 | - $this->assertEquals( '30.00', $basket->getPrice()->getCosts() ); |
|
131 | - $this->assertEquals( '0.00', $basket->getPrice()->getRebate() ); |
|
129 | + $this->assertEquals('600.00', $basket->getPrice()->getValue()); |
|
130 | + $this->assertEquals('30.00', $basket->getPrice()->getCosts()); |
|
131 | + $this->assertEquals('0.00', $basket->getPrice()->getRebate()); |
|
132 | 132 | |
133 | - $basket = $this->access( 'addBasketCoupons' )->invokeArgs( $this->object, [$this->context, $basket, ['90AB']] ); |
|
133 | + $basket = $this->access('addBasketCoupons')->invokeArgs($this->object, [$this->context, $basket, ['90AB']]); |
|
134 | 134 | |
135 | - $this->assertEquals( 1, count( $basket->getCoupons() ) ); |
|
136 | - $this->assertEquals( 2, count( $basket->getProducts() ) ); |
|
137 | - $this->assertEquals( '537.00', $basket->getPrice()->getValue() ); |
|
138 | - $this->assertEquals( '30.00', $basket->getPrice()->getCosts() ); |
|
139 | - $this->assertEquals( '63.00', $basket->getPrice()->getRebate() ); |
|
135 | + $this->assertEquals(1, count($basket->getCoupons())); |
|
136 | + $this->assertEquals(2, count($basket->getProducts())); |
|
137 | + $this->assertEquals('537.00', $basket->getPrice()->getValue()); |
|
138 | + $this->assertEquals('30.00', $basket->getPrice()->getCosts()); |
|
139 | + $this->assertEquals('63.00', $basket->getPrice()->getRebate()); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | |
143 | 143 | public function testAddBasketProducts() |
144 | 144 | { |
145 | - $basket = \Aimeos\MShop::create( $this->context, 'order/base' )->createItem(); |
|
146 | - $product = \Aimeos\MShop::create( $this->context, 'product' )->findItem( 'CNC' ); |
|
147 | - $manager = \Aimeos\MShop::create( $this->context, 'order/base/product' ); |
|
145 | + $basket = \Aimeos\MShop::create($this->context, 'order/base')->createItem(); |
|
146 | + $product = \Aimeos\MShop::create($this->context, 'product')->findItem('CNC'); |
|
147 | + $manager = \Aimeos\MShop::create($this->context, 'order/base/product'); |
|
148 | 148 | |
149 | 149 | $orderProducts = [ |
150 | - $manager->createItem()->copyFrom( $product )->setId( 1 ), |
|
151 | - $manager->createItem()->copyFrom( $product )->setId( 2 ), |
|
150 | + $manager->createItem()->copyFrom($product)->setId(1), |
|
151 | + $manager->createItem()->copyFrom($product)->setId(2), |
|
152 | 152 | ]; |
153 | 153 | |
154 | - $basket = $this->access( 'addBasketProducts' )->invokeArgs( $this->object, [$this->context, $basket, $orderProducts, 1] ); |
|
154 | + $basket = $this->access('addBasketProducts')->invokeArgs($this->object, [$this->context, $basket, $orderProducts, 1]); |
|
155 | 155 | |
156 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
157 | - $this->assertNull( $basket->getProduct( 0 )->getId() ); |
|
156 | + $this->assertEquals(1, count($basket->getProducts())); |
|
157 | + $this->assertNull($basket->getProduct(0)->getId()); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | |
161 | 161 | public function testAddBasketServices() |
162 | 162 | { |
163 | - $basket = \Aimeos\MShop::create( $this->context, 'order/base' )->createItem(); |
|
164 | - $manager = \Aimeos\MShop::create( $this->context, 'order/base/service' ); |
|
163 | + $basket = \Aimeos\MShop::create($this->context, 'order/base')->createItem(); |
|
164 | + $manager = \Aimeos\MShop::create($this->context, 'order/base/service'); |
|
165 | 165 | |
166 | 166 | $orderServices = [ |
167 | - 'delivery' => [$manager->createItem()->setCode( 'shiptest' )], |
|
168 | - 'payment' => [$manager->createItem()->setCode( 'paytest' )], |
|
167 | + 'delivery' => [$manager->createItem()->setCode('shiptest')], |
|
168 | + 'payment' => [$manager->createItem()->setCode('paytest')], |
|
169 | 169 | ]; |
170 | 170 | |
171 | - $basket = $this->access( 'addBasketServices' )->invokeArgs( $this->object, [$this->context, $basket, $orderServices] ); |
|
171 | + $basket = $this->access('addBasketServices')->invokeArgs($this->object, [$this->context, $basket, $orderServices]); |
|
172 | 172 | |
173 | 173 | $class = \Aimeos\MShop\Order\Item\Base\Service\Iface::class; |
174 | 174 | |
175 | - $this->assertEquals( 2, count( $basket->getServices() ) ); |
|
176 | - $this->assertEquals( 1, count( $basket->getService( 'delivery' ) ) ); |
|
177 | - $this->assertInstanceOf( $class, $basket->getService( 'delivery', 'unitcode' ) ); |
|
178 | - $this->assertEquals( 1, count( $basket->getService( 'payment' ) ) ); |
|
179 | - $this->assertInstanceOf( $class, $basket->getService( 'payment', 'paytest' ) ); |
|
175 | + $this->assertEquals(2, count($basket->getServices())); |
|
176 | + $this->assertEquals(1, count($basket->getService('delivery'))); |
|
177 | + $this->assertInstanceOf($class, $basket->getService('delivery', 'unitcode')); |
|
178 | + $this->assertEquals(1, count($basket->getService('payment'))); |
|
179 | + $this->assertInstanceOf($class, $basket->getService('payment', 'paytest')); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | |
@@ -184,34 +184,34 @@ discard block |
||
184 | 184 | { |
185 | 185 | $item = $this->getSubscription(); |
186 | 186 | |
187 | - $managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Order\\Manager\\Base\\Standard' ) |
|
188 | - ->setConstructorArgs( [$this->context] ) |
|
189 | - ->setMethods( ['store'] ) |
|
187 | + $managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Base\\Standard') |
|
188 | + ->setConstructorArgs([$this->context]) |
|
189 | + ->setMethods(['store']) |
|
190 | 190 | ->getMock(); |
191 | 191 | |
192 | - \Aimeos\MShop::inject( $this->context, 'order/base', $managerStub ); |
|
192 | + \Aimeos\MShop::inject($this->context, 'order/base', $managerStub); |
|
193 | 193 | |
194 | - $managerStub->expects( $this->once() )->method( 'store' ); |
|
194 | + $managerStub->expects($this->once())->method('store'); |
|
195 | 195 | |
196 | - $this->access( 'createOrderBase' )->invokeArgs( $this->object, [$this->context, $item] ); |
|
196 | + $this->access('createOrderBase')->invokeArgs($this->object, [$this->context, $item]); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | |
200 | 200 | public function testCreateOrderInvoice() |
201 | 201 | { |
202 | 202 | $item = $this->getSubscription(); |
203 | - $baseItem = $this->getOrderBaseItem( $item->getOrderBaseId() ); |
|
203 | + $baseItem = $this->getOrderBaseItem($item->getOrderBaseId()); |
|
204 | 204 | |
205 | - $managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Order\\Manager\\Standard' ) |
|
206 | - ->setConstructorArgs( [$this->context] ) |
|
207 | - ->setMethods( ['saveItem'] ) |
|
205 | + $managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Standard') |
|
206 | + ->setConstructorArgs([$this->context]) |
|
207 | + ->setMethods(['saveItem']) |
|
208 | 208 | ->getMock(); |
209 | 209 | |
210 | - \Aimeos\MShop::inject( $this->context, 'order', $managerStub ); |
|
210 | + \Aimeos\MShop::inject($this->context, 'order', $managerStub); |
|
211 | 211 | |
212 | - $managerStub->expects( $this->once() )->method( 'saveItem' ); |
|
212 | + $managerStub->expects($this->once())->method('saveItem'); |
|
213 | 213 | |
214 | - $this->access( 'createOrderInvoice' )->invokeArgs( $this->object, [$this->context, $baseItem] ); |
|
214 | + $this->access('createOrderInvoice')->invokeArgs($this->object, [$this->context, $baseItem]); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | |
@@ -219,55 +219,55 @@ discard block |
||
219 | 219 | { |
220 | 220 | $item = $this->getSubscription(); |
221 | 221 | $invoice = $this->getOrderItem(); |
222 | - $baseItem = $this->getOrderBaseItem( $item->getOrderBaseId() ); |
|
222 | + $baseItem = $this->getOrderBaseItem($item->getOrderBaseId()); |
|
223 | 223 | |
224 | - $managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Order\\Manager\\Standard' ) |
|
225 | - ->setConstructorArgs( [$this->context] ) |
|
226 | - ->setMethods( ['saveItem'] ) |
|
224 | + $managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Standard') |
|
225 | + ->setConstructorArgs([$this->context]) |
|
226 | + ->setMethods(['saveItem']) |
|
227 | 227 | ->getMock(); |
228 | 228 | |
229 | - \Aimeos\MShop::inject( $this->context, 'order', $managerStub ); |
|
229 | + \Aimeos\MShop::inject($this->context, 'order', $managerStub); |
|
230 | 230 | |
231 | - $managerStub->expects( $this->once() )->method( 'saveItem' ); |
|
231 | + $managerStub->expects($this->once())->method('saveItem'); |
|
232 | 232 | |
233 | - $this->access( 'createPayment' )->invokeArgs( $this->object, [$this->context, $baseItem, $invoice] ); |
|
233 | + $this->access('createPayment')->invokeArgs($this->object, [$this->context, $baseItem, $invoice]); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | |
237 | 237 | protected function getOrderItem() |
238 | 238 | { |
239 | - return \Aimeos\MShop::create( $this->context, 'order' )->createItem(); |
|
239 | + return \Aimeos\MShop::create($this->context, 'order')->createItem(); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | |
243 | - protected function getOrderBaseItem( $baseId ) |
|
243 | + protected function getOrderBaseItem($baseId) |
|
244 | 244 | { |
245 | - return \Aimeos\MShop::create( $this->context, 'order/base' )->getItem( $baseId, ['order/base/service'] ); |
|
245 | + return \Aimeos\MShop::create($this->context, 'order/base')->getItem($baseId, ['order/base/service']); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | |
249 | 249 | protected function getSubscription() |
250 | 250 | { |
251 | - $manager = \Aimeos\MShop::create( $this->context, 'subscription' ); |
|
251 | + $manager = \Aimeos\MShop::create($this->context, 'subscription'); |
|
252 | 252 | |
253 | 253 | $search = $manager->createSearch(); |
254 | - $search->setConditions( $search->compare( '==', 'subscription.dateend', '2010-01-01' ) ); |
|
254 | + $search->setConditions($search->compare('==', 'subscription.dateend', '2010-01-01')); |
|
255 | 255 | |
256 | - $items = $manager->searchItems( $search ); |
|
256 | + $items = $manager->searchItems($search); |
|
257 | 257 | |
258 | - if( ( $item = reset( $items ) ) !== false ) { |
|
258 | + if (($item = reset($items)) !== false) { |
|
259 | 259 | return $item; |
260 | 260 | } |
261 | 261 | |
262 | - throw new \Exception( 'No subscription item found' ); |
|
262 | + throw new \Exception('No subscription item found'); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | |
266 | - protected function access( $name ) |
|
266 | + protected function access($name) |
|
267 | 267 | { |
268 | - $class = new \ReflectionClass( \Aimeos\Controller\Jobs\Subscription\Process\Renew\Standard::class ); |
|
269 | - $method = $class->getMethod( $name ); |
|
270 | - $method->setAccessible( true ); |
|
268 | + $class = new \ReflectionClass(\Aimeos\Controller\Jobs\Subscription\Process\Renew\Standard::class); |
|
269 | + $method = $class->getMethod($name); |
|
270 | + $method->setAccessible(true); |
|
271 | 271 | |
272 | 272 | return $method; |
273 | 273 | } |
@@ -20,49 +20,49 @@ discard block |
||
20 | 20 | $aimeos = \TestHelperJobs::getAimeos(); |
21 | 21 | $this->context = \TestHelperJobs::getContext(); |
22 | 22 | |
23 | - $this->object = new \Aimeos\Controller\Jobs\Subscription\Process\Begin\Standard( $this->context, $aimeos ); |
|
23 | + $this->object = new \Aimeos\Controller\Jobs\Subscription\Process\Begin\Standard($this->context, $aimeos); |
|
24 | 24 | |
25 | - \Aimeos\MShop::cache( true ); |
|
25 | + \Aimeos\MShop::cache(true); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
29 | 29 | protected function tearDown() |
30 | 30 | { |
31 | - \Aimeos\MShop::cache( false ); |
|
31 | + \Aimeos\MShop::cache(false); |
|
32 | 32 | \Aimeos\MShop::clear(); |
33 | 33 | |
34 | - unset( $this->object, $this->context ); |
|
34 | + unset($this->object, $this->context); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
38 | 38 | public function testGetName() |
39 | 39 | { |
40 | - $this->assertEquals( 'Subscription process start', $this->object->getName() ); |
|
40 | + $this->assertEquals('Subscription process start', $this->object->getName()); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
44 | 44 | public function testGetDescription() |
45 | 45 | { |
46 | - $this->assertEquals( 'Process subscriptions initially', $this->object->getDescription() ); |
|
46 | + $this->assertEquals('Process subscriptions initially', $this->object->getDescription()); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
50 | 50 | public function testRun() |
51 | 51 | { |
52 | - $this->context->getConfig()->set( 'controller/common/subscription/process/processors', ['cgroup'] ); |
|
52 | + $this->context->getConfig()->set('controller/common/subscription/process/processors', ['cgroup']); |
|
53 | 53 | $item = $this->getSubscription(); |
54 | 54 | |
55 | - $managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Subscription\\Manager\\Standard' ) |
|
56 | - ->setConstructorArgs( [$this->context] ) |
|
57 | - ->setMethods( ['searchItems', 'saveItem'] ) |
|
55 | + $managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Subscription\\Manager\\Standard') |
|
56 | + ->setConstructorArgs([$this->context]) |
|
57 | + ->setMethods(['searchItems', 'saveItem']) |
|
58 | 58 | ->getMock(); |
59 | 59 | |
60 | - \Aimeos\MShop::inject( $this->context, 'subscription', $managerStub ); |
|
60 | + \Aimeos\MShop::inject($this->context, 'subscription', $managerStub); |
|
61 | 61 | |
62 | - $managerStub->expects( $this->once() )->method( 'searchItems' ) |
|
63 | - ->will( $this->returnValue( [$item] ) ); |
|
62 | + $managerStub->expects($this->once())->method('searchItems') |
|
63 | + ->will($this->returnValue([$item])); |
|
64 | 64 | |
65 | - $managerStub->expects( $this->once() )->method( 'saveItem' ); |
|
65 | + $managerStub->expects($this->once())->method('saveItem'); |
|
66 | 66 | |
67 | 67 | $this->object->run(); |
68 | 68 | } |
@@ -70,21 +70,21 @@ discard block |
||
70 | 70 | |
71 | 71 | public function testRunException() |
72 | 72 | { |
73 | - $this->context->getConfig()->set( 'controller/common/subscription/process/processors', ['cgroup'] ); |
|
74 | - $this->context->getConfig()->set( 'controller/common/subscription/process/processor/cgroup/groupids', ['1'] ); |
|
73 | + $this->context->getConfig()->set('controller/common/subscription/process/processors', ['cgroup']); |
|
74 | + $this->context->getConfig()->set('controller/common/subscription/process/processor/cgroup/groupids', ['1']); |
|
75 | 75 | |
76 | - $managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Subscription\\Manager\\Standard' ) |
|
77 | - ->setConstructorArgs( [$this->context] ) |
|
78 | - ->setMethods( ['searchItems', 'saveItem'] ) |
|
76 | + $managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Subscription\\Manager\\Standard') |
|
77 | + ->setConstructorArgs([$this->context]) |
|
78 | + ->setMethods(['searchItems', 'saveItem']) |
|
79 | 79 | ->getMock(); |
80 | 80 | |
81 | - \Aimeos\MShop::inject( $this->context, 'subscription', $managerStub ); |
|
81 | + \Aimeos\MShop::inject($this->context, 'subscription', $managerStub); |
|
82 | 82 | |
83 | - $managerStub->expects( $this->once() )->method( 'searchItems' ) |
|
84 | - ->will( $this->returnValue( [$managerStub->createItem()] ) ); |
|
83 | + $managerStub->expects($this->once())->method('searchItems') |
|
84 | + ->will($this->returnValue([$managerStub->createItem()])); |
|
85 | 85 | |
86 | - $managerStub->expects( $this->once() )->method( 'saveItem' ) |
|
87 | - ->will( $this->throwException( new \Exception() ) ); |
|
86 | + $managerStub->expects($this->once())->method('saveItem') |
|
87 | + ->will($this->throwException(new \Exception())); |
|
88 | 88 | |
89 | 89 | $this->object->run(); |
90 | 90 | } |
@@ -92,17 +92,17 @@ discard block |
||
92 | 92 | |
93 | 93 | protected function getSubscription() |
94 | 94 | { |
95 | - $manager = \Aimeos\MShop::create( $this->context, 'subscription' ); |
|
95 | + $manager = \Aimeos\MShop::create($this->context, 'subscription'); |
|
96 | 96 | |
97 | 97 | $search = $manager->createSearch(); |
98 | - $search->setConditions( $search->compare( '==', 'subscription.dateend', '2010-01-01' ) ); |
|
98 | + $search->setConditions($search->compare('==', 'subscription.dateend', '2010-01-01')); |
|
99 | 99 | |
100 | - $items = $manager->searchItems( $search ); |
|
100 | + $items = $manager->searchItems($search); |
|
101 | 101 | |
102 | - if( ( $item = reset( $items ) ) !== false ) { |
|
102 | + if (($item = reset($items)) !== false) { |
|
103 | 103 | return $item; |
104 | 104 | } |
105 | 105 | |
106 | - throw new \Exception( 'No subscription item found' ); |
|
106 | + throw new \Exception('No subscription item found'); |
|
107 | 107 | } |
108 | 108 | } |