Completed
Push — master ( 309746...ad59be )
by Aimeos
08:33
created
controller/frontend/src/Controller/Frontend/Product/Standard.php 1 patch
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -31,42 +31,42 @@  discard block
 block discarded – undo
31 31
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
32 32
 	 * @since 2017.03
33 33
 	 */
34
-	public function addFilterAttribute( \Aimeos\MW\Criteria\Iface $filter, array $attrIds, array $optIds, array $oneIds )
34
+	public function addFilterAttribute(\Aimeos\MW\Criteria\Iface $filter, array $attrIds, array $optIds, array $oneIds)
35 35
 	{
36
-		if( !empty( $attrIds ) )
36
+		if (!empty($attrIds))
37 37
 		{
38
-			$attrIds = $this->validateIds( $attrIds );
38
+			$attrIds = $this->validateIds($attrIds);
39 39
 
40
-			$func = $filter->createFunction( 'index.attributeaggregate', array( $attrIds ) );
40
+			$func = $filter->createFunction('index.attributeaggregate', array($attrIds));
41 41
 			$expr = array(
42
-				$filter->compare( '==', $func, count( $attrIds ) ),
42
+				$filter->compare('==', $func, count($attrIds)),
43 43
 				$filter->getConditions(),
44 44
 			);
45
-			$filter->setConditions( $filter->combine( '&&', $expr ) );
45
+			$filter->setConditions($filter->combine('&&', $expr));
46 46
 		}
47 47
 
48
-		if( !empty( $optIds ) )
48
+		if (!empty($optIds))
49 49
 		{
50
-			$optIds = $this->validateIds( $optIds );
50
+			$optIds = $this->validateIds($optIds);
51 51
 
52
-			$func = $filter->createFunction( 'index.attributeaggregate', array( $optIds ) );
52
+			$func = $filter->createFunction('index.attributeaggregate', array($optIds));
53 53
 			$expr = array(
54
-				$filter->compare( '>', $func, 0 ),
54
+				$filter->compare('>', $func, 0),
55 55
 				$filter->getConditions(),
56 56
 			);
57
-			$filter->setConditions( $filter->combine( '&&', $expr ) );
57
+			$filter->setConditions($filter->combine('&&', $expr));
58 58
 		}
59 59
 
60
-		foreach( $oneIds as $type => $list )
60
+		foreach ($oneIds as $type => $list)
61 61
 		{
62
-			if( ( $list = $this->validateIds( (array) $list ) ) !== [] )
62
+			if (($list = $this->validateIds((array) $list)) !== [])
63 63
 			{
64
-				$func = $filter->createFunction( 'index.attributeaggregate', array( $list ) );
64
+				$func = $filter->createFunction('index.attributeaggregate', array($list));
65 65
 				$expr = array(
66
-					$filter->compare( '>', $func, 0 ),
66
+					$filter->compare('>', $func, 0),
67 67
 					$filter->getConditions(),
68 68
 				);
69
-				$filter->setConditions( $filter->combine( '&&', $expr ) );
69
+				$filter->setConditions($filter->combine('&&', $expr));
70 70
 			}
71 71
 		}
72 72
 
@@ -86,38 +86,38 @@  discard block
 block discarded – undo
86 86
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
87 87
 	 * @since 2017.03
88 88
 	 */
89
-	public function addFilterCategory( \Aimeos\MW\Criteria\Iface $filter, $catId,
90
-		$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default' )
89
+	public function addFilterCategory(\Aimeos\MW\Criteria\Iface $filter, $catId,
90
+		$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default')
91 91
 	{
92
-		$catIds = ( !is_array( $catId ) ? explode( ',', $catId ) : $catId );
92
+		$catIds = (!is_array($catId) ? explode(',', $catId) : $catId);
93 93
 
94
-		if( $level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE )
94
+		if ($level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE)
95 95
 		{
96 96
 			$list = [];
97
-			$cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'catalog' );
97
+			$cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'catalog');
98 98
 
99
-			foreach( $catIds as $catId )
99
+			foreach ($catIds as $catId)
100 100
 			{
101
-				$tree = $cntl->getCatalogTree( $catId, [], $level );
102
-				$list = array_merge( $list, $this->getCatalogIdsFromTree( $tree ) );
101
+				$tree = $cntl->getCatalogTree($catId, [], $level);
102
+				$list = array_merge($list, $this->getCatalogIdsFromTree($tree));
103 103
 			}
104 104
 
105 105
 			$catIds = $list;
106 106
 		}
107 107
 
108
-		$expr = array( $filter->compare( '==', 'index.catalog.id', array_unique( $catIds ) ) );
108
+		$expr = array($filter->compare('==', 'index.catalog.id', array_unique($catIds)));
109 109
 		$expr[] = $filter->getConditions();
110 110
 
111
-		if( $sort === 'relevance' )
111
+		if ($sort === 'relevance')
112 112
 		{
113
-			$cmpfunc = $filter->createFunction( 'index.catalog.position', array( $listtype, $catIds ) );
114
-			$expr[] = $filter->compare( '>=', $cmpfunc, 0 );
113
+			$cmpfunc = $filter->createFunction('index.catalog.position', array($listtype, $catIds));
114
+			$expr[] = $filter->compare('>=', $cmpfunc, 0);
115 115
 
116
-			$sortfunc = $filter->createFunction( 'sort:index.catalog.position', array( $listtype, $catIds ) );
117
-			$filter->setSortations( array( $filter->sort( $direction, $sortfunc ) ) );
116
+			$sortfunc = $filter->createFunction('sort:index.catalog.position', array($listtype, $catIds));
117
+			$filter->setSortations(array($filter->sort($direction, $sortfunc)));
118 118
 		}
119 119
 
120
-		$filter->setConditions( $filter->combine( '&&', $expr ) );
120
+		$filter->setConditions($filter->combine('&&', $expr));
121 121
 
122 122
 		return $filter;
123 123
 	}
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
135 135
 	 * @since 2017.03
136 136
 	 */
137
-	public function addFilterText( \Aimeos\MW\Criteria\Iface $filter, $input, $sort = null, $direction = '+', $listtype = 'default' )
137
+	public function addFilterText(\Aimeos\MW\Criteria\Iface $filter, $input, $sort = null, $direction = '+', $listtype = 'default')
138 138
 	{
139 139
 		$langid = $this->getContext()->getLocale()->getLanguageId();
140
-		$cmpfunc = $filter->createFunction( 'index.text.relevance', array( $listtype, $langid, $input ) );
141
-		$expr = array( $filter->compare( '>', $cmpfunc, 0 ), $filter->getConditions() );
140
+		$cmpfunc = $filter->createFunction('index.text.relevance', array($listtype, $langid, $input));
141
+		$expr = array($filter->compare('>', $cmpfunc, 0), $filter->getConditions());
142 142
 
143
-		return $filter->setConditions( $filter->combine( '&&', $expr ) );
143
+		return $filter->setConditions($filter->combine('&&', $expr));
144 144
 	}
145 145
 
146 146
 
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
 	 * @return array Associative list of key values as key and the product count for this key as value
153 153
 	 * @since 2017.03
154 154
 	 */
155
-	public function aggregate( \Aimeos\MW\Criteria\Iface $filter, $key )
155
+	public function aggregate(\Aimeos\MW\Criteria\Iface $filter, $key)
156 156
 	{
157
-		return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->aggregate( $filter, $key );
157
+		return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->aggregate($filter, $key);
158 158
 	}
159 159
 
160 160
 
@@ -169,62 +169,62 @@  discard block
 block discarded – undo
169 169
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
170 170
 	 * @since 2017.03
171 171
 	 */
172
-	public function createFilter( $sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default' )
172
+	public function createFilter($sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default')
173 173
 	{
174 174
 		$sortations = [];
175 175
 		$context = $this->getContext();
176
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'index' );
176
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'index');
177 177
 
178 178
 
179
-		if( $context->getConfig()->get( 'controller/frontend/product/ignore-dates', false ) )
179
+		if ($context->getConfig()->get('controller/frontend/product/ignore-dates', false))
180 180
 		{
181 181
 			$search = $manager->createSearch();
182
-			$search->setConditions( $search->compare( '>', 'product.status', 0 ) );
182
+			$search->setConditions($search->compare('>', 'product.status', 0));
183 183
 		}
184 184
 		else
185 185
 		{
186
-			$search = $manager->createSearch( true );
186
+			$search = $manager->createSearch(true);
187 187
 		}
188 188
 
189 189
 
190
-		$expr = array( $search->compare( '!=', 'index.catalog.id', null ) );
190
+		$expr = array($search->compare('!=', 'index.catalog.id', null));
191 191
 
192
-		switch( $sort )
192
+		switch ($sort)
193 193
 		{
194 194
 			case 'code':
195
-				$sortations[] = $search->sort( $direction, 'product.code' );
195
+				$sortations[] = $search->sort($direction, 'product.code');
196 196
 				break;
197 197
 
198 198
 			case 'ctime':
199
-				$sortations[] = $search->sort( $direction, 'product.ctime' );
199
+				$sortations[] = $search->sort($direction, 'product.ctime');
200 200
 				break;
201 201
 
202 202
 			case 'name':
203 203
 				$langid = $context->getLocale()->getLanguageId();
204 204
 
205
-				$cmpfunc = $search->createFunction( 'index.text.value', array( $listtype, $langid, 'name', 'product' ) );
206
-				$expr[] = $search->compare( '>=', $cmpfunc, '' );
205
+				$cmpfunc = $search->createFunction('index.text.value', array($listtype, $langid, 'name', 'product'));
206
+				$expr[] = $search->compare('>=', $cmpfunc, '');
207 207
 
208
-				$sortfunc = $search->createFunction( 'sort:index.text.value', array( $listtype, $langid, 'name' ) );
209
-				$sortations[] = $search->sort( $direction, $sortfunc );
208
+				$sortfunc = $search->createFunction('sort:index.text.value', array($listtype, $langid, 'name'));
209
+				$sortations[] = $search->sort($direction, $sortfunc);
210 210
 				break;
211 211
 
212 212
 			case 'price':
213 213
 				$currencyid = $context->getLocale()->getCurrencyId();
214 214
 
215
-				$cmpfunc = $search->createFunction( 'index.price.value', array( $listtype, $currencyid, 'default' ) );
216
-				$expr[] = $search->compare( '>=', $cmpfunc, '0.00' );
215
+				$cmpfunc = $search->createFunction('index.price.value', array($listtype, $currencyid, 'default'));
216
+				$expr[] = $search->compare('>=', $cmpfunc, '0.00');
217 217
 
218
-				$sortfunc = $search->createFunction( 'sort:index.price.value', array( $listtype, $currencyid, 'default' ) );
219
-				$sortations[] = $search->sort( $direction, $sortfunc );
218
+				$sortfunc = $search->createFunction('sort:index.price.value', array($listtype, $currencyid, 'default'));
219
+				$sortations[] = $search->sort($direction, $sortfunc);
220 220
 				break;
221 221
 		}
222 222
 
223 223
 		$expr[] = $search->getConditions();
224 224
 
225
-		$search->setConditions( $search->combine( '&&', $expr ) );
226
-		$search->setSortations( $sortations );
227
-		$search->setSlice( $start, $size );
225
+		$search->setConditions($search->combine('&&', $expr));
226
+		$search->setSortations($sortations);
227
+		$search->setSlice($start, $size);
228 228
 
229 229
 		return $search;
230 230
 	}
@@ -238,15 +238,15 @@  discard block
 block discarded – undo
238 238
 	 * @return \Aimeos\MShop\Product\Item\Iface Product item including the referenced domains items
239 239
 	 * @since 2017.03
240 240
 	 */
241
-	public function getItem( $productId, array $domains = array( 'attribute', 'media', 'price', 'product', 'product/property', 'text' ) )
241
+	public function getItem($productId, array $domains = array('attribute', 'media', 'price', 'product', 'product/property', 'text'))
242 242
 	{
243
-		$items = $this->getItems( [$productId], $domains );
243
+		$items = $this->getItems([$productId], $domains);
244 244
 
245
-		if( ( $item = reset( $items ) ) !== false ) {
245
+		if (($item = reset($items)) !== false) {
246 246
 			return $item;
247 247
 		}
248 248
 
249
-		throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Product item with ID "%1$s" not found', $productId ) );
249
+		throw new \Aimeos\Controller\Frontend\Exception(sprintf('Product item with ID "%1$s" not found', $productId));
250 250
 	}
251 251
 
252 252
 
@@ -258,10 +258,10 @@  discard block
 block discarded – undo
258 258
 	 * @return \Aimeos\MShop\Product\Item\Iface[] Associative list of product IDs as keys and product items as values
259 259
 	 * @since 2017.03
260 260
 	 */
261
-	public function getItems( array $productIds, array $domains = array( 'media', 'price', 'text' ) )
261
+	public function getItems(array $productIds, array $domains = array('media', 'price', 'text'))
262 262
 	{
263 263
 		$context = $this->getContext();
264
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'product' );
264
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'product');
265 265
 
266 266
 		/** controller/frontend/order/ignore-dates
267 267
 		 * Ignore start and end dates of products
@@ -275,24 +275,24 @@  discard block
 block discarded – undo
275 275
 		 * @since 2017.08
276 276
 		 * @category Developer
277 277
 		 */
278
-		if( $context->getConfig()->get( 'controller/frontend/product/ignore-dates', false ) )
278
+		if ($context->getConfig()->get('controller/frontend/product/ignore-dates', false))
279 279
 		{
280 280
 			$search = $manager->createSearch();
281
-			$search->setConditions( $search->compare( '>', 'product.status', 0 ) );
281
+			$search->setConditions($search->compare('>', 'product.status', 0));
282 282
 		}
283 283
 		else
284 284
 		{
285
-			$search = $manager->createSearch( true );
285
+			$search = $manager->createSearch(true);
286 286
 		}
287 287
 
288 288
 		$expr = array(
289
-			$search->compare( '==', 'product.id', $productIds ),
289
+			$search->compare('==', 'product.id', $productIds),
290 290
 			$search->getConditions(),
291 291
 		);
292
-		$search->setConditions( $search->combine( '&&', $expr ) );
293
-		$search->setSlice( 0, count( $productIds ) );
292
+		$search->setConditions($search->combine('&&', $expr));
293
+		$search->setSlice(0, count($productIds));
294 294
 
295
-		return $manager->searchItems( $search, $domains );
295
+		return $manager->searchItems($search, $domains);
296 296
 	}
