Completed
Push — master ( a59c24...27cf3f )
by Aimeos
02:28
created
controller/frontend/src/Controller/Frontend/Index/Standard.php 2 patches
Doc Comments   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -80,6 +80,7 @@  discard block
 block discarded – undo
80 80
 	 * @param \Aimeos\MW\Criteria\Iface $filter Criteria object used for product search
81 81
 	 * @param string|array $catId Selected category by the user
82 82
 	 * @param integer $level Constant for current category only, categories of next level (LEVEL_LIST) or whole subtree (LEVEL_SUBTREE)
83
+	 * @param string $sort
83 84
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
84 85
 	 * @since 2017.03
85 86
 	 */
@@ -263,6 +264,7 @@  discard block
 block discarded – undo
263 264
 	 * @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions
264 265
 	 * @param string[] $domains Domain names of items that are associated with the products and that should be fetched too
265 266
 	 * @param integer &$total Parameter where the total number of found products will be stored in
267
+	 * @param integer $total
266 268
 	 * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface
267 269
 	 * @since 2017.03
268 270
 	 */
@@ -288,7 +290,7 @@  discard block
 block discarded – undo
288 290
 	 * Returns the list of catalog IDs for the given catalog tree
289 291
 	 *
290 292
 	 * @param \Aimeos\MShop\Catalog\Item\Iface $item Catalog item with children
291
-	 * @return array List of catalog IDs
293
+	 * @return integer[] List of catalog IDs
292 294
 	 */
293 295
 	protected function getCatalogIdsFromTree( \Aimeos\MShop\Catalog\Item\Iface $item )
294 296
 	{
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 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 ) ) !== array() )
62
+			if (($list = $this->validateIds((array) $list)) !== array())
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
 
@@ -83,38 +83,38 @@  discard block
 block discarded – undo
83 83
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
84 84
 	 * @since 2017.03
85 85
 	 */
86
-	public function addFilterCategory( \Aimeos\MW\Criteria\Iface $filter, $catId,
87
-		$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default' )
86
+	public function addFilterCategory(\Aimeos\MW\Criteria\Iface $filter, $catId,
87
+		$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default')
88 88
 	{
89
-		$catIds = ( !is_array( $catId ) ? explode( ',', $catId ) : $catId );
89
+		$catIds = (!is_array($catId) ? explode(',', $catId) : $catId);
90 90
 
91
-		if( $level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE )
91
+		if ($level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE)
92 92
 		{
93 93
 			$list = array();
94
-			$cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'catalog' );
94
+			$cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'catalog');
95 95
 
96
-			foreach( $catIds as $catId )
96
+			foreach ($catIds as $catId)
97 97
 			{
98
-				$tree = $cntl->getCatalogTree( $catId, array(), $level );
99
-				$list = array_merge( $list, $this->getCatalogIdsFromTree( $tree ) );
98
+				$tree = $cntl->getCatalogTree($catId, array(), $level);
99
+				$list = array_merge($list, $this->getCatalogIdsFromTree($tree));
100 100
 			}
101 101
 
102 102
 			$catIds = $list;
103 103
 		}
104 104
 
105
-		$expr = array( $filter->compare( '==', 'index.catalog.id', array_unique( $catIds ) ) );
105
+		$expr = array($filter->compare('==', 'index.catalog.id', array_unique($catIds)));
106 106
 		$expr[] = $filter->getConditions();
107 107
 
108
-		if( $sort === 'relevance' )
108
+		if ($sort === 'relevance')
109 109
 		{
110
-			$cmpfunc = $filter->createFunction( 'index.catalog.position', array( $listtype, $catIds ) );
111
-			$expr[] = $filter->compare( '>=', $cmpfunc, 0 );
110
+			$cmpfunc = $filter->createFunction('index.catalog.position', array($listtype, $catIds));
111
+			$expr[] = $filter->compare('>=', $cmpfunc, 0);
112 112
 
113
-			$sortfunc = $filter->createFunction( 'sort:index.catalog.position', array( $listtype, $catIds ) );
114
-			$filter->setSortations( array( $filter->sort( $direction, $sortfunc ) ) );
113
+			$sortfunc = $filter->createFunction('sort:index.catalog.position', array($listtype, $catIds));
114
+			$filter->setSortations(array($filter->sort($direction, $sortfunc)));
115 115
 		}
116 116
 
117
-		$filter->setConditions( $filter->combine( '&&', $expr ) );
117
+		$filter->setConditions($filter->combine('&&', $expr));
118 118
 
119 119
 		return $filter;
120 120
 	}
