Completed
Push — master ( b98343...f157ac )
by Aimeos
03:37
created
admin/jqadm/src/Admin/JQAdm/Factory.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -29,29 +29,29 @@
 block discarded – undo
29 29
 	 * @return \Aimeos\Admin\JQAdm\Iface admin client implementing \Aimeos\Admin\JQAdm\Iface
30 30
 	 * @throws \Aimeos\Admin\JQAdm\Exception If requested client implementation couldn't be found or initialisation fails
31 31
 	 */
32
-	public static function createClient( \Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $type, $name = null )
32
+	public static function createClient(\Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $type, $name = null)
33 33
 	{
34
-		if( empty( $type ) ) {
35
-			throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Admin JQAdm type is empty' ) );
34
+		if (empty($type)) {
35
+			throw new \Aimeos\Admin\JQAdm\Exception(sprintf('Admin JQAdm type is empty'));
36 36
 		}
37 37
 
38
-		if( ctype_alnum( $type ) === false ) {
39
-			throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Invalid characters in client name "%1$s"', $type ) );
38
+		if (ctype_alnum($type) === false) {
39
+			throw new \Aimeos\Admin\JQAdm\Exception(sprintf('Invalid characters in client name "%1$s"', $type));
40 40
 		}
41 41
 
42
-		$factory = '\\Aimeos\\Admin\\JQAdm\\' . ucwords( $type ) . '\\Factory';
42
+		$factory = '\\Aimeos\\Admin\\JQAdm\\' . ucwords($type) . '\\Factory';
43 43
 
44
-		if( class_exists( $factory ) === false ) {
45
-			throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Class "%1$s" not available', $factory ) );
44
+		if (class_exists($factory) === false) {
45
+			throw new \Aimeos\Admin\JQAdm\Exception(sprintf('Class "%1$s" not available', $factory));
46 46
 		}
47 47
 
48
-		$client = @call_user_func_array( array( $factory, 'createClient' ), array( $context, $templatePaths, $name ) );
48
+		$client = @call_user_func_array(array($factory, 'createClient'), array($context, $templatePaths, $name));
49 49
 
50
-		if( $client === false ) {
51
-			throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Invalid factory "%1$s"', $factory ) );
50
+		if ($client === false) {
51
+			throw new \Aimeos\Admin\JQAdm\Exception(sprintf('Invalid factory "%1$s"', $factory));
52 52
 		}
53 53
 
54
-		$client->setView( $context->getView() );
54
+		$client->setView($context->getView());
55 55
 
56 56
 		return $client;
57 57
 	}
Please login to merge, or discard this patch.
admin/jqadm/tests/TestHelperJqadm.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -13,47 +13,47 @@  discard block
 block discarded – undo
13 13
 	public static function bootstrap()
14 14
 	{
15 15
 		self::getAimeos();
16
-		\Aimeos\MShop\Factory::setCache( false );
16
+		\Aimeos\MShop\Factory::setCache(false);
17 17
 	}
18 18
 
19 19
 
20
-	public static function getContext( $site = 'unittest' )
20
+	public static function getContext($site = 'unittest')
21 21
 	{
22
-		if( !isset( self::$context[$site] ) ) {
23
-			self::$context[$site] = self::createContext( $site );
22
+		if (!isset(self::$context[$site])) {
23
+			self::$context[$site] = self::createContext($site);
24 24
 		}
25 25
 
26 26
 		return clone self::$context[$site];
27 27
 	}
28 28
 
29 29
 
30
-	public static function getView( $site = 'unittest', \Aimeos\MW\Config\Iface $config = null )
30
+	public static function getView($site = 'unittest', \Aimeos\MW\Config\Iface $config = null)
31 31
 	{
32
-		if( $config === null ) {
33
-			$config = self::getContext( $site )->getConfig();
32
+		if ($config === null) {
33
+			$config = self::getContext($site)->getConfig();
34 34
 		}
35 35
 
36
-		$view = new \Aimeos\MW\View\Standard( self::getTemplatePaths() );
36
+		$view = new \Aimeos\MW\View\Standard(self::getTemplatePaths());
37 37
 
38
-		$trans = new \Aimeos\MW\Translation\None( 'de_DE' );
39
-		$helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $trans );
40
-		$view->addHelper( 'translate', $helper );
38
+		$trans = new \Aimeos\MW\Translation\None('de_DE');
39
+		$helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $trans);
40
+		$view->addHelper('translate', $helper);
41 41
 
42
-		$helper = new \Aimeos\MW\View\Helper\Url\Standard( $view, 'http://baseurl' );
43
-		$view->addHelper( 'url', $helper );
42
+		$helper = new \Aimeos\MW\View\Helper\Url\Standard($view, 'http://baseurl');
43
+		$view->addHelper('url', $helper);
44 44
 
45
-		$helper = new \Aimeos\MW\View\Helper\Number\Standard( $view, '.', '' );
46
-		$view->addHelper( 'number', $helper );
45
+		$helper = new \Aimeos\MW\View\Helper\Number\Standard($view, '.', '');
46
+		$view->addHelper('number', $helper);
47 47
 
48
-		$helper = new \Aimeos\MW\View\Helper\Date\Standard( $view, 'Y-m-d' );
49
-		$view->addHelper( 'date', $helper );
48
+		$helper = new \Aimeos\MW\View\Helper\Date\Standard($view, 'Y-m-d');
49
+		$view->addHelper('date', $helper);
50 50
 
51
-		$config = new \Aimeos\MW\Config\Decorator\Protect( $config, array( 'admin', 'client/html', 'controller/jsonadm' ) );
52
-		$helper = new \Aimeos\MW\View\Helper\Config\Standard( $view, $config );
53
-		$view->addHelper( 'config', $helper );
51
+		$config = new \Aimeos\MW\Config\Decorator\Protect($config, array('admin', 'client/html', 'controller/jsonadm'));
52
+		$helper = new \Aimeos\MW\View\Helper\Config\Standard($view, $config);
53
+		$view->addHelper('config', $helper);
54 54
 
55
-		$helper = new \Aimeos\MW\View\Helper\Csrf\Standard( $view, '_csrf_token', '_csrf_value' );
56
-		$view->addHelper( 'csrf', $helper );
55
+		$helper = new \Aimeos\MW\View\Helper\Csrf\Standard($view, '_csrf_token', '_csrf_value');
56
+		$view->addHelper('csrf', $helper);
57 57
 
58 58
 		return $view;
59 59
 	}
@@ -61,19 +61,19 @@  discard block
 block discarded – undo
61 61
 
62 62
 	public static function getTemplatePaths()
63 63
 	{
64
-		return self::getAimeos()->getCustomPaths( 'admin/jqadm/templates' );
64
+		return self::getAimeos()->getCustomPaths('admin/jqadm/templates');
65 65
 	}
66 66
 
67 67
 
68 68
 	private static function getAimeos()
69 69
 	{
70
-		if( !isset( self::$aimeos ) )
70
+		if (!isset(self::$aimeos))
71 71
 		{
72 72
 			require_once 'Bootstrap.php';
73
-			spl_autoload_register( 'Aimeos\\Bootstrap::autoload' );
73
+			spl_autoload_register('Aimeos\\Bootstrap::autoload');
74 74
 
75
-			$extdir = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
76
-			self::$aimeos = new \Aimeos\Bootstrap( array( $extdir ), false );
75
+			$extdir = dirname(dirname(dirname(dirname(__FILE__))));
76
+			self::$aimeos = new \Aimeos\Bootstrap(array($extdir), false);
77 77
 		}
78 78
 
79 79
 		return self::$aimeos;
@@ -83,53 +83,53 @@  discard block
 block discarded – undo
83 83
 	/**
84 84
 	 * @param string $site
85 85
 	 */
86
-	private static function createContext( $site )
86
+	private static function createContext($site)
87 87
 	{
88 88
 		$ctx = new \Aimeos\MShop\Context\Item\Standard();
89 89
 		$aimeos = self::getAimeos();
90 90
 
91 91
 
92
-		$paths = $aimeos->getConfigPaths( 'mysql' );
92
+		$paths = $aimeos->getConfigPaths('mysql');
93 93
 		$paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config';
94 94
 		$file = __DIR__ . DIRECTORY_SEPARATOR . 'confdoc.ser';
95
-		$local = array( 'resource' => array( 'fs' => array( 'adapter' => 'Standard', 'basedir' => __DIR__ . '/tmp' ) ) );
95
+		$local = array('resource' => array('fs' => array('adapter' => 'Standard', 'basedir' => __DIR__ . '/tmp')));
96 96
 
97
-		$conf = new \Aimeos\MW\Config\PHPArray( $local, $paths );
98
-		$conf = new \Aimeos\MW\Config\Decorator\Memory( $conf );
99
-		$conf = new \Aimeos\MW\Config\Decorator\Documentor( $conf, $file );
100
-		$ctx->setConfig( $conf );
97
+		$conf = new \Aimeos\MW\Config\PHPArray($local, $paths);
98
+		$conf = new \Aimeos\MW\Config\Decorator\Memory($conf);
99
+		$conf = new \Aimeos\MW\Config\Decorator\Documentor($conf, $file);
100
+		$ctx->setConfig($conf);
101 101
 
102 102
 
103
-		$dbm = new \Aimeos\MW\DB\Manager\PDO( $conf );
104
-		$ctx->setDatabaseManager( $dbm );
103
+		$dbm = new \Aimeos\MW\DB\Manager\PDO($conf);
104
+		$ctx->setDatabaseManager($dbm);
105 105
 
106 106
 
107
-		$fs = new \Aimeos\MW\Filesystem\Manager\Standard( $conf );
108
-		$ctx->setFilesystemManager( $fs );
107
+		$fs = new \Aimeos\MW\Filesystem\Manager\Standard($conf);
108
+		$ctx->setFilesystemManager($fs);
109 109
 
110 110
 
111
-		$logger = new \Aimeos\MW\Logger\File( $site . '.log', \Aimeos\MW\Logger\Base::DEBUG );
112
-		$ctx->setLogger( $logger );
111
+		$logger = new \Aimeos\MW\Logger\File($site . '.log', \Aimeos\MW\Logger\Base::DEBUG);
112
+		$ctx->setLogger($logger);
113 113
 
114 114
 
115 115
 		$cache = new \Aimeos\MW\Cache\None();
116
-		$ctx->setCache( $cache );
116
+		$ctx->setCache($cache);
117 117
 
118 118
 
119
-		$i18n = new \Aimeos\MW\Translation\None( 'de' );
120
-		$ctx->setI18n( array( 'de' => $i18n ) );
119
+		$i18n = new \Aimeos\MW\Translation\None('de');
120
+		$ctx->setI18n(array('de' => $i18n));
121 121
 
122 122
 
123 123
 		$session = new \Aimeos\MW\Session\None();
124
-		$ctx->setSession( $session );
124
+		$ctx->setSession($session);
125 125
 
126 126
 
127
-		$localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $ctx );
128
-		$locale = $localeManager->bootstrap( $site, '', '', false );
129
-		$ctx->setLocale( $locale );
127
+		$localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($ctx);
128
+		$locale = $localeManager->bootstrap($site, '', '', false);
129
+		$ctx->setLocale($locale);
130 130
 
131 131
 
132
-		$ctx->setEditor( 'core:admin/jqadm' );
132
+		$ctx->setEditor('core:admin/jqadm');
133 133
 
134 134
 		return $ctx;
135 135
 	}
Please login to merge, or discard this patch.
admin/jqadm/src/Admin/JQAdm/Product/Download/Standard.php 2 patches
Spacing   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -67,17 +67,17 @@  discard block
 block discarded – undo
67 67
 	{
68 68
 		$view = $this->getView();
69 69
 
70
-		$this->setData( $view );
70
+		$this->setData($view);
71 71
 		$view->downloadBody = '';
72 72
 
73
-		foreach( $this->getSubClients() as $client ) {
73
+		foreach ($this->getSubClients() as $client) {
74 74
 			$view->downloadBody .= $client->copy();
75 75
 		}
76 76
 
77 77
 		$tplconf = 'admin/jqadm/product/download/template-item';
78 78
 		$default = 'product/item-download-default.php';
79 79
 
80
-		return $view->render( $view->config( $tplconf, $default ) );
80
+		return $view->render($view->config($tplconf, $default));
81 81
 	}
82 82
 
83 83
 
@@ -90,17 +90,17 @@  discard block
 block discarded – undo
90 90
 	{
91 91
 		$view = $this->getView();
92 92
 
93
-		$this->setData( $view );
93
+		$this->setData($view);
94 94
 		$view->downloadBody = '';
95 95
 
96
-		foreach( $this->getSubClients() as $client ) {
96
+		foreach ($this->getSubClients() as $client) {
97 97
 			$view->downloadBody .= $client->create();
98 98
 		}
99 99
 
100 100
 		$tplconf = 'admin/jqadm/product/download/template-item';
101 101
 		$default = 'product/item-download-default.php';
102 102
 
103
-		return $view->render( $view->config( $tplconf, $default ) );
103
+		return $view->render($view->config($tplconf, $default));
104 104
 	}
105 105
 
106 106
 
@@ -112,35 +112,35 @@  discard block
 block discarded – undo
112 112
 	public function delete()
113 113
 	{
114 114
 		$view = $this->getView();
115
-		$listManager = \Aimeos\MShop\Factory::createManager( $context = $this->getContext(), 'product/lists' );
115
+		$listManager = \Aimeos\MShop\Factory::createManager($context = $this->getContext(), 'product/lists');
116 116
 		$search = $listManager->createSearch();
117 117
 
118
-		foreach( (array) $view->param( 'id' ) as $id )
118
+		foreach ((array) $view->param('id') as $id)
119 119
 		{
120
-			$listItems = $this->getListItems( $id );
121
-			$items = $this->getAttributeItems( $listItems );
120
+			$listItems = $this->getListItems($id);
121
+			$items = $this->getAttributeItems($listItems);
122 122
 
123
-			foreach( $listItems as $listid => $listItem )
123
+			foreach ($listItems as $listid => $listItem)
124 124
 			{
125 125
 				$refId = $listItem->getRefId();
126 126
 
127 127
 				$expr = array(
128
-					$search->compare( '==', 'product.lists.refid', $refId ),
129
-					$search->compare( '==', 'product.lists.domain', 'attribute' ),
130
-					$search->compare( '==', 'product.lists.type.code', 'hidden' ),
131
-					$search->compare( '==', 'product.lists.type.domain', 'attribute' ),
128
+					$search->compare('==', 'product.lists.refid', $refId),
129
+					$search->compare('==', 'product.lists.domain', 'attribute'),
130
+					$search->compare('==', 'product.lists.type.code', 'hidden'),
131
+					$search->compare('==', 'product.lists.type.domain', 'attribute'),
132 132
 				);
133
-				$search->setConditions( $search->combine( '&&', $expr ) );
134
-				$result = $listManager->aggregate( $search, 'product.lists.refid' );
133
+				$search->setConditions($search->combine('&&', $expr));
134
+				$result = $listManager->aggregate($search, 'product.lists.refid');
135 135
 
136
-				if( isset( $items[$refId] ) && $result[$refId] == 1 ) {
137
-					$listItem->setRefItem( $items[$refId] );
136
+				if (isset($items[$refId]) && $result[$refId] == 1) {
137
+					$listItem->setRefItem($items[$refId]);
138 138
 				} else {
139
-					unset( $listItems[$id] );
139
+					unset($listItems[$id]);
140 140
 				}
141 141
 			}
142 142
 
143
-			$this->cleanupItems( $listItems, array() );
143
+			$this->cleanupItems($listItems, array());
144 144
 		}
145 145
 	}
146 146
 
@@ -154,17 +154,17 @@  discard block
 block discarded – undo
154 154
 	{
155 155
 		$view = $this->getView();
156 156
 
157
-		$this->setData( $view );
157
+		$this->setData($view);
158 158
 		$view->downloadBody = '';
159 159
 
160
-		foreach( $this->getSubClients() as $client ) {
160
+		foreach ($this->getSubClients() as $client) {
161 161
 			$view->downloadBody .= $client->get();
162 162
 		}
163 163
 
164 164
 		$tplconf = 'admin/jqadm/product/download/template-item';
165 165
 		$default = 'product/item-download-default.php';
166 166
 
167
-		return $view->render( $view->config( $tplconf, $default ) );
167
+		return $view->render($view->config($tplconf, $default));
168 168
 	}
169 169
 
170 170
 
@@ -178,18 +178,18 @@  discard block
 block discarded – undo
178 178
 		$view = $this->getView();
179 179
 		$context = $this->getContext();
180 180
 
181
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' );
182
-		$attrManager = \Aimeos\MShop\Factory::createManager( $context, 'attribute' );
181
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'product/lists');
182
+		$attrManager = \Aimeos\MShop\Factory::createManager($context, 'attribute');
183 183
 
184 184
 		$manager->begin();
185 185
 		$attrManager->begin();
186 186
 
187 187
 		try
188 188
 		{
189
-			$this->updateItems( $view );
189
+			$this->updateItems($view);
190 190
 			$view->downloadBody = '';
191 191
 
192
-			foreach( $this->getSubClients() as $client ) {
192
+			foreach ($this->getSubClients() as $client) {
193 193
 				$view->downloadBody .= $client->save();
194 194
 			}
195 195
 
@@ -197,19 +197,19 @@  discard block
 block discarded – undo
197 197
 			$manager->commit();
198 198
 			return;
199 199
 		}
200
-		catch( \Aimeos\MShop\Exception $e )
200
+		catch (\Aimeos\MShop\Exception $e)
201 201
 		{
202
-			$error = array( 'product-item-download' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) );
203
-			$view->errors = $view->get( 'errors', array() ) + $error;
202
+			$error = array('product-item-download' => $context->getI18n()->dt('mshop', $e->getMessage()));
203
+			$view->errors = $view->get('errors', array()) + $error;
204 204
 
205 205
 			$attrManager->rollback();
206 206
 			$manager->rollback();
207 207
 		}
208
-		catch( \Exception $e )
208
+		catch (\Exception $e)
209 209
 		{
210
-			$context->getLogger()->log( $e->getMessage() . ' - ' . $e->getTraceAsString() );
211
-			$error = array( 'product-item-download' => $e->getMessage() );
212
-			$view->errors = $view->get( 'errors', array() ) + $error;
210
+			$context->getLogger()->log($e->getMessage() . ' - ' . $e->getTraceAsString());
211
+			$error = array('product-item-download' => $e->getMessage());
212
+			$view->errors = $view->get('errors', array()) + $error;
213 213
 
214 214
 			$attrManager->rollback();
215 215
 			$manager->rollback();
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 	 * @param string|null $name Name of the sub-client (Default if null)
227 227
 	 * @return \Aimeos\Admin\JQAdm\Iface Sub-client object
228 228
 	 */
229
-	public function getSubClient( $type, $name = null )
229
+	public function getSubClient($type, $name = null)
230 230
 	{
231 231
 		/** admin/jqadm/product/download/decorators/excludes
232 232
 		 * Excludes decorators added by the "common" option from the product JQAdm client
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 		 * @see admin/jqadm/product/download/decorators/excludes
302 302
 		 * @see admin/jqadm/product/download/decorators/global
303 303
 		 */
304
-		return $this->createSubClient( 'product/download/' . $type, $name );
304
+		return $this->createSubClient('product/download/' . $type, $name);
305 305
 	}
306 306
 
307 307
 
@@ -311,29 +311,29 @@  discard block
 block discarded – undo
311 311
 	 * @param array $listItems List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface
312 312
 	 * @param array $listIds List of IDs of the still used list items
313 313
 	 */
314
-	protected function cleanupItems( array $listItems, array $listIds )
314
+	protected function cleanupItems(array $listItems, array $listIds)
315 315
 	{
316 316
 		$context = $this->getContext();
317
-		$fs = $context->getFilesystemManager()->get( 'fs-secure' );
318
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'attribute' );
319
-		$listManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' );
317
+		$fs = $context->getFilesystemManager()->get('fs-secure');
318
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'attribute');
319
+		$listManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists');
320 320
 
321 321
 		$rmItems = array();
322
-		$rmListIds = array_diff( array_keys( $listItems ), $listIds );
322
+		$rmListIds = array_diff(array_keys($listItems), $listIds);
323 323
 
324
-		foreach( $rmListIds as $rmListId )
324
+		foreach ($rmListIds as $rmListId)
325 325
 		{
326
-			if( ( $item = $listItems[$rmListId]->getRefItem() ) !== null )
326
+			if (($item = $listItems[$rmListId]->getRefItem()) !== null)
327 327
 			{
328
-				if( $item->getCode() != '' && $fs->has( $item->getCode() ) ) {
329
-					$fs->rm( $item->getCode() );
328
+				if ($item->getCode() != '' && $fs->has($item->getCode())) {
329
+					$fs->rm($item->getCode());
330 330
 				}
331 331
 				$rmItems[] = $item->getId();
332 332
 			}
333 333
 		}
334 334
 
335
-		$listManager->deleteItems( $rmListIds  );
336
-		$manager->deleteItems( $rmItems  );
335
+		$listManager->deleteItems($rmListIds);
336
+		$manager->deleteItems($rmItems);
337 337
 	}
338 338
 
339 339
 
@@ -345,13 +345,13 @@  discard block
 block discarded – undo
345 345
 	protected function createItem()
346 346
 	{
347 347
 		$context = $this->getContext();
348
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'attribute' );
349
-		$typeManager = \Aimeos\MShop\Factory::createManager( $context, 'attribute/type' );
348
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'attribute');
349
+		$typeManager = \Aimeos\MShop\Factory::createManager($context, 'attribute/type');
350 350
 
351 351
 		$item = $manager->createItem();
352
-		$item->setTypeId( $typeManager->findItem( 'download', array(), 'product' )->getId() );
353
-		$item->setDomain( 'product' );
354
-		$item->setStatus( 1 );
352
+		$item->setTypeId($typeManager->findItem('download', array(), 'product')->getId());
353
+		$item->setDomain('product');
354
+		$item->setStatus(1);
355 355
 
356 356
 		return $item;
357 357
 	}
@@ -363,17 +363,17 @@  discard block
 block discarded – undo
363 363
 	 * @param string $id Parent ID for the new list item
364 364
 	 * @return \Aimeos\MShop\Common\Item\Lists\Iface New list item object
365 365
 	 */
366
-	protected function createListItem( $id )
366
+	protected function createListItem($id)
367 367
 	{
368 368
 		$context = $this->getContext();
369
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' );
370
-		$typeManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists/type' );
369
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'product/lists');
370
+		$typeManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists/type');
371 371
 
372 372
 		$item = $manager->createItem();
373
-		$item->setTypeId( $typeManager->findItem( 'hidden', array(), 'attribute' )->getId() );
374
-		$item->setDomain( 'attribute' );
375
-		$item->setParentId( $id );
376
-		$item->setStatus( 1 );
373
+		$item->setTypeId($typeManager->findItem('hidden', array(), 'attribute')->getId());
374
+		$item->setDomain('attribute');
375
+		$item->setParentId($id);
376
+		$item->setStatus(1);
377 377
 
378 378
 		return $item;
379 379
 	}
@@ -385,27 +385,27 @@  discard block
 block discarded – undo
385 385
 	 * @param array $listItems List of list items with IDs as key and items implementing \Aimeos\MShop\Common\Item\List\Iface as values
386 386
 	 * @return array List of attribute items with ID as key and items implementing \Aimeos\MShop\Attribute\Item\Iface as values
387 387
 	 */
388
-	protected function getAttributeItems( array $listItems )
388
+	protected function getAttributeItems(array $listItems)
389 389
 	{
390 390
 		$refIds = array();
391 391
 
392
-		foreach( $listItems as $item ) {
392
+		foreach ($listItems as $item) {
393 393
 			$refIds[] = $item->getRefId();
394 394
 		}
395 395
 
396
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' );
396
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute');
397 397
 
398 398
 		$search = $manager->createSearch();
399 399
 		$expr = array(
400
-			$search->compare( '==', 'attribute.id', $refIds ),
401
-			$search->compare( '==', 'attribute.domain', 'product' ),
402
-			$search->compare( '==', 'attribute.type.domain', 'product' ),
403
-			$search->compare( '==', 'attribute.type.code', 'download' ),
400
+			$search->compare('==', 'attribute.id', $refIds),
401
+			$search->compare('==', 'attribute.domain', 'product'),
402
+			$search->compare('==', 'attribute.type.domain', 'product'),
403
+			$search->compare('==', 'attribute.type.code', 'download'),
404 404
 		);
405
-		$search->setConditions( $search->combine( '&&', $expr ) );
406
-		$search->setSlice( 0, 0x7fffffff );
405
+		$search->setConditions($search->combine('&&', $expr));
406
+		$search->setSlice(0, 0x7fffffff);
407 407
 
408
-		return $manager->searchItems( $search );
408
+		return $manager->searchItems($search);
409 409
 	}
410 410
 
411 411
 
@@ -415,20 +415,20 @@  discard block
 block discarded – undo
415 415
 	 * @param string $prodid Unique product ID
416 416
 	 * @return array Associative list of bundle product IDs as keys and list items as values
417 417
 	 */
418
-	protected function getListItems( $prodid )
418
+	protected function getListItems($prodid)
419 419
 	{
420
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists' );
420
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists');
421 421
 
422 422
 		$search = $manager->createSearch();
423 423
 		$expr = array(
424
-			$search->compare( '==', 'product.lists.parentid', $prodid ),
425
-			$search->compare( '==', 'product.lists.domain', 'attribute' ),
426
-			$search->compare( '==', 'product.lists.type.domain', 'attribute' ),
427
-			$search->compare( '==', 'product.lists.type.code', 'hidden' ),
424
+			$search->compare('==', 'product.lists.parentid', $prodid),
425
+			$search->compare('==', 'product.lists.domain', 'attribute'),
426
+			$search->compare('==', 'product.lists.type.domain', 'attribute'),
427
+			$search->compare('==', 'product.lists.type.code', 'hidden'),
428 428
 		);
429
-		$search->setConditions( $search->combine( '&&', $expr ) );
429
+		$search->setConditions($search->combine('&&', $expr));
430 430
 
431
-		return $manager->searchItems( $search );
431
+		return $manager->searchItems($search);
432 432
 	}
433 433
 
434 434
 
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 	 */
440 440
 	protected function getSubClientNames()
441 441
 	{
442
-		return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames );
442
+		return $this->getContext()->getConfig()->get($this->subPartPath, $this->subPartNames);
443 443
 	}
444 444
 
445 445
 
@@ -448,29 +448,29 @@  discard block
 block discarded – undo
448 448
 	 *
449 449
 	 * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters
450 450
 	 */
451
-	protected function setData( \Aimeos\MW\View\Iface $view )
451
+	protected function setData(\Aimeos\MW\View\Iface $view)
452 452
 	{
453
-		$view->downloadData = (array) $view->param( 'download', array() );
453
+		$view->downloadData = (array) $view->param('download', array());
454 454
 
455
-		if( !empty( $view->downloadData ) ) {
455
+		if (!empty($view->downloadData)) {
456 456
 			return;
457 457
 		}
458 458
 
459 459
 		$data = array();
460
-		$listItems = $this->getListItems( $view->item->getId() );
461
-		$attrItems = $this->getAttributeItems( $listItems );
460
+		$listItems = $this->getListItems($view->item->getId());
461
+		$attrItems = $this->getAttributeItems($listItems);
462 462
 
463
-		foreach( $listItems as $listItem )
463
+		foreach ($listItems as $listItem)
464 464
 		{
465
-			if( !isset( $attrItems[$listItem->getRefId()] ) ) {
465
+			if (!isset($attrItems[$listItem->getRefId()])) {
466 466
 				continue;
467 467
 			}
468 468
 
469
-			foreach( $listItem->toArray() as $key => $value ) {
469
+			foreach ($listItem->toArray() as $key => $value) {
470 470
 				$data[$key] = $value;
471 471
 			}
472 472
 
473
-			foreach( $attrItems[$listItem->getRefId()]->toArray() as $key => $value ) {
473
+			foreach ($attrItems[$listItem->getRefId()]->toArray() as $key => $value) {
474 474
 				$data[$key] = $value;
475 475
 			}
476 476
 
@@ -478,12 +478,12 @@  discard block
 block discarded – undo
478 478
 
479 479
 			try
480 480
 			{
481
-				$fs = $this->getContext()->getFilesystemManager()->get( 'fs-secure' );
481
+				$fs = $this->getContext()->getFilesystemManager()->get('fs-secure');
482 482
 
483
-				$data['time'] = $fs->time( $data['path'] );
484
-				$data['size'] = $fs->size( $data['path'] );
483
+				$data['time'] = $fs->time($data['path']);
484
+				$data['size'] = $fs->size($data['path']);
485 485
 			}
486
-			catch( \Exception $e ) { ; } // Show product even if file isn't available any more
486
+			catch (\Exception $e) {; } // Show product even if file isn't available any more
487 487
 		}
488 488
 
489 489
 		$view->downloadData = $data;
@@ -497,22 +497,22 @@  discard block
 block discarded – undo
497 497
 	 * @param string $path Path the file should be stored at
498 498
 	 * @return string Path to the uploaded file
499 499
 	 */
500
-	protected function storeFile( \Psr\Http\Message\UploadedFileInterface $file, $path )
500
+	protected function storeFile(\Psr\Http\Message\UploadedFileInterface $file, $path)
501 501
 	{
502
-		$fs = $this->getContext()->getFilesystemManager()->get( 'fs-secure' );
502
+		$fs = $this->getContext()->getFilesystemManager()->get('fs-secure');
503 503
 
504
-		if( $path == null )
504
+		if ($path == null)
505 505
 		{
506
-			$ext = pathinfo( $file->getClientFilename(), PATHINFO_EXTENSION );
507
-			$hash = md5( $file->getClientFilename() . microtime( true ) );
508
-			$path = sprintf( '%s/%s/%s.%s', $hash[0], $hash[1], $hash, $ext );
506
+			$ext = pathinfo($file->getClientFilename(), PATHINFO_EXTENSION);
507
+			$hash = md5($file->getClientFilename() . microtime(true));
508
+			$path = sprintf('%s/%s/%s.%s', $hash[0], $hash[1], $hash, $ext);
509 509
 
510
-			if( !$fs->isdir( $hash[0] . '/' . $hash[1] ) ) {
511
-				$fs->mkdir( $hash[0] . '/' . $hash[1] );
510
+			if (!$fs->isdir($hash[0] . '/' . $hash[1])) {
511
+				$fs->mkdir($hash[0] . '/' . $hash[1]);
512 512
 			}
513 513
 		}
514 514
 
515
-		$fs->writes( $path, $file->getStream()->detach() );
515
+		$fs->writes($path, $file->getStream()->detach());
516 516
 
517 517
 		return $path;
518 518
 	}
@@ -523,47 +523,47 @@  discard block
 block discarded – undo
523 523
 	 *
524 524
 	 * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters
525 525
 	 */
526
-	protected function updateItems( \Aimeos\MW\View\Iface $view )
526
+	protected function updateItems(\Aimeos\MW\View\Iface $view)
527 527
 	{
528 528
 		$id = $view->item->getId();
529 529
 		$context = $this->getContext();
530 530
 
531
-		$attrManager = \Aimeos\MShop\Factory::createManager( $context, 'attribute' );
532
-		$listManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' );
531
+		$attrManager = \Aimeos\MShop\Factory::createManager($context, 'attribute');
532
+		$listManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists');
533 533
 
534
-		$listItems = $this->getListItems( $id );
535
-		$listId = $view->param( 'download/product.lists.id' );
534
+		$listItems = $this->getListItems($id);
535
+		$listId = $view->param('download/product.lists.id');
536 536
 
537
-		if( isset( $listItems[$listId] ) ) {
537
+		if (isset($listItems[$listId])) {
538 538
 			$litem = $listItems[$listId];
539 539
 		} else {
540
-			$litem = $this->createListItem( $id );
540
+			$litem = $this->createListItem($id);
541 541
 		}
542 542
 
543
-		if( ( $attrId = $view->param( 'download/attribute.id' ) ) != '' ) {
544
-			$item = $attrManager->getItem( $attrId );
543
+		if (($attrId = $view->param('download/attribute.id')) != '') {
544
+			$item = $attrManager->getItem($attrId);
545 545
 		} else {
546 546
 			$item = $this->createItem();
547 547
 		}
548 548
 
549
-		if( ( $file = $view->value( (array) $view->request()->getUploadedFiles(), 'download/file' ) ) !== null
549
+		if (($file = $view->value((array) $view->request()->getUploadedFiles(), 'download/file')) !== null
550 550
 			&& $file->getError() === UPLOAD_ERR_OK
551 551
 		) {
552
-			$path = ( $view->param( 'download/overwrite' ) == 1 ? $item->getCode() : null );
553
-			$item->setCode( $this->storeFile( $file, $path ) );
552
+			$path = ($view->param('download/overwrite') == 1 ? $item->getCode() : null);
553
+			$item->setCode($this->storeFile($file, $path));
554 554
 		}
555 555
 
556
-		if( ( $label = $view->param( 'download/attribute.label' ) ) != '' )
556
+		if (($label = $view->param('download/attribute.label')) != '')
557 557
 		{
558
-			$item->setLabel( $label );
559
-			$attrManager->saveItem( $item );
558
+			$item->setLabel($label);
559
+			$attrManager->saveItem($item);
560 560
 
561
-			$litem->setPosition( 0 );
562
-			$litem->setRefId( $item->getId() );
563
-			$litem->setStatus( $view->param( 'download/product.lists.status' ) );
564
-			$listManager->saveItem( $litem );
561
+			$litem->setPosition(0);
562
+			$litem->setRefId($item->getId());
563
+			$litem->setStatus($view->param('download/product.lists.status'));
564
+			$listManager->saveItem($litem);
565 565
 		}
566 566
 
567
-		$this->cleanupItems( $listItems, array( $listId ) );
567
+		$this->cleanupItems($listItems, array($listId));
568 568
 	}
569 569
 }
570 570
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -196,16 +196,14 @@  discard block
 block discarded – undo
196 196
 			$attrManager->commit();
197 197
 			$manager->commit();
198 198
 			return;
199
-		}
200
-		catch( \Aimeos\MShop\Exception $e )
199
+		} catch( \Aimeos\MShop\Exception $e )
201 200
 		{
202 201
 			$error = array( 'product-item-download' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) );
203 202
 			$view->errors = $view->get( 'errors', array() ) + $error;
204 203
 
205 204
 			$attrManager->rollback();
206 205
 			$manager->rollback();
207
-		}
208
-		catch( \Exception $e )
206
+		} catch( \Exception $e )
209 207
 		{
210 208
 			$context->getLogger()->log( $e->getMessage() . ' - ' . $e->getTraceAsString() );
211 209
 			$error = array( 'product-item-download' => $e->getMessage() );
@@ -482,8 +480,7 @@  discard block
 block discarded – undo
482 480
 
483 481
 				$data['time'] = $fs->time( $data['path'] );
484 482
 				$data['size'] = $fs->size( $data['path'] );
485
-			}
486
-			catch( \Exception $e ) { ; } // Show product even if file isn't available any more
483
+			} catch( \Exception $e ) { ; } // Show product even if file isn't available any more
487 484
 		}
488 485
 
489 486
 		$view->downloadData = $data;
Please login to merge, or discard this patch.
admin/jqadm/tests/Admin/JQAdm/Common/Factory/BaseTest.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -96,7 +96,6 @@
 block discarded – undo
96 96
 {
97 97
 	/**
98 98
 	 * @param string $classprefix
99
-	 * @param string $path
100 99
 	 */
101 100
 	public static function addDecoratorsPublic( \Aimeos\MShop\Context\Item\Iface $context,
102 101
 		\Aimeos\Admin\JQAdm\Iface $client, $templatePaths, array $decorators, $classprefix )
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -17,76 +17,76 @@  discard block
 block discarded – undo
17 17
 	protected function setUp()
18 18
 	{
19 19
 		$this->context = \TestHelperJqadm::getContext();
20
-		$this->context->setView( \TestHelperJqadm::getView() );
20
+		$this->context->setView(\TestHelperJqadm::getView());
21 21
 
22 22
 		$config = $this->context->getConfig();
23
-		$config->set( 'admin/jqadm/common/decorators/default', array() );
24
-		$config->set( 'admin/jqadm/decorators/global', array() );
25
-		$config->set( 'admin/jqadm/decorators/local', array() );
23
+		$config->set('admin/jqadm/common/decorators/default', array());
24
+		$config->set('admin/jqadm/decorators/global', array());
25
+		$config->set('admin/jqadm/decorators/local', array());
26 26
 
27 27
 	}
28 28
 
29 29
 
30 30
 	public function testInjectClient()
31 31
 	{
32
-		$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' );
33
-		\Aimeos\Admin\JQAdm\Product\Factory::injectClient( '\\Aimeos\\Admin\\JQAdm\\Product\\Standard', $client );
32
+		$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient($this->context, array(), 'Standard');
33
+		\Aimeos\Admin\JQAdm\Product\Factory::injectClient('\\Aimeos\\Admin\\JQAdm\\Product\\Standard', $client);
34 34
 
35
-		$iClient = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' );
35
+		$iClient = \Aimeos\Admin\JQAdm\Product\Factory::createClient($this->context, array(), 'Standard');
36 36
 
37
-		$this->assertSame( $client, $iClient );
37
+		$this->assertSame($client, $iClient);
38 38
 	}
39 39
 
40 40
 
41 41
 	public function testInjectClientReset()
42 42
 	{
43
-		$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' );
44
-		\Aimeos\Admin\JQAdm\Product\Factory::injectClient( '\\Aimeos\\Admin\\JQAdm\\Product\\Standard', $client );
45
-		\Aimeos\Admin\JQAdm\Product\Factory::injectClient( '\\Aimeos\\Admin\\JQAdm\\Product\\Standard', null );
43
+		$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient($this->context, array(), 'Standard');
44
+		\Aimeos\Admin\JQAdm\Product\Factory::injectClient('\\Aimeos\\Admin\\JQAdm\\Product\\Standard', $client);
45
+		\Aimeos\Admin\JQAdm\Product\Factory::injectClient('\\Aimeos\\Admin\\JQAdm\\Product\\Standard', null);
46 46
 
47
-		$new = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' );
47
+		$new = \Aimeos\Admin\JQAdm\Product\Factory::createClient($this->context, array(), 'Standard');
48 48
 
49
-		$this->assertNotSame( $client, $new );
49
+		$this->assertNotSame($client, $new);
50 50
 	}
51 51
 
52 52
 
53 53
 	public function testAddDecoratorsInvalidName()
54 54
 	{
55
-		$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' );
55
+		$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient($this->context, array(), 'Standard');
56 56
 
57
-		$this->setExpectedException( '\\Aimeos\\Admin\\JQAdm\\Exception' );
58
-		\Aimeos\Admin\JQAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $this->context, $client, array(),
59
-			array( '$' ), 'Test' );
57
+		$this->setExpectedException('\\Aimeos\\Admin\\JQAdm\\Exception');
58
+		\Aimeos\Admin\JQAdm\Common\Factory\TestAbstract::addDecoratorsPublic($this->context, $client, array(),
59
+			array('$'), 'Test');
60 60
 	}
61 61
 
62 62
 
63 63
 	public function testAddDecoratorsInvalidClass()
64 64
 	{
65
-		$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' );
65
+		$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient($this->context, array(), 'Standard');
66 66
 
67
-		$this->setExpectedException( '\\Aimeos\\Admin\\JQAdm\\Exception' );
68
-		\Aimeos\Admin\JQAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $this->context, $client, array(),
69
-			array( 'Test' ), 'TestDecorator' );
67
+		$this->setExpectedException('\\Aimeos\\Admin\\JQAdm\\Exception');
68
+		\Aimeos\Admin\JQAdm\Common\Factory\TestAbstract::addDecoratorsPublic($this->context, $client, array(),
69
+			array('Test'), 'TestDecorator');
70 70
 	}
71 71
 
72 72
 
73 73
 	public function testAddDecoratorsInvalidInterface()
74 74
 	{
75
-		$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' );
75
+		$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient($this->context, array(), 'Standard');
76 76
 
77
-		$this->setExpectedException( '\\Aimeos\\Admin\\JQAdm\\Exception' );
78
-		\Aimeos\Admin\JQAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $this->context, $client, array(),
79
-			array( 'Test' ), '\\Aimeos\\Admin\\JQAdm\\Common\\Decorator\\' );
77
+		$this->setExpectedException('\\Aimeos\\Admin\\JQAdm\\Exception');
78
+		\Aimeos\Admin\JQAdm\Common\Factory\TestAbstract::addDecoratorsPublic($this->context, $client, array(),
79
+			array('Test'), '\\Aimeos\\Admin\\JQAdm\\Common\\Decorator\\');
80 80
 	}
81 81
 
82 82
 
83 83
 	public function testAddClientDecoratorsExcludes()
84 84
 	{
85
-		$this->context->getConfig()->set( 'admin/jqadm/decorators/excludes', array( 'TestDecorator' ) );
86
-		$this->context->getConfig()->set( 'admin/jqadm/common/decorators/default', array( 'TestDecorator' ) );
85
+		$this->context->getConfig()->set('admin/jqadm/decorators/excludes', array('TestDecorator'));
86
+		$this->context->getConfig()->set('admin/jqadm/common/decorators/default', array('TestDecorator'));
87 87
 
88
-		$this->setExpectedException( '\\Aimeos\\Admin\\JQAdm\\Exception' );
89
-		\Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' );
88
+		$this->setExpectedException('\\Aimeos\\Admin\\JQAdm\\Exception');
89
+		\Aimeos\Admin\JQAdm\Product\Factory::createClient($this->context, array(), 'Standard');
90 90
 	}
91 91
 }
92 92
 
@@ -98,16 +98,16 @@  discard block
 block discarded – undo
98 98
 	 * @param string $classprefix
99 99
 	 * @param string $path
100 100
 	 */
101
-	public static function addDecoratorsPublic( \Aimeos\MShop\Context\Item\Iface $context,
102
-		\Aimeos\Admin\JQAdm\Iface $client, $templatePaths, array $decorators, $classprefix )
101
+	public static function addDecoratorsPublic(\Aimeos\MShop\Context\Item\Iface $context,
102
+		\Aimeos\Admin\JQAdm\Iface $client, $templatePaths, array $decorators, $classprefix)
103 103
 	{
104
-		self::addDecorators( $context, $client, $templatePaths, $decorators, $classprefix );
104
+		self::addDecorators($context, $client, $templatePaths, $decorators, $classprefix);
105 105
 	}
106 106
 
107
-	public static function addClientDecoratorsPublic( \Aimeos\MShop\Context\Item\Iface $context,
108
-		\Aimeos\Admin\JQAdm\Iface $client, $templatePaths, $path )
107
+	public static function addClientDecoratorsPublic(\Aimeos\MShop\Context\Item\Iface $context,
108
+		\Aimeos\Admin\JQAdm\Iface $client, $templatePaths, $path)
109 109
 	{
110
-		self::addClientDecorators( $context, $client, $templatePaths, $path );
110
+		self::addClientDecorators($context, $client, $templatePaths, $path);
111 111
 	}
112 112
 }
113 113
 
Please login to merge, or discard this patch.
admin/jqadm/src/Admin/JQAdm/Base.php 1 patch
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	 * @param array $templatePaths Associative list of the file system paths to the core or the extensions as key
34 34
 	 * 	and a list of relative paths inside the core or the extension as values
35 35
 	 */
36
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $templatePaths )
36
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $templatePaths)
37 37
 	{
38 38
 		$this->context = $context;
39 39
 		$this->templatePaths = $templatePaths;
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 * @param array $param List of method parameter
48 48
 	 * @return boolean False for every call
49 49
 	 */
50
-	public function __call( $name, array $param )
50
+	public function __call($name, array $param)
51 51
 	{
52 52
 		return false;
53 53
 	}
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 	 */
61 61
 	public function getView()
62 62
 	{
63
-		if( !isset( $this->view ) ) {
64
-			throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'No view available' ) );
63
+		if (!isset($this->view)) {
64
+			throw new \Aimeos\Admin\JQAdm\Exception(sprintf('No view available'));
65 65
 		}
66 66
 
67 67
 		return $this->view;
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 * @param \Aimeos\MW\View\Iface $view The view object which generates the admin output
75 75
 	 * @return \Aimeos\Admin\JQAdm\Iface Reference to this object for fluent calls
76 76
 	 */
77
-	public function setView( \Aimeos\MW\View\Iface $view )
77
+	public function setView(\Aimeos\MW\View\Iface $view)
78 78
 	{
79 79
 		$this->view = $view;
80 80
 		return $this;
@@ -110,29 +110,29 @@  discard block
 block discarded – undo
110 110
 	 * @param string $classprefix Decorator class prefix, e.g. "\Aimeos\Admin\JQAdm\Catalog\Decorator\"
111 111
 	 * @return \Aimeos\Admin\JQAdm\Iface Admin object
112 112
 	 */
113
-	protected function addDecorators( \Aimeos\Admin\JQAdm\Iface $client, array $templatePaths,
114
-		array $decorators, $classprefix )
113
+	protected function addDecorators(\Aimeos\Admin\JQAdm\Iface $client, array $templatePaths,
114
+		array $decorators, $classprefix)
115 115
 	{
116 116
 		$iface = '\\Aimeos\\Admin\\JQAdm\\Common\\Decorator\\Iface';
117 117
 
118
-		foreach( $decorators as $name )
118
+		foreach ($decorators as $name)
119 119
 		{
120
-			if( ctype_alnum( $name ) === false )
120
+			if (ctype_alnum($name) === false)
121 121
 			{
122
-				$classname = is_string( $name ) ? $classprefix . $name : '<not a string>';
123
-				throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) );
122
+				$classname = is_string($name) ? $classprefix . $name : '<not a string>';
123
+				throw new \Aimeos\Admin\JQAdm\Exception(sprintf('Invalid class name "%1$s"', $classname));
124 124
 			}
125 125
 
126 126
 			$classname = $classprefix . $name;
127 127
 
128
-			if( class_exists( $classname ) === false ) {
129
-				throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Class "%1$s" not found', $classname ) );
128
+			if (class_exists($classname) === false) {
129
+				throw new \Aimeos\Admin\JQAdm\Exception(sprintf('Class "%1$s" not found', $classname));
130 130
 			}
131 131
 
132
-			$client = new $classname( $client, $this->context, $this->templatePaths );
132
+			$client = new $classname($client, $this->context, $this->templatePaths);
133 133
 
134
-			if( !( $client instanceof $iface ) ) {
135
-				throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Class "%1$s" does not implement "%2$s"', $classname, $iface ) );
134
+			if (!($client instanceof $iface)) {
135
+				throw new \Aimeos\Admin\JQAdm\Exception(sprintf('Class "%1$s" does not implement "%2$s"', $classname, $iface));
136 136
 			}
137 137
 		}
138 138
 
@@ -148,35 +148,35 @@  discard block
 block discarded – undo
148 148
 	 * @param string $path Admin string in lower case, e.g. "catalog/detail/basic"
149 149
 	 * @return \Aimeos\Admin\JQAdm\Iface Admin object
150 150
 	 */
151
-	protected function addClientDecorators( \Aimeos\Admin\JQAdm\Iface $client, array $templatePaths, $path )
151
+	protected function addClientDecorators(\Aimeos\Admin\JQAdm\Iface $client, array $templatePaths, $path)
152 152
 	{
153
-		if( !is_string( $path ) || $path === '' ) {
154
-			throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Invalid domain "%1$s"', $path ) );
153
+		if (!is_string($path) || $path === '') {
154
+			throw new \Aimeos\Admin\JQAdm\Exception(sprintf('Invalid domain "%1$s"', $path));
155 155
 		}
156 156
 
157
-		$localClass = str_replace( ' ', '\\', ucwords( str_replace( '/', ' ', $path ) ) );
157
+		$localClass = str_replace(' ', '\\', ucwords(str_replace('/', ' ', $path)));
158 158
 		$config = $this->context->getConfig();
159 159
 
160
-		$decorators = $config->get( 'admin/jqadm/common/decorators/default', array() );
161
-		$excludes = $config->get( 'admin/jqadm/' . $path . '/decorators/excludes', array() );
160
+		$decorators = $config->get('admin/jqadm/common/decorators/default', array());
161
+		$excludes = $config->get('admin/jqadm/' . $path . '/decorators/excludes', array());
162 162
 
163
-		foreach( $decorators as $key => $name )
163
+		foreach ($decorators as $key => $name)
164 164
 		{
165
-			if( in_array( $name, $excludes ) ) {
166
-				unset( $decorators[$key] );
165
+			if (in_array($name, $excludes)) {
166
+				unset($decorators[$key]);
167 167
 			}
168 168
 		}
169 169
 
170 170
 		$classprefix = '\\Aimeos\\Admin\\JQAdm\\Common\\Decorator\\';
171
-		$client = $this->addDecorators( $client, $templatePaths, $decorators, $classprefix );
171
+		$client = $this->addDecorators($client, $templatePaths, $decorators, $classprefix);
172 172
 
173 173
 		$classprefix = '\\Aimeos\\Admin\\JQAdm\\Common\\Decorator\\';
174
-		$decorators = $config->get( 'admin/jqadm/' . $path . '/decorators/global', array() );
175
-		$client = $this->addDecorators( $client, $templatePaths, $decorators, $classprefix );
174
+		$decorators = $config->get('admin/jqadm/' . $path . '/decorators/global', array());
175
+		$client = $this->addDecorators($client, $templatePaths, $decorators, $classprefix);
176 176
 
177 177
 		$classprefix = '\\Aimeos\\Admin\\JQAdm\\' . $localClass . '\\Decorator\\';
178
-		$decorators = $config->get( 'admin/jqadm/' . $path . '/decorators/local', array() );
179
-		$client = $this->addDecorators( $client, $templatePaths, $decorators, $classprefix );
178
+		$decorators = $config->get('admin/jqadm/' . $path . '/decorators/local', array());
179
+		$client = $this->addDecorators($client, $templatePaths, $decorators, $classprefix);
180 180
 
181 181
 		return $client;
182 182
 	}
@@ -189,35 +189,35 @@  discard block
 block discarded – undo
189 189
 	 * @param string|null $name Name of the implementation, will be from configuration (or Default) if null
190 190
 	 * @return \Aimeos\Admin\JQAdm\Iface Sub-part object
191 191
 	 */
192
-	protected function createSubClient( $path, $name )
192
+	protected function createSubClient($path, $name)
193 193
 	{
194
-		$path = strtolower( $path );
194
+		$path = strtolower($path);
195 195
 
196
-		if( $name === null ) {
197
-			$name = $this->context->getConfig()->get( 'admin/jqadm/' . $path . '/name', 'Standard' );
196
+		if ($name === null) {
197
+			$name = $this->context->getConfig()->get('admin/jqadm/' . $path . '/name', 'Standard');
198 198
 		}
199 199
 
200
-		if( empty( $name ) || ctype_alnum( $name ) === false ) {
201
-			throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Invalid characters in client name "%1$s"', $name ) );
200
+		if (empty($name) || ctype_alnum($name) === false) {
201
+			throw new \Aimeos\Admin\JQAdm\Exception(sprintf('Invalid characters in client name "%1$s"', $name));
202 202
 		}
203 203
 
204
-		$subnames = str_replace( ' ', '\\', ucwords( str_replace( '/', ' ', $path ) ) );
204
+		$subnames = str_replace(' ', '\\', ucwords(str_replace('/', ' ', $path)));
205 205
 
206 206
 		$classname = '\\Aimeos\\Admin\\JQAdm\\' . $subnames . '\\' . $name;
207 207
 		$interface = '\\Aimeos\\Admin\\JQAdm\\Iface';
208 208
 
209
-		if( class_exists( $classname ) === false ) {
210
-			throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Class "%1$s" not available', $classname ) );
209
+		if (class_exists($classname) === false) {
210
+			throw new \Aimeos\Admin\JQAdm\Exception(sprintf('Class "%1$s" not available', $classname));
211 211
 		}
212 212
 
213
-		$object = new $classname( $this->context, $this->templatePaths );
213
+		$object = new $classname($this->context, $this->templatePaths);
214 214
 
215
-		if( ( $object instanceof $interface ) === false ) {
216
-			throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Class "%1$s" does not implement interface "%2$s"', $classname, $interface ) );
215
+		if (($object instanceof $interface) === false) {
216
+			throw new \Aimeos\Admin\JQAdm\Exception(sprintf('Class "%1$s" does not implement interface "%2$s"', $classname, $interface));
217 217
 		}
218 218
 
219
-		$object = $this->addClientDecorators( $object, $this->templatePaths, $path );
220
-		$object->setView( $this->view );
219
+		$object = $this->addClientDecorators($object, $this->templatePaths, $path);
220
+		$object->setView($this->view);
221 221
 
222 222
 		return $object;
223 223
 	}
@@ -229,13 +229,13 @@  discard block
 block discarded – undo
229 229
 	 * @param array $names List of parameter names
230 230
 	 * @return array Associative list of parameters names as key and their values
231 231
 	 */
232
-	protected function getClientParams( $names = array( 'resource', 'site', 'lang', 'fields', 'filter', 'page', 'sort' ) )
232
+	protected function getClientParams($names = array('resource', 'site', 'lang', 'fields', 'filter', 'page', 'sort'))
233 233
 	{
234 234
 		$list = array();
235 235
 
236
-		foreach( $names as $name )
236
+		foreach ($names as $name)
237 237
 		{
238
-			if( ( $val = $this->view->param( $name ) ) !== null ) {
238
+			if (($val = $this->view->param($name)) !== null) {
239 239
 				$list[$name] = $val;
240 240
 			}
241 241
 		}
@@ -270,12 +270,12 @@  discard block
 block discarded – undo
270 270
 	 */
271 271
 	protected function getSubClients()
272 272
 	{
273
-		if( !isset( $this->subclients ) )
273
+		if (!isset($this->subclients))
274 274
 		{
275 275
 			$this->subclients = array();
276 276
 
277
-			foreach( $this->getSubClientNames() as $name ) {
278
-				$this->subclients[] = $this->getSubClient( $name );
277
+			foreach ($this->getSubClientNames() as $name) {
278
+				$this->subclients[] = $this->getSubClient($name);
279 279
 			}
280 280
 		}
281 281
 
@@ -301,11 +301,11 @@  discard block
 block discarded – undo
301 301
 	 * @param array $params List of criteria data with condition, sorting and paging
302 302
 	 * @return \Aimeos\MW\Criteria\Iface Initialized criteria object
303 303
 	 */
304
-	protected function initCriteria( \Aimeos\MW\Criteria\Iface $criteria, array $params )
304
+	protected function initCriteria(\Aimeos\MW\Criteria\Iface $criteria, array $params)
305 305
 	{
306
-		$this->initCriteriaConditions( $criteria, $params );
307
-		$this->initCriteriaSortations( $criteria, $params );
308
-		$this->initCriteriaSlice( $criteria, $params );
306
+		$this->initCriteriaConditions($criteria, $params);
307
+		$this->initCriteriaSortations($criteria, $params);
308
+		$this->initCriteriaSlice($criteria, $params);
309 309
 
310 310
 		return $criteria;
311 311
 	}
@@ -317,24 +317,24 @@  discard block
 block discarded – undo
317 317
 	 * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object
318 318
 	 * @param array $params List of criteria data with condition, sorting and paging
319 319
 	 */
320
-	private function initCriteriaConditions( \Aimeos\MW\Criteria\Iface $criteria, array $params )
320
+	private function initCriteriaConditions(\Aimeos\MW\Criteria\Iface $criteria, array $params)
321 321
 	{
322
-		if( isset( $params['filter'] ) && isset( $params['filter']['key'] ) )
322
+		if (isset($params['filter']) && isset($params['filter']['key']))
323 323
 		{
324 324
 			$expr = array();
325 325
 			$existing = $criteria->getConditions();
326 326
 
327
-			foreach( (array) $params['filter']['key'] as $idx => $key )
327
+			foreach ((array) $params['filter']['key'] as $idx => $key)
328 328
 			{
329
-				if( $key != '' && isset( $params['filter']['op'][$idx] ) && $params['filter']['op'][$idx] != ''
330
-					&& isset( $params['filter']['val'][$idx] )
329
+				if ($key != '' && isset($params['filter']['op'][$idx]) && $params['filter']['op'][$idx] != ''
330
+					&& isset($params['filter']['val'][$idx])
331 331
 				) {
332
-					$expr[] = $criteria->compare( $params['filter']['op'][$idx], $key, $params['filter']['val'][$idx] );
332
+					$expr[] = $criteria->compare($params['filter']['op'][$idx], $key, $params['filter']['val'][$idx]);
333 333
 				}
334 334
 			}
335 335
 
336 336
 			$expr[] = $existing;
337
-			$criteria->setConditions( $criteria->combine( '&&', $expr ) );
337
+			$criteria->setConditions($criteria->combine('&&', $expr));
338 338
 		}
339 339
 	}
340 340
 
@@ -345,12 +345,12 @@  discard block
 block discarded – undo
345 345
 	 * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object
346 346
 	 * @param array $params List of criteria data with condition, sorting and paging
347 347
 	 */
348
-	private function initCriteriaSlice( \Aimeos\MW\Criteria\Iface $criteria, array $params )
348
+	private function initCriteriaSlice(\Aimeos\MW\Criteria\Iface $criteria, array $params)
349 349
 	{
350
-		$start = ( isset( $params['page']['offset'] ) ? $params['page']['offset'] : 0 );
351
-		$size = ( isset( $params['page']['limit'] ) ? $params['page']['limit'] : 100 );
350
+		$start = (isset($params['page']['offset']) ? $params['page']['offset'] : 0);
351
+		$size = (isset($params['page']['limit']) ? $params['page']['limit'] : 100);
352 352
 
353
-		$criteria->setSlice( $start, $size );
353
+		$criteria->setSlice($start, $size);
354 354
 	}
355 355
 
356 356
 
@@ -360,23 +360,23 @@  discard block
 block discarded – undo
360 360
 	 * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object
361 361
 	 * @param array $params List of criteria data with condition, sorting and paging
362 362
 	 */
363
-	private function initCriteriaSortations( \Aimeos\MW\Criteria\Iface $criteria, array $params )
363
+	private function initCriteriaSortations(\Aimeos\MW\Criteria\Iface $criteria, array $params)
364 364
 	{
365
-		if( !isset( $params['sort'] ) ) {
365
+		if (!isset($params['sort'])) {
366 366
 			return;
367 367
 		}
368 368
 
369 369
 		$sortation = array();
370 370
 
371
-		foreach( (array) $params['sort'] as $sort )
371
+		foreach ((array) $params['sort'] as $sort)
372 372
 		{
373
-			if( $sort[0] === '-' ) {
374
-				$sortation[] = $criteria->sort( '-', substr( $sort, 1 ) );
373
+			if ($sort[0] === '-') {
374
+				$sortation[] = $criteria->sort('-', substr($sort, 1));
375 375
 			} else {
376
-				$sortation[] = $criteria->sort( '+', $sort ); break;
376
+				$sortation[] = $criteria->sort('+', $sort); break;
377 377
 			}
378 378
 		}
379 379
 
380
-		$criteria->setSortations( $sortation );
380
+		$criteria->setSortations($sortation);
381 381
 	}
382 382
 }
Please login to merge, or discard this patch.
admin/jqadm/tests/Admin/JQAdm/Product/Selection/StandardTest.php 1 patch
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -22,44 +22,44 @@  discard block
 block discarded – undo
22 22
 		$this->context = \TestHelperJqadm::getContext();
23 23
 		$templatePaths = \TestHelperJqadm::getTemplatePaths();
24 24
 
25
-		$this->object = new \Aimeos\Admin\JQAdm\Product\Selection\Standard( $this->context, $templatePaths );
26
-		$this->object->setView( $this->view );
25
+		$this->object = new \Aimeos\Admin\JQAdm\Product\Selection\Standard($this->context, $templatePaths);
26
+		$this->object->setView($this->view);
27 27
 	}
28 28
 
29 29
 
30 30
 	protected function tearDown()
31 31
 	{
32
-		unset( $this->object );
32
+		unset($this->object);
33 33
 	}
34 34
 
35 35
 
36 36
 	public function testCreate()
37 37
 	{
38
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' );
38
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'product');
39 39
 
40 40
 		$this->view->item = $manager->createItem();
41 41
 		$result = $this->object->create();
42 42
 
43
-		$this->assertNull( $this->view->get( 'errors' ) );
44
-		$this->assertStringStartsWith( '<div class="product-item-selection', $result );
43
+		$this->assertNull($this->view->get('errors'));
44
+		$this->assertStringStartsWith('<div class="product-item-selection', $result);
45 45
 	}
46 46
 
47 47
 
48 48
 	public function testCopy()
49 49
 	{
50
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' );
50
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'product');
51 51
 
52
-		$this->view->item = $manager->findItem( 'U:TEST', array( 'product' ) );
52
+		$this->view->item = $manager->findItem('U:TEST', array('product'));
53 53
 		$result = $this->object->copy();
54 54
 
55
-		$this->assertNull( $this->view->get( 'errors' ) );
56
-		$this->assertContains( 'U:TESTSUB01', $result );
57
-		$this->assertContains( 'U:TESTSUB02', $result );
58
-		$this->assertContains( 'U:TESTSUB03', $result );
59
-		$this->assertContains( 'U:TESTSUB04', $result );
60
-		$this->assertContains( 'U:TESTSUB05', $result );
61
-		$this->assertContains( 'value="30"', $result );
62
-		$this->assertContains( 'value="32"', $result );
55
+		$this->assertNull($this->view->get('errors'));
56
+		$this->assertContains('U:TESTSUB01', $result);
57
+		$this->assertContains('U:TESTSUB02', $result);
58
+		$this->assertContains('U:TESTSUB03', $result);
59
+		$this->assertContains('U:TESTSUB04', $result);
60
+		$this->assertContains('U:TESTSUB05', $result);
61
+		$this->assertContains('value="30"', $result);
62
+		$this->assertContains('value="32"', $result);
63 63
 	}
64 64
 
65 65
 
@@ -67,124 +67,124 @@  discard block
 block discarded – undo
67 67
 	{
68 68
 		$param = array(
69 69
 			'selection' => array(
70
-				'product.id' => array( 0 => '' ),
71
-				'product.code' => array( 0 => 'testprod' ),
72
-				'product.label' => array( 0 => 'test product' ),
70
+				'product.id' => array(0 => ''),
71
+				'product.code' => array(0 => 'testprod'),
72
+				'product.label' => array(0 => 'test product'),
73 73
 				'attr' => array(
74
-					'id' => array( 0 => '123' ),
75
-					'label' => array( 0 => 'test attribute' ),
76
-					'ref' => array( 0 => 'testprod' ),
74
+					'id' => array(0 => '123'),
75
+					'label' => array(0 => 'test attribute'),
76
+					'ref' => array(0 => 'testprod'),
77 77
 				)
78 78
 			),
79 79
 		);
80 80
 
81
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $param );
82
-		$this->view->addHelper( 'param', $helper );
81
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $param);
82
+		$this->view->addHelper('param', $helper);
83 83
 
84
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' );
85
-		$this->view->item = $manager->findItem( 'U:TEST' );
84
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'product');
85
+		$this->view->item = $manager->findItem('U:TEST');
86 86
 
87 87
 		$result = $this->object->get();
88 88
 
89
-		$this->assertNull( $this->view->get( 'errors' ) );
90
-		$this->assertContains( 'testprod', $result );
91
-		$this->assertContains( 'value="123"', $result );
89
+		$this->assertNull($this->view->get('errors'));
90
+		$this->assertContains('testprod', $result);
91
+		$this->assertContains('value="123"', $result);
92 92
 	}
93 93
 
94 94
 
95 95
 	public function testSave()
96 96
 	{
97
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' );
97
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'product');
98 98
 
99
-		$item = $manager->findItem( 'U:TEST' );
100
-		$item->setCode( 'jqadm-test-selection' );
101
-		$item->setId( null );
99
+		$item = $manager->findItem('U:TEST');
100
+		$item->setCode('jqadm-test-selection');
101
+		$item->setId(null);
102 102
 
103
-		$manager->saveItem( $item );
103
+		$manager->saveItem($item);
104 104
 
105
-		$attrManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
106
-		$attrItem = $attrManager->findItem( 'xs', array(), 'product', 'size' );
105
+		$attrManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute');
106
+		$attrItem = $attrManager->findItem('xs', array(), 'product', 'size');
107 107
 
108 108
 
109 109
 		$param = array(
110 110
 			'selection' => array(
111
-				'product.lists.id' => array( 0 => '' ),
112
-				'product.id' => array( 0 => $item->getId() ),
113
-				'product.code' => array( 0 => 'testprod' ),
114
-				'product.label' => array( 0 => 'test product' ),
111
+				'product.lists.id' => array(0 => ''),
112
+				'product.id' => array(0 => $item->getId()),
113
+				'product.code' => array(0 => 'testprod'),
114
+				'product.label' => array(0 => 'test product'),
115 115
 				'attr' => array(
116
-					'id' => array( 0 => $attrItem->getId() ),
117
-					'label' => array( 0 => 'test attribute' ),
118
-					'ref' => array( 0 => 'testprod' ),
116
+					'id' => array(0 => $attrItem->getId()),
117
+					'label' => array(0 => 'test attribute'),
118
+					'ref' => array(0 => 'testprod'),
119 119
 				)
120 120
 			),
121 121
 		);
122 122
 
123
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $param );
124
-		$this->view->addHelper( 'param', $helper );
123
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $param);
124
+		$this->view->addHelper('param', $helper);
125 125
 		$this->view->item = $item;
126 126
 
127 127
 		$result = $this->object->save();
128 128
 
129
-		$item = $manager->getItem( $item->getId(), array( 'product' ) );
130
-		$variants = $item->getListItems( 'product', 'default' );
129
+		$item = $manager->getItem($item->getId(), array('product'));
130
+		$variants = $item->getListItems('product', 'default');
131 131
 
132
-		if( empty( $variants ) ) {
133
-			throw new \Exception( 'No variant products available' );
132
+		if (empty($variants)) {
133
+			throw new \Exception('No variant products available');
134 134
 		}
135 135
 
136
-		$variant = $manager->getItem( reset( $variants )->getRefId(), array( 'attribute' ) );
137
-		$attributes = $variant->getListItems( 'attribute', 'variant' );
136
+		$variant = $manager->getItem(reset($variants)->getRefId(), array('attribute'));
137
+		$attributes = $variant->getListItems('attribute', 'variant');
138 138
 
139
-		$manager->deleteItems( array( $item->getId(), $variant->getId() ) );
139
+		$manager->deleteItems(array($item->getId(), $variant->getId()));
140 140
 
141 141
 
142
-		$this->assertNull( $this->view->get( 'errors' ) );
143
-		$this->assertNull( $result );
144
-		$this->assertEquals( 1, count( $variants ) );
145
-		$this->assertEquals( 1, count( $attributes ) );
146
-		$this->assertEquals( 'testprod', $variant->getCode() );
147
-		$this->assertEquals( $attrItem->getId(), reset( $attributes )->getRefId() );
142
+		$this->assertNull($this->view->get('errors'));
143
+		$this->assertNull($result);
144
+		$this->assertEquals(1, count($variants));
145
+		$this->assertEquals(1, count($attributes));
146
+		$this->assertEquals('testprod', $variant->getCode());
147
+		$this->assertEquals($attrItem->getId(), reset($attributes)->getRefId());
148 148
 	}
149 149
 
150 150
 
151 151
 	public function testSaveException()
152 152
 	{
153
-		$object = $this->getMockBuilder( '\Aimeos\Admin\JQAdm\Product\Selection\Standard' )
154
-			->setConstructorArgs( array( $this->context, \TestHelperJqadm::getTemplatePaths() ) )
155
-			->setMethods( array( 'updateItems' ) )
153
+		$object = $this->getMockBuilder('\Aimeos\Admin\JQAdm\Product\Selection\Standard')
154
+			->setConstructorArgs(array($this->context, \TestHelperJqadm::getTemplatePaths()))
155
+			->setMethods(array('updateItems'))
156 156
 			->getMock();
157 157
 
158
-		$object->expects( $this->once() )->method( 'updateItems' )
159
-			->will( $this->throwException( new \Exception() ) );
158
+		$object->expects($this->once())->method('updateItems')
159
+			->will($this->throwException(new \Exception()));
160 160
 
161
-		$object->setView( \TestHelperJqadm::getView() );
161
+		$object->setView(\TestHelperJqadm::getView());
162 162
 
163
-		$this->setExpectedException( '\Aimeos\Admin\JQAdm\Exception' );
163
+		$this->setExpectedException('\Aimeos\Admin\JQAdm\Exception');
164 164
 		$object->save();
165 165
 	}
166 166
 
167 167
 
168 168
 	public function testSaveMShopException()
169 169
 	{
170
-		$object = $this->getMockBuilder( '\Aimeos\Admin\JQAdm\Product\Selection\Standard' )
171
-			->setConstructorArgs( array( $this->context, \TestHelperJqadm::getTemplatePaths() ) )
172
-			->setMethods( array( 'updateItems' ) )
170
+		$object = $this->getMockBuilder('\Aimeos\Admin\JQAdm\Product\Selection\Standard')
171
+			->setConstructorArgs(array($this->context, \TestHelperJqadm::getTemplatePaths()))
172
+			->setMethods(array('updateItems'))
173 173
 			->getMock();
174 174
 
175
-		$object->expects( $this->once() )->method( 'updateItems' )
176
-			->will( $this->throwException( new \Aimeos\MShop\Exception() ) );
175
+		$object->expects($this->once())->method('updateItems')
176
+			->will($this->throwException(new \Aimeos\MShop\Exception()));
177 177
 
178
-		$object->setView( \TestHelperJqadm::getView() );
178
+		$object->setView(\TestHelperJqadm::getView());
179 179
 
180
-		$this->setExpectedException( '\Aimeos\Admin\JQAdm\Exception' );
180
+		$this->setExpectedException('\Aimeos\Admin\JQAdm\Exception');
181 181
 		$object->save();
182 182
 	}
183 183
 
184 184
 
185 185
 	public function testGetSubClient()
186 186
 	{
187
-		$this->setExpectedException( '\Aimeos\Admin\JQAdm\Exception' );
188
-		$this->object->getSubClient( 'invalid' );
187
+		$this->setExpectedException('\Aimeos\Admin\JQAdm\Exception');
188
+		$this->object->getSubClient('invalid');
189 189
 	}
190 190
 }
Please login to merge, or discard this patch.
admin/jqadm/tests/Admin/JQAdm/Product/Text/StandardTest.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -22,38 +22,38 @@  discard block
 block discarded – undo
22 22
 		$this->context = \TestHelperJqadm::getContext();
23 23
 		$templatePaths = \TestHelperJqadm::getTemplatePaths();
24 24
 
25
-		$this->object = new \Aimeos\Admin\JQAdm\Product\Text\Standard( $this->context, $templatePaths );
26
-		$this->object->setView( $this->view );
25
+		$this->object = new \Aimeos\Admin\JQAdm\Product\Text\Standard($this->context, $templatePaths);
26
+		$this->object->setView($this->view);
27 27
 	}
28 28
 
29 29
 
30 30
 	protected function tearDown()
31 31
 	{
32
-		unset( $this->object );
32
+		unset($this->object);
33 33
 	}
34 34
 
35 35
 
36 36
 	public function testCreate()
37 37
 	{
38
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' );
38
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'product');
39 39
 
40 40
 		$this->view->item = $manager->createItem();
41 41
 		$result = $this->object->create();
42 42
 
43
-		$this->assertContains( 'Texts', $result );
44
-		$this->assertNull( $this->view->get( 'errors' ) );
43
+		$this->assertContains('Texts', $result);
44
+		$this->assertNull($this->view->get('errors'));
45 45
 	}
46 46
 
47 47
 
48 48
 	public function testCopy()
49 49
 	{
50
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' );
50
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'product');
51 51
 
52
-		$this->view->item = $manager->findItem( 'ABCD', array( 'text' ) );
52
+		$this->view->item = $manager->findItem('ABCD', array('text'));
53 53
 		$result = $this->object->copy();
54 54
 
55
-		$this->assertNull( $this->view->get( 'errors' ) );
56
-		$this->assertContains( 'value="Unterproduct 1"', $result );
55
+		$this->assertNull($this->view->get('errors'));
56
+		$this->assertContains('value="Unterproduct 1"', $result);
57 57
 	}
58 58
 
59 59
 
@@ -61,113 +61,113 @@  discard block
 block discarded – undo
61 61
 	{
62 62
 		$result = $this->object->delete();
63 63
 
64
-		$this->assertNull( $this->view->get( 'errors' ) );
65
-		$this->assertNull( $result );
64
+		$this->assertNull($this->view->get('errors'));
65
+		$this->assertNull($result);
66 66
 	}
67 67
 
68 68
 
69 69
 	public function testGet()
70 70
 	{
71
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' );
71
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'product');
72 72
 
73
-		$this->view->item = $manager->findItem( 'ABCD', array( 'text' ) );
73
+		$this->view->item = $manager->findItem('ABCD', array('text'));
74 74
 		$result = $this->object->get();
75 75
 
76
-		$this->assertNull( $this->view->get( 'errors' ) );
77
-		$this->assertContains( 'value="Unterproduct 1"', $result );
76
+		$this->assertNull($this->view->get('errors'));
77
+		$this->assertContains('value="Unterproduct 1"', $result);
78 78
 	}
79 79
 
80 80
 
81 81
 	public function testSave()
82 82
 	{
83
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' );
83
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'product');
84 84
 
85
-		$item = $manager->findItem( 'CNC' );
86
-		$item->setCode( 'jqadm-test-save' );
87
-		$item->setId( null );
85
+		$item = $manager->findItem('CNC');
86
+		$item->setCode('jqadm-test-save');
87
+		$item->setId(null);
88 88
 
89
-		$manager->saveItem( $item );
89
+		$manager->saveItem($item);
90 90
 
91 91
 
92 92
 		$param = array(
93 93
 			'text' => array(
94
-				'langid' => array( 'de' ),
95
-				'name' => array( 'listid' => '', 'content' => 'test name' ),
96
-				'short' => array( 'listid' => '', 'content' => 'short desc' ),
97
-				'long' => array( 'listid' => '', 'content' => 'long desc' ),
98
-				'url' => array( 'listid' => '', 'content' => 'url segment' ),
99
-				'meta-keyword' => array( 'listid' => '', 'content' => 'meta keywords' ),
100
-				'meta-description' => array( 'listid' => '', 'content' => 'meta desc' ),
94
+				'langid' => array('de'),
95
+				'name' => array('listid' => '', 'content' => 'test name'),
96
+				'short' => array('listid' => '', 'content' => 'short desc'),
97
+				'long' => array('listid' => '', 'content' => 'long desc'),
98
+				'url' => array('listid' => '', 'content' => 'url segment'),
99
+				'meta-keyword' => array('listid' => '', 'content' => 'meta keywords'),
100
+				'meta-description' => array('listid' => '', 'content' => 'meta desc'),
101 101
 			),
102 102
 		);
103 103
 
104
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $param );
105
-		$this->view->addHelper( 'param', $helper );
104
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $param);
105
+		$this->view->addHelper('param', $helper);
106 106
 		$this->view->item = $item;