297 297
 
298 298
 
@@ -305,9 +305,9 @@  discard block
 block discarded – undo
305 305
 	 * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface
306 306
 	 * @since 2017.03
307 307
 	 */
308
-	public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null )
308
+	public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = array('media', 'price', 'text'), &$total = null)
309 309
 	{
310
-		return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->searchItems( $filter, $domains, $total );
310
+		return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->searchItems($filter, $domains, $total);
311 311
 	}
312 312
 
313 313
 
@@ -317,12 +317,12 @@  discard block
 block discarded – undo
317 317
 	 * @param \Aimeos\MShop\Catalog\Item\Iface $item Catalog item with children
318 318
 	 * @return array List of catalog IDs
319 319
 	 */
320
-	protected function getCatalogIdsFromTree( \Aimeos\MShop\Catalog\Item\Iface $item )
320
+	protected function getCatalogIdsFromTree(\Aimeos\MShop\Catalog\Item\Iface $item)
321 321
 	{
322
-		$list = array( $item->getId() );
322
+		$list = array($item->getId());
323 323
 
324
-		foreach( $item->getChildren() as $child ) {
325
-			$list = array_merge( $list, $this->getCatalogIdsFromTree( $child ) );
324
+		foreach ($item->getChildren() as $child) {
325
+			$list = array_merge($list, $this->getCatalogIdsFromTree($child));
326 326
 		}
327 327
 
328 328
 		return $list;
@@ -335,13 +335,13 @@  discard block
 block discarded – undo
335 335
 	 * @param array $ids List of IDs to validate
336 336
 	 * @return array List of validated IDs
337 337
 	 */
338
-	protected function validateIds( array $ids )
338
+	protected function validateIds(array $ids)
339 339
 	{
340 340
 		$list = [];
341 341
 
342
-		foreach( $ids as $id )
342
+		foreach ($ids as $id)
343 343
 		{
344
-			if( $id != '' ) {
344
+			if ($id != '') {
345 345
 				$list[] = (int) $id;
346 346
 			}
347 347
 		}
Please login to merge, or discard this patch.
controller/frontend/tests/Controller/Frontend/Product/StandardTest.php 1 patch
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -17,22 +17,22 @@  discard block
 block discarded – undo
17 17
 	protected function setUp()
18 18
 	{
19 19
 		$this->context = \TestHelperFrontend::getContext();
20
-		$this->object = new \Aimeos\Controller\Frontend\Product\Standard( $this->context );
20
+		$this->object = new \Aimeos\Controller\Frontend\Product\Standard($this->context);
21 21
 	}
22 22
 
23 23
 
24 24
 	protected function tearDown()
25 25
 	{
26
-		unset( $this->object );
26
+		unset($this->object);
27 27
 	}
28 28
 
29 29
 
30 30
 	public function testAggregate()
31 31
 	{
32 32
 		$filter = $this->object->createFilter();
33
-		$list = $this->object->aggregate( $filter, 'index.attribute.id' );
33
+		$list = $this->object->aggregate($filter, 'index.attribute.id');
34 34
 
35
-		$this->assertGreaterThan( 0, count( $list ) );
35
+		$this->assertGreaterThan(0, count($list));
36 36
 	}
37 37
 
38 38
 
@@ -40,113 +40,113 @@  discard block
 block discarded – undo
40 40
 	{
41 41
 		$filter = $this->object->createFilter();
42 42
 
43
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
44
-		$this->assertEquals( [], $filter->getSortations() );
45
-		$this->assertEquals( 0, $filter->getSliceStart() );
46
-		$this->assertEquals( 100, $filter->getSliceSize() );
43
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
44
+		$this->assertEquals([], $filter->getSortations());
45
+		$this->assertEquals(0, $filter->getSliceStart());
46
+		$this->assertEquals(100, $filter->getSliceSize());
47 47
 	}
48 48
 
49 49
 
50 50
 	public function testCreateFilterIgnoreDates()
51 51
 	{
52
-		$this->context->getConfig()->set( 'controller/frontend/product/ignore-dates', true );
52
+		$this->context->getConfig()->set('controller/frontend/product/ignore-dates', true);
53 53
 
54 54
 		$filter = $this->object->createFilter();
55 55
 
56
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
56
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
57 57
 	}
58 58
 
59 59
 
60 60
 	public function testAddFilterAttribute()
61 61
 	{
62 62
 		$filter = $this->object->createFilter();
63
-		$filter = $this->object->addFilterAttribute( $filter, array( 0, 1 ), [], [] );
63
+		$filter = $this->object->addFilterAttribute($filter, array(0, 1), [], []);
64 64
 
65 65
 		$list = $filter->getConditions()->getExpressions();
66 66
 
67
-		if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) {
68
-			throw new \RuntimeException( 'Wrong expression' );
67
+		if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) {
68
+			throw new \RuntimeException('Wrong expression');
69 69
 		}
70 70
 
71
-		$this->assertEquals( 'index.attributeaggregate([0,1])', $list[0]->getName() );
72
-		$this->assertEquals( 2, $list[0]->getValue() );
71
+		$this->assertEquals('index.attributeaggregate([0,1])', $list[0]->getName());
72
+		$this->assertEquals(2, $list[0]->getValue());
73 73
 	}
74 74
 
75 75
 
76 76
 	public function testAddFilterAttributeOptions()
77 77
 	{
78 78
 		$filter = $this->object->createFilter();
79
-		$filter = $this->object->addFilterAttribute( $filter, [], array( 1 ), [] );
79
+		$filter = $this->object->addFilterAttribute($filter, [], array(1), []);
80 80
 
81 81
 		$list = $filter->getConditions()->getExpressions();
82 82
 
83
-		if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) {
84
-			throw new \RuntimeException( 'Wrong expression' );
83
+		if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) {
84
+			throw new \RuntimeException('Wrong expression');
85 85
 		}
86 86
 
87
-		$this->assertEquals( 'index.attributeaggregate([1])', $list[0]->getName() );
88
-		$this->assertEquals( 0, $list[0]->getValue() );
87
+		$this->assertEquals('index.attributeaggregate([1])', $list[0]->getName());
88
+		$this->assertEquals(0, $list[0]->getValue());
89 89
 	}
90 90
 
91 91
 
92 92
 	public function testAddFilterAttributeOne()
93 93
 	{
94 94
 		$filter = $this->object->createFilter();
95
-		$filter = $this->object->addFilterAttribute( $filter, [], [], array( 'test' => array( 2 ) ) );
95
+		$filter = $this->object->addFilterAttribute($filter, [], [], array('test' => array(2)));
96 96
 
97 97
 		$list = $filter->getConditions()->getExpressions();
98 98
 
99
-		if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) {
100
-			throw new \RuntimeException( 'Wrong expression' );
99
+		if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) {
100
+			throw new \RuntimeException('Wrong expression');
101 101
 		}
102 102
 
103
-		$this->assertEquals( 'index.attributeaggregate([2])', $list[0]->getName() );
104
-		$this->assertEquals( 0, $list[0]->getValue() );
103
+		$this->assertEquals('index.attributeaggregate([2])', $list[0]->getName());
104
+		$this->assertEquals(0, $list[0]->getValue());
105 105
 	}
106 106
 
107 107
 
108 108
 	public function testAddFilterCategory()
109 109
 	{
110 110
 		$context = \TestHelperFrontend::getContext();
111
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'catalog' );
111
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'catalog');
112 112
 