@@ -129,13 +129,13 @@  discard block
 block discarded – undo
129 129
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
130 130
 	 * @since 2017.03
131 131
 	 */
132
-	public function addFilterText( \Aimeos\MW\Criteria\Iface $filter, $input, $listtype = 'default' )
132
+	public function addFilterText(\Aimeos\MW\Criteria\Iface $filter, $input, $listtype = 'default')
133 133
 	{
134 134
 		$langid = $this->getContext()->getLocale()->getLanguageId();
135
-		$cmpfunc = $filter->createFunction( 'index.text.relevance', array( $listtype, $langid, $input ) );
136
-		$expr = array( $filter->compare( '>', $cmpfunc, 0 ), $filter->getConditions() );
135
+		$cmpfunc = $filter->createFunction('index.text.relevance', array($listtype, $langid, $input));
136
+		$expr = array($filter->compare('>', $cmpfunc, 0), $filter->getConditions());
137 137
 
138
-		return $filter->setConditions( $filter->combine( '&&', $expr ) );
138
+		return $filter->setConditions($filter->combine('&&', $expr));
139 139
 	}
140 140
 
141 141
 
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
 	 * @return array Associative list of key values as key and the product count for this key as value
148 148
 	 * @since 2017.03
149 149
 	 */
150
-	public function aggregate( \Aimeos\MW\Criteria\Iface $filter, $key )
150
+	public function aggregate(\Aimeos\MW\Criteria\Iface $filter, $key)
151 151
 	{
152
-		return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->aggregate( $filter, $key );
152
+		return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->aggregate($filter, $key);
153 153
 	}
154 154
 
155 155
 
@@ -164,46 +164,46 @@  discard block
 block discarded – undo
164 164
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
165 165
 	 * @since 2017.03
166 166
 	 */