107 107
 
108 108
 		$result = $this->object->save();
109 109
 
110
-		$item = $manager->getItem( $item->getId(), array( 'text' ) );
111
-		$manager->deleteItem( $item->getId() );
110
+		$item = $manager->getItem($item->getId(), array('text'));
111
+		$manager->deleteItem($item->getId());
112 112
 
113
-		$this->assertNull( $this->view->get( 'errors' ) );
114
-		$this->assertNull( $result );
115
-		$this->assertEquals( 6, count( $item->getListItems() ) );
113
+		$this->assertNull($this->view->get('errors'));
114
+		$this->assertNull($result);
115
+		$this->assertEquals(6, count($item->getListItems()));
116 116
 
117
-		foreach( $item->getListItems( 'text' ) as $listItem )
117
+		foreach ($item->getListItems('text') as $listItem)
118 118
 		{
119
-			$this->assertEquals( 'text', $listItem->getDomain() );
120
-			$this->assertEquals( 'default', $listItem->getType() );
119
+			$this->assertEquals('text', $listItem->getDomain());
120
+			$this->assertEquals('default', $listItem->getType());
121 121
 
122 122
 			$refItem = $listItem->getRefItem();
123
-			$this->assertEquals( 'de', $refItem->getLanguageId() );
123
+			$this->assertEquals('de', $refItem->getLanguageId());
124 124
 		}