113
-		$catId = $manager->findItem( 'root' )->getId();
113
+		$catId = $manager->findItem('root')->getId();
114 114
 		$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST;
115 115
 
116 116
 		$filter = $this->object->createFilter();
117
-		$filter = $this->object->addFilterCategory( $filter, $catId, $level );
117
+		$filter = $this->object->addFilterCategory($filter, $catId, $level);
118 118
 
119 119
 		$list = $filter->getConditions()->getExpressions();
120 120
 
121
-		if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) {
122
-			throw new \RuntimeException( 'Wrong expression' );
121
+		if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) {
122
+			throw new \RuntimeException('Wrong expression');
123 123
 		}
124 124
 
125
-		$this->assertEquals( 'index.catalog.id', $list[0]->getName() );
126
-		$this->assertEquals( 3, count( $list[0]->getValue() ) );
127
-		$this->assertEquals( [], $filter->getSortations() );
125
+		$this->assertEquals('index.catalog.id', $list[0]->getName());
126
+		$this->assertEquals(3, count($list[0]->getValue()));
127
+		$this->assertEquals([], $filter->getSortations());
128 128
 	}
129 129
 
130 130
 
131 131
 	public function testAddFilterText()
132 132
 	{
133 133
 		$filter = $this->object->createFilter();
134
-		$filter = $this->object->addFilterText( $filter, 'Espresso' );
134
+		$filter = $this->object->addFilterText($filter, 'Espresso');
135 135
 
136
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
136
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
137 137
 
138 138
 		$list = $filter->getConditions()->getExpressions();
139 139
 
140 140
 
141
-		if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) {
142
-			throw new \RuntimeException( 'Wrong expression' );
141
+		if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) {
142
+			throw new \RuntimeException('Wrong expression');
143 143
 		}