167
-	public function createFilter( $sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default' )
167
+	public function createFilter($sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default')
168 168
 	{
169 169
 		$sortations = array();
170 170
 		$context = $this->getContext();
171 171
 
172
-		$search = \Aimeos\MShop\Factory::createManager( $context, 'index' )->createSearch( true );
173
-		$expr = array( $search->compare( '!=', 'index.catalog.id', null ) );
172
+		$search = \Aimeos\MShop\Factory::createManager($context, 'index')->createSearch(true);
173
+		$expr = array($search->compare('!=', 'index.catalog.id', null));
174 174
 
175
-		switch( $sort )
175
+		switch ($sort)
176 176
 		{
177 177
 			case 'code':
178
-				$sortations[] = $search->sort( $direction, 'product.code' );
178
+				$sortations[] = $search->sort($direction, 'product.code');
179 179
 				break;
180 180
 
181 181
 			case 'name':
182 182
 				$langid = $context->getLocale()->getLanguageId();
183 183
 
184
-				$cmpfunc = $search->createFunction( 'index.text.value', array( $listtype, $langid, 'name', 'product' ) );
185
-				$expr[] = $search->compare( '>=', $cmpfunc, '' );
184
+				$cmpfunc = $search->createFunction('index.text.value', array($listtype, $langid, 'name', 'product'));
185
+				$expr[] = $search->compare('>=', $cmpfunc, '');
186 186
 
187
-				$sortfunc = $search->createFunction( 'sort:index.text.value', array( $listtype, $langid, 'name' ) );
188
-				$sortations[] = $search->sort( $direction, $sortfunc );
187
+				$sortfunc = $search->createFunction('sort:index.text.value', array($listtype, $langid, 'name'));
188
+				$sortations[] = $search->sort($direction, $sortfunc);
189 189
 				break;
190 190
 
191 191
 			case 'price':
192 192
 				$currencyid = $context->getLocale()->getCurrencyId();
193 193
 
194
-				$cmpfunc = $search->createFunction( 'index.price.value', array( $listtype, $currencyid, 'default' ) );
195
-				$expr[] = $search->compare( '>=', $cmpfunc, '0.00' );
194
+				$cmpfunc = $search->createFunction('index.price.value', array($listtype, $currencyid, 'default'));
195
+				$expr[] = $search->compare('>=', $cmpfunc, '0.00');
196 196
 
197
-				$sortfunc = $search->createFunction( 'sort:index.price.value', array( $listtype, $currencyid, 'default' ) );
198
-				$sortations[] = $search->sort( $direction, $sortfunc );
197
+				$sortfunc = $search->createFunction('sort:index.price.value', array($listtype, $currencyid, 'default'));
198
+				$sortations[] = $search->sort($direction, $sortfunc);
199 199
 				break;
200 200
 		}
201 201
 
202 202
 		$expr[] = $search->getConditions();
203 203
 
204
-		$search->setConditions( $search->combine( '&&', $expr ) );
205
-		$search->setSortations( $sortations );
206
-		$search->setSlice( $start, $size );
204
+		$search->setConditions($search->combine('&&', $expr));
205
+		$search->setSortations($sortations);
206
+		$search->setSlice($start, $size);
207 207
 
208 208
 		return $search;
209 209
 	}
@@ -221,37 +221,37 @@  discard block
 block discarded – undo
221 221
 	 * @param string $type Type of the text like "name", "short", "long", etc.
222 222
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
223 223
 	 */
224
-	public function createTextFilter( $input, $sort = null, $direction = '+', $start = 0, $size = 25, $listtype = 'default', $type = 'name' )
224
+	public function createTextFilter($input, $sort = null, $direction = '+', $start = 0, $size = 25, $listtype = 'default', $type = 'name')
225 225
 	{
226 226
 		$locale = $this->getContext()->getLocale();
227 227
 		$langid = $locale->getLanguageId();
228 228
 
229
-		$search = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index/text' )->createSearch( true );
229
+		$search = \Aimeos\MShop\Factory::createManager($this->getContext(), 'index/text')->createSearch(true);
230 230
 
231 231
 		$expr = array(
232
-			$search->compare( '>', $search->createFunction( 'index.text.relevance', array( $listtype, $langid, $input ) ), 0 ),
233
-			$search->compare( '>', $search->createFunction( 'index.text.value', array( $listtype, $langid, $type, 'product' ) ), '' ),
232
+			$search->compare('>', $search->createFunction('index.text.relevance', array($listtype, $langid, $input)), 0),
233
+			$search->compare('>', $search->createFunction('index.text.value', array($listtype, $langid, $type, 'product')), ''),
234 234
 		);
235 235
 
236 236
 		$sortations = array();
237 237
 
238
-		switch( $sort )
238
+		switch ($sort)
239 239
 		{
240 240
 			case 'name':
241
-				$cmpfunc = $search->createFunction( 'index.text.value', array( $listtype, $langid, 'name', 'product' ) );
242
-				$expr[] = $search->compare( '>=', $cmpfunc, '' );
241
+				$cmpfunc = $search->createFunction('index.text.value', array($listtype, $langid, 'name', 'product'));
242
+				$expr[] = $search->compare('>=', $cmpfunc, '');
243 243
 
244
-				$sortfunc = $search->createFunction( 'sort:index.text.value', array( $listtype, $langid, 'name' ) );
245
-				$sortations[] = $search->sort( $direction, $sortfunc );
244
+				$sortfunc = $search->createFunction('sort:index.text.value', array($listtype, $langid, 'name'));
245
+				$sortations[] = $search->sort($direction, $sortfunc);
246 246
 				break;
247 247
 
248 248
 			case 'relevance':
249 249
 				// we don't need to sort by 'sort:index.text.relevance' because it's a boolean match (relevance is either 0 or 1)
250 250
 		}
251 251
 
252
-		$search->setConditions( $search->combine( '&&', $expr ) );
253
-		$search->setSortations( $sortations );
254
-		$search->setSlice( $start, $size );
252
+		$search->setConditions($search->combine('&&', $expr));
253
+		$search->setSortations($sortations);
254
+		$search->setSlice($start, $size);
255 255
 
256 256
 		return $search;
257 257
 	}
@@ -266,9 +266,9 @@  discard block
 block discarded – undo
266 266
 	 * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface
267 267
 	 * @since 2017.03
268 268
 	 */
269
-	public function getItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null )
269
+	public function getItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = array('media', 'price', 'text'), &$total = null)
270 270
 	{
271
-		return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->searchItems( $filter, $domains, $total );
271
+		return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->searchItems($filter, $domains, $total);
272 272
 	}