125 125
 	}
126 126
 
127 127
 
128 128
 	public function testSaveException()
129 129
 	{
130
-		$object = $this->getMockBuilder( '\Aimeos\Admin\JQAdm\Product\Text\Standard' )
131
-			->setConstructorArgs( array( $this->context, \TestHelperJqadm::getTemplatePaths() ) )
132
-			->setMethods( array( 'updateItems' ) )
130
+		$object = $this->getMockBuilder('\Aimeos\Admin\JQAdm\Product\Text\Standard')
131
+			->setConstructorArgs(array($this->context, \TestHelperJqadm::getTemplatePaths()))
132
+			->setMethods(array('updateItems'))
133 133
 			->getMock();
134 134
 
135
-		$object->expects( $this->once() )->method( 'updateItems' )
136
-			->will( $this->throwException( new \Exception() ) );
135
+		$object->expects($this->once())->method('updateItems')
136
+			->will($this->throwException(new \Exception()));
137 137
 
138
-		$object->setView( \TestHelperJqadm::getView() );
138
+		$object->setView(\TestHelperJqadm::getView());
139 139
 
140
-		$this->setExpectedException( '\Aimeos\Admin\JQAdm\Exception' );
140
+		$this->setExpectedException('\Aimeos\Admin\JQAdm\Exception');
141 141
 		$object->save();
142 142
 	}