144
-		$this->assertEquals( 'index.text.relevance("default","de","Espresso")', $list[0]->getName() );
145
-		$this->assertEquals( 0, $list[0]->getValue() );
144
+		$this->assertEquals('index.text.relevance("default","de","Espresso")', $list[0]->getName());
145
+		$this->assertEquals(0, $list[0]->getValue());
146 146
 
147
-		$this->assertEquals( [], $filter->getSortations() );
148
-		$this->assertEquals( 0, $filter->getSliceStart() );
149
-		$this->assertEquals( 100, $filter->getSliceSize() );
147
+		$this->assertEquals([], $filter->getSortations());
148
+		$this->assertEquals(0, $filter->getSliceStart());
149
+		$this->assertEquals(100, $filter->getSliceSize());
150 150
 	}
151 151
 
152 152
 
@@ -155,177 +155,177 @@  discard block
 block discarded – undo
155 155
 		$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE;
156 156
 
157 157
 		$filter = $this->object->createFilter();
158
-		$filter = $this->object->addFilterCategory( $filter, 0, $level, 'relevance', '-', 'test' );
158
+		$filter = $this->object->addFilterCategory($filter, 0, $level, 'relevance', '-', 'test');
159 159
 
160
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
160
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
161 161
 
162 162
 		$sort = $filter->getSortations();