273 273
 
274 274
 
@@ -278,9 +278,9 @@  discard block
 block discarded – undo
278 278
 	 * @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions
279 279
 	 * @return array Associative list of the product ID as key and the product text as value
280 280
 	 */
281
-	public function getTextList( \Aimeos\MW\Criteria\Iface $filter )
281
+	public function getTextList(\Aimeos\MW\Criteria\Iface $filter)
282 282
 	{
283
-		return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index/text' )->searchTexts( $filter );
283
+		return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index/text')->searchTexts($filter);
284 284
 	}
285 285
 
286 286
 
@@ -290,12 +290,12 @@  discard block
 block discarded – undo
290 290
 	 * @param \Aimeos\MShop\Catalog\Item\Iface $item Catalog item with children
291 291
 	 * @return array List of catalog IDs
292 292
 	 */
293
-	protected function getCatalogIdsFromTree( \Aimeos\MShop\Catalog\Item\Iface $item )
293
+	protected function getCatalogIdsFromTree(\Aimeos\MShop\Catalog\Item\Iface $item)
294 294
 	{
295
-		$list = array( $item->getId() );
295
+		$list = array($item->getId());
296 296
 
297
-		foreach( $item->getChildren() as $child ) {
298
-			$list = array_merge( $list, $this->getCatalogIdsFromTree( $child ) );
297
+		foreach ($item->getChildren() as $child) {
298
+			$list = array_merge($list, $this->getCatalogIdsFromTree($child));
299 299
 		}
300 300
 
301 301
 		return $list;
@@ -308,13 +308,13 @@  discard block
 block discarded – undo
308 308
 	 * @param array $ids List of IDs to validate
309 309
 	 * @return array List of validated IDs
310 310
 	 */
311
-	protected function validateIds( array $ids )
311
+	protected function validateIds(array $ids)
312 312
 	{
313 313
 		$list = array();
314 314
 
315
-		foreach( $ids as $id )
315
+		foreach ($ids as $id)
316 316
 		{
317
-			if( $id != '' ) {
317
+			if ($id != '') {
318 318
 				$list[] = (int) $id;
319 319
 			}
320 320
 		}
Please login to merge, or discard this patch.
controller/frontend/tests/Controller/Frontend/Index/StandardTest.php 1 patch
Spacing   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -16,22 +16,22 @@  discard block
 block discarded – undo
16 16
 
17 17
 	protected function setUp()
18 18
 	{
19
-		$this->object = new \Aimeos\Controller\Frontend\Index\Standard( \TestHelperFrontend::getContext() );
19
+		$this->object = new \Aimeos\Controller\Frontend\Index\Standard(\TestHelperFrontend::getContext());
20 20
 	}
21 21
 
22 22
 
23 23
 	protected function tearDown()
24 24
 	{
25
-		unset( $this->object );
25
+		unset($this->object);
26 26
 	}
27 27
 
28 28
 
29 29
 	public function testAggregate()
30 30
 	{
31 31
 		$filter = $this->object->createFilter();
32
-		$list = $this->object->aggregate( $filter, 'index.attribute.id' );
32
+		$list = $this->object->aggregate($filter, 'index.attribute.id');
33 33
 
34
-		$this->assertGreaterThan( 0, count( $list ) );
34
+		$this->assertGreaterThan(0, count($list));
35 35
 	}
36 36
 
37 37
 
@@ -39,97 +39,97 @@  discard block
 block discarded – undo
39 39
 	{
40 40
 		$filter = $this->object->createFilter();
41 41
 
42
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
43
-		$this->assertEquals( array(), $filter->getSortations() );
44
-		$this->assertEquals( 0, $filter->getSliceStart() );
45
-		$this->assertEquals( 100, $filter->getSliceSize() );
42
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
43
+		$this->assertEquals(array(), $filter->getSortations());
44
+		$this->assertEquals(0, $filter->getSliceStart());
45
+		$this->assertEquals(100, $filter->getSliceSize());
46 46
 	}
47 47
 
48 48
 
49 49
 	public function testAddFilterAttribute()
50 50
 	{
51 51
 		$filter = $this->object->createFilter();
52
-		$filter = $this->object->addFilterAttribute( $filter, array( 0, 1 ), array(), array() );
52
+		$filter = $this->object->addFilterAttribute($filter, array(0, 1), array(), array());
53 53
 
54 54
 		$list = $filter->getConditions()->getExpressions();
55 55
 
56
-		if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) {
57
-			throw new \RuntimeException( 'Wrong expression' );
56
+		if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) {
57
+			throw new \RuntimeException('Wrong expression');
58 58
 		}
59 59
 
60
-		$this->assertEquals( 'index.attributeaggregate([0,1])', $list[0]->getName() );
61
-		$this->assertEquals( 2, $list[0]->getValue() );
60
+		$this->assertEquals('index.attributeaggregate([0,1])', $list[0]->getName());
61
+		$this->assertEquals(2, $list[0]->getValue());
62 62
 	}
63 63
 
64 64
 
65 65
 	public function testAddFilterAttributeOptions()
66 66
 	{
67 67
 		$filter = $this->object->createFilter();
68
-		$filter = $this->object->addFilterAttribute( $filter, array(), array( 1 ), array() );
68
+		$filter = $this->object->addFilterAttribute($filter, array(), array(1), array());
69 69
 
70 70
 		$list = $filter->getConditions()->getExpressions();
71 71
 
72
-		if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) {
73
-			throw new \RuntimeException( 'Wrong expression' );
72
+		if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) {
73
+			throw new \RuntimeException('Wrong expression');
74 74
 		}
75 75
 
76
-		$this->assertEquals( 'index.attributeaggregate([1])', $list[0]->getName() );
77
-		$this->assertEquals( 0, $list[0]->getValue() );
76
+		$this->assertEquals('index.attributeaggregate([1])', $list[0]->getName());
77
+		$this->assertEquals(0, $list[0]->getValue());
78 78
 	}
79 79
 
80 80
 
81 81
 	public function testAddFilterAttributeOne()
82 82
 	{
83 83
 		$filter = $this->object->createFilter();
84
-		$filter = $this->object->addFilterAttribute( $filter, array(), array(), array( 'test' => array( 2 ) ) );
84
+		$filter = $this->object->addFilterAttribute($filter, array(), array(), array('test' => array(2)));
85 85
 
86 86
 		$list = $filter->getConditions()->getExpressions();
87 87
 
88
-		if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) {
89
-			throw new \RuntimeException( 'Wrong expression' );
88
+		if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) {
89
+			throw new \RuntimeException('Wrong expression');
90 90
 		}
91 91
 
92
-		$this->assertEquals( 'index.attributeaggregate([2])', $list[0]->getName() );
93
-		$this->assertEquals( 0, $list[0]->getValue() );
92
+		$this->assertEquals('index.attributeaggregate([2])', $list[0]->getName());
93
+		$this->assertEquals(0, $list[0]->getValue());
94 94
 	}
95 95
 
96 96
 
97 97
 	public function testAddFilterCategory()
98 98
 	{
99 99
 		$filter = $this->object->createFilter();
100
-		$filter = $this->object->addFilterCategory( $filter, 0 );
100
+		$filter = $this->object->addFilterCategory($filter, 0);
101 101
 
102 102
 		$list = $filter->getConditions()->getExpressions();
103 103
 
104
-		if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) {
105
-			throw new \RuntimeException( 'Wrong expression' );
104
+		if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) {
105
+			throw new \RuntimeException('Wrong expression');
106 106
 		}
107 107
 
108
-		$this->assertEquals( 'index.catalog.id', $list[0]->getName() );
109
-		$this->assertEquals( array( 0 ), $list[0]->getValue() );
110
-		$this->assertEquals( array(), $filter->getSortations() );
108
+		$this->assertEquals('index.catalog.id', $list[0]->getName());
109
+		$this->assertEquals(array(0), $list[0]->getValue());
110
+		$this->assertEquals(array(), $filter->getSortations());
111 111
 	}