143 143
 
144 144
 
145 145
 	public function testSaveMShopException()
146 146
 	{
147
-		$object = $this->getMockBuilder( '\Aimeos\Admin\JQAdm\Product\Text\Standard' )
148
-			->setConstructorArgs( array( $this->context, \TestHelperJqadm::getTemplatePaths() ) )
149
-			->setMethods( array( 'updateItems' ) )
147
+		$object = $this->getMockBuilder('\Aimeos\Admin\JQAdm\Product\Text\Standard')
148
+			->setConstructorArgs(array($this->context, \TestHelperJqadm::getTemplatePaths()))
149
+			->setMethods(array('updateItems'))
150 150
 			->getMock();
151 151
 
152
-		$object->expects( $this->once() )->method( 'updateItems' )
153
-			->will( $this->throwException( new \Aimeos\MShop\Exception() ) );
152
+		$object->expects($this->once())->method('updateItems')
153
+			->will($this->throwException(new \Aimeos\MShop\Exception()));
154 154
 
155
-		$object->setView( \TestHelperJqadm::getView() );
155
+		$object->setView(\TestHelperJqadm::getView());
156 156
 
157
-		$this->setExpectedException( '\Aimeos\Admin\JQAdm\Exception' );
157
+		$this->setExpectedException('\Aimeos\Admin\JQAdm\Exception');
158 158
 		$object->save();
159 159
 	}