163
-		if( ( $item = reset( $sort ) ) === false ) {
164
-			throw new \RuntimeException( 'Sortation not set' );
163
+		if (($item = reset($sort)) === false) {
164
+			throw new \RuntimeException('Sortation not set');
165 165
 		}
166 166
 
167
-		$this->assertEquals( 'sort:index.catalog.position("test",["0"])', $item->getName() );
168
-		$this->assertEquals( '-', $item->getOperator() );
167
+		$this->assertEquals('sort:index.catalog.position("test",["0"])', $item->getName());
168
+		$this->assertEquals('-', $item->getOperator());
169 169
 	}
170 170
 
171 171
 
172 172
 	public function testCreateFilterSortRelevanceText()
173 173
 	{
174
-		$filter = $this->object->createFilter( 'relevance', '-', 1, 2, 'test' );
175
-		$filter = $this->object->addFilterText( $filter, 'Espresso' );
174
+		$filter = $this->object->createFilter('relevance', '-', 1, 2, 'test');
175
+		$filter = $this->object->addFilterText($filter, 'Espresso');
176 176
 
177
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
178
-		$this->assertEquals( [], $filter->getSortations() );
179
-		$this->assertEquals( 1, $filter->getSliceStart() );
180
-		$this->assertEquals( 2, $filter->getSliceSize() );
177
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
178
+		$this->assertEquals([], $filter->getSortations());
179
+		$this->assertEquals(1, $filter->getSliceStart());
180
+		$this->assertEquals(2, $filter->getSliceSize());
181 181
 	}