112 112
 
113 113
 
114 114
 	public function testAddFilterText()
115 115
 	{
116 116
 		$filter = $this->object->createFilter();
117
-		$filter = $this->object->addFilterText( $filter, 'Espresso' );
117
+		$filter = $this->object->addFilterText($filter, 'Espresso');
118 118
 
119
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
119
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
120 120
 
121 121
 		$list = $filter->getConditions()->getExpressions();
122 122
 
123 123
 
124
-		if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) {
125
-			throw new \RuntimeException( 'Wrong expression' );
124
+		if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) {
125
+			throw new \RuntimeException('Wrong expression');
126 126
 		}
127
-		$this->assertEquals( 'index.text.relevance("default","de","Espresso")', $list[0]->getName() );
128
-		$this->assertEquals( 0, $list[0]->getValue() );
127
+		$this->assertEquals('index.text.relevance("default","de","Espresso")', $list[0]->getName());
128
+		$this->assertEquals(0, $list[0]->getValue());
129 129
 
130
-		$this->assertEquals( array(), $filter->getSortations() );
131
-		$this->assertEquals( 0, $filter->getSliceStart() );
132
-		$this->assertEquals( 100, $filter->getSliceSize() );
130
+		$this->assertEquals(array(), $filter->getSortations());
131
+		$this->assertEquals(0, $filter->getSliceStart());
132
+		$this->assertEquals(100, $filter->getSliceSize());
133 133
 	}