160 160
 
161 161
 
162 162
 	public function testSearch()
163 163
 	{
164
-		$this->assertNull( $this->object->search() );
164
+		$this->assertNull($this->object->search());
165 165
 	}
166 166
 
167 167
 
168 168
 	public function testGetSubClient()
169 169
 	{
170
-		$this->setExpectedException( '\Aimeos\Admin\JQAdm\Exception' );
171
-		$this->object->getSubClient( 'invalid' );
170
+		$this->setExpectedException('\Aimeos\Admin\JQAdm\Exception');
171
+		$this->object->getSubClient('invalid');
172 172
 	}
173 173
 }
Please login to merge, or discard this patch.
admin/jqadm/tests/Admin/JQAdm/Product/Price/StandardTest.php 1 patch
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -22,38 +22,38 @@  discard block
 block discarded – undo
22 22
 		$this->context = \TestHelperJqadm::getContext();
23 23
 		$templatePaths = \TestHelperJqadm::getTemplatePaths();
24 24
 
25
-		$this->object = new \Aimeos\Admin\JQAdm\Product\Price\Standard( $this->context, $templatePaths );
26
-		$this->object->setView( $this->view );
25
+		$this->object = new \Aimeos\Admin\JQAdm\Product\Price\Standard($this->context, $templatePaths);
26
+		$this->object->setView($this->view);
27 27
 	}