182 182
 
183 183
 
184 184
 	public function testCreateFilterSortCode()
185 185
 	{
186
-		$filter = $this->object->createFilter( 'code' );
186
+		$filter = $this->object->createFilter('code');
187 187
 
188
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
188
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
189 189
 
190 190
 		$sort = $filter->getSortations();
191
-		if( ( $item = reset( $sort ) ) === false ) {
192
-			throw new \RuntimeException( 'Sortation not set' );
191
+		if (($item = reset($sort)) === false) {
192
+			throw new \RuntimeException('Sortation not set');
193 193
 		}
194 194
 
195
-		$this->assertEquals( 'product.code', $item->getName() );
195
+		$this->assertEquals('product.code', $item->getName());
196 196
 	}
197 197
 
198 198
 
199 199
 	public function testCreateFilterSortCtime()
200 200
 	{
201
-		$filter = $this->object->createFilter( 'ctime' );
201
+		$filter = $this->object->createFilter('ctime');
202 202
 
203
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
203
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
204 204
 
205 205
 		$sort = $filter->getSortations();
206
-		if( ( $item = reset( $sort ) ) === false ) {
207
-			throw new \RuntimeException( 'Sortation not set' );
206
+		if (($item = reset($sort)) === false) {
207
+			throw new \RuntimeException('Sortation not set');
208 208
 		}
209 209
 
210
-		$this->assertEquals( 'product.ctime', $item->getName() );
210
+		$this->assertEquals('product.ctime', $item->getName());
211 211
 	}
212 212
 
213 213
 
214 214
 	public function testCreateFilterSortName()
215 215
 	{
216
-		$filter = $this->object->createFilter( 'name' );
216
+		$filter = $this->object->createFilter('name');
217 217
 
218
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
218
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
219 219
 
220 220
 		$sort = $filter->getSortations();
221
-		if( ( $item = reset( $sort ) ) === false ) {
222
-			throw new \RuntimeException( 'Sortation not set' );
221
+		if (($item = reset($sort)) === false) {
222
+			throw new \RuntimeException('Sortation not set');
223 223
 		}
224 224
 
225
-		$this->assertEquals( 'sort:index.text.value("default","de","name")', $item->getName() );
225
+		$this->assertEquals('sort:index.text.value("default","de","name")', $item->getName());
226 226
 	}
227 227
 
228 228
 
229 229
 	public function testCreateFilterSortPrice()
230 230
 	{
231
-		$filter = $this->object->createFilter( 'price' );
231
+		$filter = $this->object->createFilter('price');
232 232
 
233
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
233
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
234 234
 
235 235
 		$sort = $filter->getSortations();
236
-		if( ( $item = reset( $sort ) ) === false ) {
237
-			throw new \RuntimeException( 'Sortation not set' );
236
+		if (($item = reset($sort)) === false) {
237
+			throw new \RuntimeException('Sortation not set');
238 238
 		}
239 239
 
240
-		$this->assertStringStartsWith( 'sort:index.price.value("default","EUR","default")', $item->getName() );
240
+		$this->assertStringStartsWith('sort:index.price.value("default","EUR","default")', $item->getName());
241 241
 	}
242 242
 
243 243
 
244 244
 	public function testCreateFilterSortInvalid()
245 245
 	{
246
-		$filter = $this->object->createFilter( '', 'failure' );
246
+		$filter = $this->object->createFilter('', 'failure');
247 247
 
248
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
249
-		$this->assertEquals( [], $filter->getSortations() );
248
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
249
+		$this->assertEquals([], $filter->getSortations());
250 250
 	}
251 251
 
252 252
 
253 253
 	public function testGetItem()
254 254
 	{
255 255
 		$context = \TestHelperFrontend::getContext();
256
-		$id = \Aimeos\MShop\Factory::createManager( $context, 'product' )->findItem( 'CNC' )->getId();
256
+		$id = \Aimeos\MShop\Factory::createManager($context, 'product')->findItem('CNC')->getId();
257 257
 
258
-		$result = $this->object->getItem( $id );
258
+		$result = $this->object->getItem($id);
259 259
 
260
-		$this->assertInstanceOf( '\Aimeos\MShop\Product\Item\Iface', $result );
261
-		$this->assertGreaterThan( 0, $result->getPropertyItems() );
262
-		$this->assertGreaterThan( 0, $result->getRefItems( 'attribute' ) );
263
-		$this->assertGreaterThan( 0, $result->getRefItems( 'media' ) );
264
-		$this->assertGreaterThan( 0, $result->getRefItems( 'price' ) );
265
-		$this->assertGreaterThan( 0, $result->getRefItems( 'product' ) );
266
-		$this->assertGreaterThan( 0, $result->getRefItems( 'text' ) );
260
+		$this->assertInstanceOf('\Aimeos\MShop\Product\Item\Iface', $result);
261
+		$this->assertGreaterThan(0, $result->getPropertyItems());
262
+		$this->assertGreaterThan(0, $result->getRefItems('attribute'));
263
+		$this->assertGreaterThan(0, $result->getRefItems('media'));
264
+		$this->assertGreaterThan(0, $result->getRefItems('price'));
265
+		$this->assertGreaterThan(0, $result->getRefItems('product'));
266
+		$this->assertGreaterThan(0, $result->getRefItems('text'));
267 267
 	}
268 268
 
269 269
 
270 270
 	public function testGetItems()
271 271
 	{
272 272
 		$context = \TestHelperFrontend::getContext();
273
-		$context->getConfig()->set( 'controller/frontend/product/ignore-dates', true );
273
+		$context->getConfig()->set('controller/frontend/product/ignore-dates', true);
274 274
 
275
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'product' );
275
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'product');
276 276
 
277 277
 		$search = $manager->createSearch();
278
-		$search->setConditions( $search->compare( '==', 'product.code', array( 'CNC', 'CNE' ) ) );
278
+		$search->setConditions($search->compare('==', 'product.code', array('CNC', 'CNE')));
279 279
 
280 280
 		$ids = [];
281
-		foreach( $manager->searchItems( $search ) as $productItem ) {
281
+		foreach ($manager->searchItems($search) as $productItem) {
282 282
 			$ids[] = $productItem->getId();
283 283
 		}
284 284
 
285 285
 
286
-		$result = $this->object->getItems( $ids );
286
+		$result = $this->object->getItems($ids);
287 287
 
288
-		$this->assertEquals( 2, count( $result ) );
288
+		$this->assertEquals(2, count($result));
289 289
 
290
-		foreach( $result as $productItem ) {
291
-			$this->assertInstanceOf( '\Aimeos\MShop\Product\Item\Iface', $productItem );
290
+		foreach ($result as $productItem) {
291
+			$this->assertInstanceOf('\Aimeos\MShop\Product\Item\Iface', $productItem);
292 292
 		}
293 293
 	}
294 294
 
295 295
 
296 296
 	public function testSearchItemsCategory()
297 297
 	{
298
-		$catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( \TestHelperFrontend::getContext() );
298
+		$catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager(\TestHelperFrontend::getContext());
299 299
 		$search = $catalogManager->createSearch();
300 300
 
301
-		$search->setConditions( $search->compare( '==', 'catalog.code', 'new' ) );
302
-		$search->setSlice( 0, 1 );
303
-		$items = $catalogManager->searchItems( $search );
301
+		$search->setConditions($search->compare('==', 'catalog.code', 'new'));
302
+		$search->setSlice(0, 1);
303
+		$items = $catalogManager->searchItems($search);
304 304
 
305
-		if( ( $item = reset( $items ) ) === false ) {
306
-			throw new \RuntimeException( 'Product item not found' );
305
+		if (($item = reset($items)) === false) {
306
+			throw new \RuntimeException('Product item not found');
307 307
 		}
308 308
 
309
-		$filter = $this->object->createFilter( 'position', '+', 1, 1 );
310
-		$filter = $this->object->addFilterCategory( $filter, $item->getId() );
309
+		$filter = $this->object->createFilter('position', '+', 1, 1);
310
+		$filter = $this->object->addFilterCategory($filter, $item->getId());
311 311
 
312 312
 		$total = 0;
313
-		$results = $this->object->searchItems( $filter, [], $total );
313
+		$results = $this->object->searchItems($filter, [], $total);
314 314
 
315
-		$this->assertEquals( 3, $total );
316
-		$this->assertEquals( 1, count( $results ) );
315
+		$this->assertEquals(3, $total);
316
+		$this->assertEquals(1, count($results));
317 317
 	}
318 318
 
319 319
 
320 320
 	public function testSearchItemsText()
321 321
 	{
322
-		$filter = $this->object->createFilter( 'relevance', '+', 0, 1, 'unittype13' );
323
-		$filter = $this->object->addFilterText( $filter, 'Expresso', 'relevance', '+', 'unittype13' );
322
+		$filter = $this->object->createFilter('relevance', '+', 0, 1, 'unittype13');
323
+		$filter = $this->object->addFilterText($filter, 'Expresso', 'relevance', '+', 'unittype13');
324 324
 
325 325
 		$total = 0;
326
-		$results = $this->object->searchItems( $filter, [], $total );
326
+		$results = $this->object->searchItems($filter, [], $total);
327 327
 
328
-		$this->assertEquals( 2, $total );
329
-		$this->assertEquals( 1, count( $results ) );
328
+		$this->assertEquals(2, $total);
329
+		$this->assertEquals(1, count($results));
330 330
 	}
331 331
 }
Please login to merge, or discard this patch.