134 134
 
135 135
 
@@ -138,140 +138,140 @@  discard block
 block discarded – undo
138 138
 		$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE;
139 139
 
140 140
 		$filter = $this->object->createFilter();
141
-		$filter = $this->object->addFilterCategory( $filter, 0, $level, 'relevance', '-', 'test' );
141
+		$filter = $this->object->addFilterCategory($filter, 0, $level, 'relevance', '-', 'test');
142 142
 
143
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
143
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
144 144
 
145 145
 		$sort = $filter->getSortations();
146
-		if( ( $item = reset( $sort ) ) === false ) {
147
-			throw new \RuntimeException( 'Sortation not set' );
146
+		if (($item = reset($sort)) === false) {
147
+			throw new \RuntimeException('Sortation not set');
148 148
 		}
149 149
 
150
-		$this->assertEquals( 'sort:index.catalog.position("test",["0"])', $item->getName() );
151
-		$this->assertEquals( '-', $item->getOperator() );
150
+		$this->assertEquals('sort:index.catalog.position("test",["0"])', $item->getName());
151
+		$this->assertEquals('-', $item->getOperator());
152 152
 	}
153 153
 
154 154
 
155 155
 	public function testCreateFilterSortRelevanceText()
156 156
 	{
157
-		$filter = $this->object->createFilter( 'relevance', '-', 1, 2, 'test' );
158
-		$filter = $this->object->addFilterText( $filter, 'Espresso' );
157
+		$filter = $this->object->createFilter('relevance', '-', 1, 2, 'test');
158
+		$filter = $this->object->addFilterText($filter, 'Espresso');
159 159
 
160
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
161
-		$this->assertEquals( array(), $filter->getSortations() );
162
-		$this->assertEquals( 1, $filter->getSliceStart() );
163
-		$this->assertEquals( 2, $filter->getSliceSize() );
160
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
161
+		$this->assertEquals(array(), $filter->getSortations());
162
+		$this->assertEquals(1, $filter->getSliceStart());
163
+		$this->assertEquals(2, $filter->getSliceSize());
164 164
 	}
165 165
 
166 166
 
167 167
 	public function testCreateFilterSortCode()