28 28
 
29 29
 
30 30
 	protected function tearDown()
31 31
 	{
32
-		unset( $this->object );
32
+		unset($this->object);
33 33
 	}
34 34
 
35 35
 
36 36
 	public function testCreate()
37 37
 	{
38
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' );
38
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'product');
39 39
 
40 40
 		$this->view->item = $manager->createItem();
41 41
 		$result = $this->object->create();
42 42
 
43
-		$this->assertContains( 'Prices', $result );
44
-		$this->assertNull( $this->view->get( 'errors' ) );
43
+		$this->assertContains('Prices', $result);
44
+		$this->assertNull($this->view->get('errors'));
45 45
 	}
46 46
 
47 47
 
48 48
 	public function testCopy()
49 49
 	{
50
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' );
50
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'product');
51 51
 
52
-		$this->view->item = $manager->findItem( 'CNC', array( 'price' ) );
52
+		$this->view->item = $manager->findItem('CNC', array('price'));
53 53
 		$result = $this->object->copy();
54 54
 
55
-		$this->assertNull( $this->view->get( 'errors' ) );
56
-		$this->assertContains( 'value="for 1 product"', $result );
55
+		$this->assertNull($this->view->get('errors'));
56
+		$this->assertContains('value="for 1 product"', $result);
57 57
 	}
58 58
 
59 59
 
@@ -61,123 +61,123 @@  discard block
 block discarded – undo
61 61
 	{
62 62
 		$result = $this->object->delete();
63 63
 
64
-		$this->assertNull( $this->view->get( 'errors' ) );
65
-		$this->assertNull( $result );
64
+		$this->assertNull($this->view->get('errors'));
65
+		$this->assertNull($result);
66 66
 	}
67 67
 
68 68
 
69 69
 	public function testGet()
70 70
 	{
71
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' );
71
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'product');
72 72
 
73
-		$this->view->item = $manager->findItem( 'CNC', array( 'price' ) );
73
+		$this->view->item = $manager->findItem('CNC', array('price'));
74 74
 		$result = $this->object->get();
75 75
 
76
-		$this->assertNull( $this->view->get( 'errors' ) );
77
-		$this->assertContains( 'value="for 1 product"', $result );
76
+		$this->assertNull($this->view->get('errors'));
77
+		$this->assertContains('value="for 1 product"', $result);
78 78
 	}
79 79
 
80 80
 
81 81
 	public function testSave()
82 82
 	{
83
-		$typeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'price/type' );
84
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' );
83
+		$typeManager = \Aimeos\MShop\Factory::createManager($this->context, 'price/type');
84
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'product');
85 85
 
86
-		$item = $manager->findItem( 'CNC' );
87
-		$item->setCode( 'jqadm-test-price' );
88
-		$item->setId( null );
86
+		$item = $manager->findItem('CNC');
87
+		$item->setCode('jqadm-test-price');
88
+		$item->setId(null);
89 89
 
90
-		$manager->saveItem( $item );
90
+		$manager->saveItem($item);
91 91
 
92 92
 
93 93
 		$param = array(
94 94
 			'price' => array(
95
-				'product.lists.id' => array( '' ),
96
-				'price.typeid' => array( $typeManager->findItem( 'default', array(), 'product' )->getId() ),
97
-				'price.currencyid' => array( 'EUR' ),
98
-				'price.label' => array( 'test' ),
99
-				'price.quantity' => array( '2' ),
100
-				'price.value' => array( '10.00' ),
101
-				'price.costs' => array( '1.00' ),
102
-				'price.rebate' => array( '5.00' ),
103
-				'price.taxrate' => array( '20.00' ),
95
+				'product.lists.id' => array(''),
96
+				'price.typeid' => array($typeManager->findItem('default', array(), 'product')->getId()),
97
+				'price.currencyid' => array('EUR'),
98
+				'price.label' => array('test'),
99
+				'price.quantity' => array('2'),
100
+				'price.value' => array('10.00'),
101
+				'price.costs' => array('1.00'),
102
+				'price.rebate' => array('5.00'),
103
+				'price.taxrate' => array('20.00'),
104 104
 			),
105 105
 		);
106 106
 
107
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $param );
108
-		$this->view->addHelper( 'param', $helper );
107
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $param);
108
+		$this->view->addHelper('param', $helper);
109 109
 		$this->view->item = $item;
110 110
 
111 111
 		$result = $this->object->save();
112 112
 
113
-		$item = $manager->getItem( $item->getId(), array( 'price' ) );
114
-		$manager->deleteItem( $item->getId() );
113
+		$item = $manager->getItem($item->getId(), array('price'));
114
+		$manager->deleteItem($item->getId());
115 115
 
116
-		$this->assertNull( $this->view->get( 'errors' ) );
117
-		$this->assertNull( $result );
118
-		$this->assertEquals( 1, count( $item->getListItems() ) );
116
+		$this->assertNull($this->view->get('errors'));
117
+		$this->assertNull($result);
118
+		$this->assertEquals(1, count($item->getListItems()));
119 119
 