168 168
 	{
169
-		$filter = $this->object->createFilter( 'code' );
169
+		$filter = $this->object->createFilter('code');
170 170
 
171
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
171
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
172 172
 
173 173
 		$sort = $filter->getSortations();
174
-		if( ( $item = reset( $sort ) ) === false ) {
175
-			throw new \RuntimeException( 'Sortation not set' );
174
+		if (($item = reset($sort)) === false) {
175
+			throw new \RuntimeException('Sortation not set');
176 176
 		}
177 177
 
178
-		$this->assertEquals( 'product.code', $item->getName() );
178
+		$this->assertEquals('product.code', $item->getName());
179 179
 	}
180 180
 
181 181
 
182 182
 	public function testCreateFilterSortName()
183 183
 	{
184
-		$filter = $this->object->createFilter( 'name' );
184
+		$filter = $this->object->createFilter('name');
185 185
 
186
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
186
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
187 187
 
188 188
 		$sort = $filter->getSortations();
189
-		if( ( $item = reset( $sort ) ) === false ) {
190
-			throw new \RuntimeException( 'Sortation not set' );
189
+		if (($item = reset($sort)) === false) {
190
+			throw new \RuntimeException('Sortation not set');
191 191
 		}
192 192
 
193
-		$this->assertEquals( 'sort:index.text.value("default","de","name")', $item->getName() );
193
+		$this->assertEquals('sort:index.text.value("default","de","name")', $item->getName());
194 194
 	}
195 195
 
196 196
 
197 197
 	public function testCreateFilterSortPrice()
198 198
 	{
199
-		$filter = $this->object->createFilter( 'price' );
199
+		$filter = $this->object->createFilter('price');
200 200
 
201
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
201
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
202 202
 
203 203
 		$sort = $filter->getSortations();
204
-		if( ( $item = reset( $sort ) ) === false ) {
205
-			throw new \RuntimeException( 'Sortation not set' );
204
+		if (($item = reset($sort)) === false) {
205
+			throw new \RuntimeException('Sortation not set');
206 206
 		}
207 207
 
208
-		$this->assertStringStartsWith( 'sort:index.price.value("default","EUR","default")', $item->getName() );
208
+		$this->assertStringStartsWith('sort:index.price.value("default","EUR","default")', $item->getName());
209 209
 	}
210 210
 
211 211
 
212 212
 	public function testCreateFilterSortInvalid()
213 213
 	{
214
-		$filter = $this->object->createFilter( '', 'failure' );
214
+		$filter = $this->object->createFilter('', 'failure');
215 215
 
216
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
217
-		$this->assertEquals( array(), $filter->getSortations() );
216
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
217
+		$this->assertEquals(array(), $filter->getSortations());
218 218
 	}
219 219
 
220 220
 
221 221
 	public function testGetItemsCategory()
222 222
 	{
223
-		$catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( \TestHelperFrontend::getContext() );
223
+		$catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager(\TestHelperFrontend::getContext());
224 224
 		$search = $catalogManager->createSearch();
225 225
 
226
-		$search->setConditions( $search->compare( '==', 'catalog.code', 'new' ) );
227
-		$search->setSlice( 0, 1 );
228
-		$items = $catalogManager->searchItems( $search );
226
+		$search->setConditions($search->compare('==', 'catalog.code', 'new'));
227
+		$search->setSlice(0, 1);
228
+		$items = $catalogManager->searchItems($search);
229 229
 
230
-		if( ( $item = reset( $items ) ) === false ) {
231
-			throw new \RuntimeException( 'Index item not found' );
230
+		if (($item = reset($items)) === false) {
231
+			throw new \RuntimeException('Index item not found');
232 232
 		}
233 233
 
234
-		$filter = $this->object->createFilter( 'position', '+', 1, 1 );
235
-		$filter = $this->object->addFilterCategory( $filter, $item->getId() );
234
+		$filter = $this->object->createFilter('position', '+', 1, 1);
235
+		$filter = $this->object->addFilterCategory($filter, $item->getId());
236 236
 
237 237
 		$total = 0;
238
-		$results = $this->object->getItems( $filter, array(), $total );
238
+		$results = $this->object->getItems($filter, array(), $total);
239 239
 
240
-		$this->assertEquals( 3, $total );
241
-		$this->assertEquals( 1, count( $results ) );
240
+		$this->assertEquals(3, $total);
241
+		$this->assertEquals(1, count($results));
242 242
 	}
243 243
 
244 244
 
245 245
 	public function testGetIndexItemsText()
246 246
 	{
247
-		$filter = $this->object->createFilter( 'relevance', '+', 0, 1, 'unittype13' );
248
-		$filter = $this->object->addFilterText( $filter, 'Expresso', 'unittype13' );
247
+		$filter = $this->object->createFilter('relevance', '+', 0, 1, 'unittype13');
248
+		$filter = $this->object->addFilterText($filter, 'Expresso', 'unittype13');
249 249
 
250 250
 		$total = 0;
251
-		$results = $this->object->getItems( $filter, array(), $total );
251
+		$results = $this->object->getItems($filter, array(), $total);
252 252
 
253
-		$this->assertEquals( 2, $total );
254
-		$this->assertEquals( 1, count( $results ) );
253
+		$this->assertEquals(2, $total);
254
+		$this->assertEquals(1, count($results));
255 255
 	}
256 256
 
257 257
 
258 258
 	public function testCreateTextFilter()
259 259
 	{
260
-		$filter = $this->object->createTextFilter( 'Expresso', 'name', '+', 0, 1 );
260
+		$filter = $this->object->createTextFilter('Expresso', 'name', '+', 0, 1);
261 261
 
262
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
263
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Expression\\Combine\\Iface', $filter->getConditions() );
264
-		$this->assertEquals( 3, count( $filter->getConditions()->getExpressions() ) );
262
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
263
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Expression\\Combine\\Iface', $filter->getConditions());
264
+		$this->assertEquals(3, count($filter->getConditions()->getExpressions()));
265 265
 	}
266 266
 
267 267
 
268 268
 	public function testGetTextListName()
269 269
 	{
270
-		$filter = $this->object->createTextFilter( 'Cafe Noire', 'relevance', '-', 0, 25, 'unittype19', 'name' );
271
-		$results = $this->object->getTextList( $filter );
270
+		$filter = $this->object->createTextFilter('Cafe Noire', 'relevance', '-', 0, 25, 'unittype19', 'name');
271
+		$results = $this->object->getTextList($filter);
272 272
 
273
-		$this->assertEquals( 1, count( $results ) );
274
-		$this->assertContains( 'Cafe Noire Cappuccino', $results );
273
+		$this->assertEquals(1, count($results));
274
+		$this->assertContains('Cafe Noire Cappuccino', $results);
275 275
 	}
276 276
 
277 277
 }
Please login to merge, or discard this patch.
controller/frontend/src/Controller/Frontend/Catalog/Iface.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 * @param string $name Name of the manager
27 27
 	 * @return \Aimeos\MShop\Common\Manager\Iface Manager object
28 28
 	 */
29
-	public function createManager( $name );
29
+	public function createManager($name);
30 30
 
31 31
 
32 32
 	/**
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object for filtering
37 37
 	 * @since 2015.08
38 38
 	 */
39
-	public function createCatalogFilter( $default = true );
39
+	public function createCatalogFilter($default = true);
40 40
 
41 41
 
42 42
 	/**
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 * @return array Associative list of items implementing \Aimeos\MShop\Catalog\Item\Iface with their IDs as keys
48 48
 	 * @since 2015.08
49 49
 	 */
50
-	public function getCatalogPath( $id, array $domains = array( 'text', 'media' ) );
50
+	public function getCatalogPath($id, array $domains = array('text', 'media'));
51 51
 
52 52
 
53 53
 	/**
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 	 * @return \Aimeos\MShop\Catalog\Item\Iface Catalog node, maybe with children depending on the level constant
62 62
 	 * @since 2015.08
63 63
 	 */
64
-	public function getCatalogTree( $id = null, array $domains = array( 'text', 'media' ),
65
-		$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE, \Aimeos\MW\Criteria\Iface $search = null );
64
+	public function getCatalogTree($id = null, array $domains = array('text', 'media'),
65
+		$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE, \Aimeos\MW\Criteria\Iface $search = null);
66 66
 
67 67
 
68 68
 	/**
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 * @return array List of product items implementing \Aimeos\MShop\Product\Item\Iface
74 74
 	 * @since 2015.08
75 75
 	 */
76
-	public function getProductItems( array $ids, array $domains = array( 'media', 'price', 'text' ) );
76
+	public function getProductItems(array $ids, array $domains = array('media', 'price', 'text'));
77 77
 
78 78
 
79 79
 	/**
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 * @param string $type Type of the text like "name", "short", "long", etc.
89 89
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
90 90
 	 */
91
-	public function createTextFilter( $input, $sort = null, $direction = '-', $start = 0, $size = 25, $listtype = 'default', $type = 'name' );
91
+	public function createTextFilter($input, $sort = null, $direction = '-', $start = 0, $size = 25, $listtype = 'default', $type = 'name');
92 92
 
93 93
 
94 94
 	/**
@@ -97,5 +97,5 @@  discard block
 block discarded – undo
97 97
 	 * @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions
98 98
 	 * @return array Associative list of the product ID as key and the product text as value
99 99
 	 */
100
-	public function getTextList( \Aimeos\MW\Criteria\Iface $filter );
100
+	public function getTextList(\Aimeos\MW\Criteria\Iface $filter);
101 101
 }
Please login to merge, or discard this patch.