120
-		foreach( $item->getListItems( 'price' ) as $listItem )
120
+		foreach ($item->getListItems('price') as $listItem)
121 121
 		{
122
-			$this->assertEquals( 'price', $listItem->getDomain() );
123
-			$this->assertEquals( 'default', $listItem->getType() );
122
+			$this->assertEquals('price', $listItem->getDomain());
123
+			$this->assertEquals('default', $listItem->getType());
124 124
 
125 125
 			$refItem = $listItem->getRefItem();
126
-			$this->assertEquals( 'default', $refItem->getType() );
127
-			$this->assertEquals( 'EUR', $refItem->getCurrencyId() );
128
-			$this->assertEquals( 'test', $refItem->getLabel() );
129
-			$this->assertEquals( '2', $refItem->getQuantity() );
130
-			$this->assertEquals( '10.00', $refItem->getValue() );
131
-			$this->assertEquals( '1.00', $refItem->getCosts() );
132
-			$this->assertEquals( '5.00', $refItem->getRebate() );
133
-			$this->assertEquals( '20.00', $refItem->getTaxRate() );
126
+			$this->assertEquals('default', $refItem->getType());
127
+			$this->assertEquals('EUR', $refItem->getCurrencyId());
128
+			$this->assertEquals('test', $refItem->getLabel());
129
+			$this->assertEquals('2', $refItem->getQuantity());
130
+			$this->assertEquals('10.00', $refItem->getValue());
131
+			$this->assertEquals('1.00', $refItem->getCosts());
132
+			$this->assertEquals('5.00', $refItem->getRebate());
133
+			$this->assertEquals('20.00', $refItem->getTaxRate());
134 134
 		}
135 135
 	}
136 136
 
137 137
 
138 138
 	public function testSaveException()
139 139
 	{
140
-		$object = $this->getMockBuilder( '\Aimeos\Admin\JQAdm\Product\Price\Standard' )
141
-			->setConstructorArgs( array( $this->context, \TestHelperJqadm::getTemplatePaths() ) )
142
-			->setMethods( array( 'updateItems' ) )
140
+		$object = $this->getMockBuilder('\Aimeos\Admin\JQAdm\Product\Price\Standard')
141
+			->setConstructorArgs(array($this->context, \TestHelperJqadm::getTemplatePaths()))
142
+			->setMethods(array('updateItems'))
143 143
 			->getMock();
144 144
 
145
-		$object->expects( $this->once() )->method( 'updateItems' )
146
-			->will( $this->throwException( new \Exception() ) );
145
+		$object->expects($this->once())->method('updateItems')
146
+			->will($this->throwException(new \Exception()));
147 147
 
148
-		$object->setView( \TestHelperJqadm::getView() );
148
+		$object->setView(\TestHelperJqadm::getView());
149 149
 
150
-		$this->setExpectedException( '\Aimeos\Admin\JQAdm\Exception' );
150
+		$this->setExpectedException('\Aimeos\Admin\JQAdm\Exception');
151 151
 		$object->save();
152 152
 	}
153 153
 
154 154
 
155 155
 	public function testSaveMShopException()
156 156
 	{
157
-		$object = $this->getMockBuilder( '\Aimeos\Admin\JQAdm\Product\Price\Standard' )
158
-			->setConstructorArgs( array( $this->context, \TestHelperJqadm::getTemplatePaths() ) )
159
-			->setMethods( array( 'updateItems' ) )
157
+		$object = $this->getMockBuilder('\Aimeos\Admin\JQAdm\Product\Price\Standard')
158
+			->setConstructorArgs(array($this->context, \TestHelperJqadm::getTemplatePaths()))
159
+			->setMethods(array('updateItems'))
160 160
 			->getMock();
161 161
 
162
-		$object->expects( $this->once() )->method( 'updateItems' )
163
-			->will( $this->throwException( new \Aimeos\MShop\Exception() ) );
162
+		$object->expects($this->once())->method('updateItems')
163
+			->will($this->throwException(new \Aimeos\MShop\Exception()));
164 164
 
165
-		$object->setView( \TestHelperJqadm::getView() );
165
+		$object->setView(\TestHelperJqadm::getView());
166 166
 
167
-		$this->setExpectedException( '\Aimeos\Admin\JQAdm\Exception' );
167
+		$this->setExpectedException('\Aimeos\Admin\JQAdm\Exception');
168 168
 		$object->save();
169 169
 	}
170 170
 
171 171
 
172 172
 	public function testSearch()
173 173
 	{
174
-		$this->assertNull( $this->object->search() );
174
+		$this->assertNull($this->object->search());
175 175
 	}
176 176
 
177 177
 
178 178
 	public function testGetSubClient()
179 179
 	{
180
-		$this->setExpectedException( '\Aimeos\Admin\JQAdm\Exception' );
181
-		$this->object->getSubClient( 'invalid' );
180
+		$this->setExpectedException('\Aimeos\Admin\JQAdm\Exception');
181
+		$this->object->getSubClient('invalid');
182 182
 	}
183 183
 }
Please login to merge, or discard this patch.
admin/jqadm/tests/Admin/JQAdm/Product/Stock/StandardTest.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -22,124 +22,124 @@
 block discarded – undo
22 22
 		$this->context = \TestHelperJqadm::getContext();
23 23
 		$templatePaths = \TestHelperJqadm::getTemplatePaths();
24 24
 
25
-		$this->object = new \Aimeos\Admin\JQAdm\Product\Stock\Standard( $this->context, $templatePaths );
26
-		$this->object->setView( $this->view );
25
+		$this->object = new \Aimeos\Admin\JQAdm\Product\Stock\Standard($this->context, $templatePaths);
26
+		$this->object->setView($this->view);
27 27
 	}
28 28
 
29 29
 
30 30
 	protected function tearDown()
31 31
 	{
32
-		unset( $this->object );
32
+		unset($this->object);
33 33
 	}
34 34
 
35 35
 
36 36
 	public function testCreate()
37 37
 	{
38
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' );
38
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'product');
39 39
 
40 40
 		$this->view->item = $manager->createItem();
41 41
 		$result = $this->object->create();
42 42
 
43
-		$this->assertNull( $this->view->get( 'errors' ) );
44
-		$this->assertStringStartsWith( '<div class="product-item-stock', $result );
43
+		$this->assertNull($this->view->get('errors'));
44
+		$this->assertStringStartsWith('<div class="product-item-stock', $result);
45 45
 	}
46 46
 
47 47
 
48 48
 	public function testCopy()
49 49
 	{
50
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' );
50
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'product');
51 51
 
52
-		$this->view->item = $manager->findItem( 'CNC' );
52
+		$this->view->item = $manager->findItem('CNC');
53 53
 		$result = $this->object->copy();
54 54
 
55
-		$this->assertNull( $this->view->get( 'errors' ) );
56
-		$this->assertContains( 'value="1200"', $result );
55
+		$this->assertNull($this->view->get('errors'));
56
+		$this->assertContains('value="1200"', $result);
57 57
 	}
58 58
 
59 59
 
60 60
 	public function testGet()
61 61
 	{
62
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' );
62
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'product');
63 63
 
64
-		$this->view->item = $manager->findItem( 'CNC' );
64
+		$this->view->item = $manager->findItem('CNC');
65 65
 		$result = $this->object->get();
66 66
 
67
-		$this->assertNull( $this->view->get( 'errors' ) );
68
-		$this->assertContains( 'value="1200"', $result );
67
+		$this->assertNull($this->view->get('errors'));
68
+		$this->assertContains('value="1200"', $result);
69 69
 	}
70 70
 
71 71
 
72 72
 	public function testSave()
73 73
 	{
74
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'product' );
75
-		$whManager = \Aimeos\MShop\Factory::createManager( $this->context, 'product/stock/warehouse' );
74
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'product');
75
+		$whManager = \Aimeos\MShop\Factory::createManager($this->context, 'product/stock/warehouse');
76 76
 
77
-		$item = $manager->findItem( 'CNC' );
78
-		$item->setCode( 'jqadm-test-stock' );
79
-		$item->setId( null );
77
+		$item = $manager->findItem('CNC');
78
+		$item->setCode('jqadm-test-stock');
79
+		$item->setId(null);
80 80
 
81
-		$manager->saveItem( $item );
81
+		$manager->saveItem($item);
82 82
 
83 83
 
84 84
 		$param = array(
85 85
 			'stock' => array(
86
-				'product.stock.id' => array( '' ),
87
-				'product.stock.warehouseid' => array( $whManager->findItem( 'default' )->getId() ),
88
-				'product.stock.dateback' => array( '2000-01-01 00:00:00' ),
89
-				'product.stock.stocklevel' => array( '-1' ),
86
+				'product.stock.id' => array(''),
87
+				'product.stock.warehouseid' => array($whManager->findItem('default')->getId()),
88
+				'product.stock.dateback' => array('2000-01-01 00:00:00'),
89
+				'product.stock.stocklevel' => array('-1'),
90 90
 			),
91 91
 		);
92 92
 
93
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $param );
94
-		$this->view->addHelper( 'param', $helper );
93
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $param);
94
+		$this->view->addHelper('param', $helper);
95 95
 		$this->view->item = $item;
96 96
 
97 97
 		$result = $this->object->save();
98 98
 
99
-		$manager->deleteItem( $item->getId() );
99
+		$manager->deleteItem($item->getId());
100 100
 
101
-		$this->assertNull( $this->view->get( 'errors' ) );
102
-		$this->assertNull( $result );
101
+		$this->assertNull($this->view->get('errors'));
102
+		$this->assertNull($result);
103 103
 	}
104 104
 
105 105
 
106 106
 	public function testSaveException()
107 107
 	{
108
-		$object = $this->getMockBuilder( '\Aimeos\Admin\JQAdm\Product\Stock\Standard' )
109
-			->setConstructorArgs( array( $this->context, \TestHelperJqadm::getTemplatePaths() ) )
110
-			->setMethods( array( 'updateItems' ) )
108
+		$object = $this->getMockBuilder('\Aimeos\Admin\JQAdm\Product\Stock\Standard')
109
+			->setConstructorArgs(array($this->context, \TestHelperJqadm::getTemplatePaths()))
110
+			->setMethods(array('updateItems'))
111 111
 			->getMock();
112 112
 
113
-		$object->expects( $this->once() )->method( 'updateItems' )
114
-			->will( $this->throwException( new \Exception() ) );
113
+		$object->expects($this->once())->method('updateItems')
114
+			->will($this->throwException(new \Exception()));
115 115
 
116
-		$object->setView( \TestHelperJqadm::getView() );
116
+		$object->setView(\TestHelperJqadm::getView());
117 117
 
118
-		$this->setExpectedException( '\Aimeos\Admin\JQAdm\Exception' );
118
+		$this->setExpectedException('\Aimeos\Admin\JQAdm\Exception');
119 119
 		$object->save();
120 120
 	}
121 121
 
122 122
 
123 123
 	public function testSaveMShopException()
124 124
 	{
125
-		$object = $this->getMockBuilder( '\Aimeos\Admin\JQAdm\Product\Stock\Standard' )
126
-			->setConstructorArgs( array( $this->context, \TestHelperJqadm::getTemplatePaths() ) )
127
-			->setMethods( array( 'updateItems' ) )
125
+		$object = $this->getMockBuilder('\Aimeos\Admin\JQAdm\Product\Stock\Standard')
126
+			->setConstructorArgs(array($this->context, \TestHelperJqadm::getTemplatePaths()))
127
+			->setMethods(array('updateItems'))
128 128
 			->getMock();
129 129
 
130
-		$object->expects( $this->once() )->method( 'updateItems' )
131
-			->will( $this->throwException( new \Aimeos\MShop\Exception() ) );
130
+		$object->expects($this->once())->method('updateItems')
131
+			->will($this->throwException(new \Aimeos\MShop\Exception()));
132 132
 
133
-		$object->setView( \TestHelperJqadm::getView() );
133
+		$object->setView(\TestHelperJqadm::getView());
134 134
 
135
-		$this->setExpectedException( '\Aimeos\Admin\JQAdm\Exception' );
135
+		$this->setExpectedException('\Aimeos\Admin\JQAdm\Exception');
136 136
 		$object->save();
137 137
 	}
138 138
 
139 139
 
140 140
 	public function testGetSubClient()
141 141
 	{
142
-		$this->setExpectedException( '\Aimeos\Admin\JQAdm\Exception' );
143
-		$this->object->getSubClient( 'invalid' );
142
+		$this->setExpectedException('\Aimeos\Admin\JQAdm\Exception');
143
+		$this->object->getSubClient('invalid');
144 144
 	}
145 145
 }
Please login to merge, or discard this patch.