Completed
Push — master ( e87582...bc3c0c )
by Aimeos
02:27
created
controller/frontend/tests/Controller/Frontend/Product/StandardTest.php 1 patch
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -17,225 +17,225 @@
 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
-		$list = $this->object->aggregate( 'index.attribute.id' );
32
+		$list = $this->object->aggregate('index.attribute.id');
33 33
 
34
-		$this->assertGreaterThan( 0, count( $list ) );
34
+		$this->assertGreaterThan(0, count($list));
35 35
 	}
36 36
 
37 37
 
38 38
 	public function testAllOf()
39 39
 	{
40
-		$manager = \Aimeos\MShop::create( $this->context, 'attribute' );
40
+		$manager = \Aimeos\MShop::create($this->context, 'attribute');
41 41
 
42
-		$length = $manager->findItem( '30', [], 'product', 'length' )->getId();
43
-		$width = $manager->findItem( '29', [], 'product', 'width' )->getId();
42
+		$length = $manager->findItem('30', [], 'product', 'length')->getId();
43
+		$width = $manager->findItem('29', [], 'product', 'width')->getId();
44 44
 
45
-		$this->assertEquals( 2, count( $this->object->allOf( [$length, $width] )->search() ) );
45
+		$this->assertEquals(2, count($this->object->allOf([$length, $width])->search()));
46 46
 	}
47 47
 
48 48
 
49 49
 	public function testCategory()
50 50
 	{
51
-		$manager = \Aimeos\MShop::create( $this->context, 'catalog' );
52
-		$catId = $manager->findItem( 'cafe' )->getId();
51
+		$manager = \Aimeos\MShop::create($this->context, 'catalog');
52
+		$catId = $manager->findItem('cafe')->getId();
53 53
 
54
-		$this->assertEquals( 2, count( $this->object->category( $catId, 'promotion' )->search() ) );
54
+		$this->assertEquals(2, count($this->object->category($catId, 'promotion')->search()));
55 55
 	}
56 56
 
57 57
 
58 58
 	public function testCategoryTree()
59 59
 	{
60
-		$manager = \Aimeos\MShop::create( $this->context, 'catalog' );
60
+		$manager = \Aimeos\MShop::create($this->context, 'catalog');
61 61
 
62
-		$catId = $manager->findItem( 'categories' )->getId();
63
-		$grpId = $manager->findItem( 'group' )->getId();
62
+		$catId = $manager->findItem('categories')->getId();
63
+		$grpId = $manager->findItem('group')->getId();
64 64
 
65
-		$this->object->category( [$catId, $grpId], 'promotion', \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE );
66
-		$this->assertEquals( 3, count( $this->object->search() ) );
65
+		$this->object->category([$catId, $grpId], 'promotion', \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE);
66
+		$this->assertEquals(3, count($this->object->search()));
67 67
 	}
68 68
 
69 69
 
70 70
 	public function testCompare()
71 71
 	{
72
-		$this->assertEquals( 1, count( $this->object->compare( '==', 'product.type', 'bundle' )->search() ) );
72
+		$this->assertEquals(1, count($this->object->compare('==', 'product.type', 'bundle')->search()));
73 73
 	}
74 74
 
75 75
 
76 76
 	public function testGet()
77 77
 	{
78
-		$item = \Aimeos\MShop::create( $this->context, 'product' )->findItem( 'CNC' );
78
+		$item = \Aimeos\MShop::create($this->context, 'product')->findItem('CNC');
79 79
 
80
-		$this->assertInstanceOf( \Aimeos\MShop\Product\Item\Iface::class, $this->object->get( $item->getId() ) );
80
+		$this->assertInstanceOf(\Aimeos\MShop\Product\Item\Iface::class, $this->object->get($item->getId()));
81 81
 	}
82 82
 
83 83
 
84 84
 	public function testFind()
85 85
 	{
86
-		$this->assertInstanceOf( \Aimeos\MShop\Product\Item\Iface::class, $this->object->find( 'CNC' ) );
86
+		$this->assertInstanceOf(\Aimeos\MShop\Product\Item\Iface::class, $this->object->find('CNC'));
87 87
 	}
88 88
 
89 89
 
90 90
 	public function testOneOf()
91 91
 	{
92
-		$manager = \Aimeos\MShop::create( $this->context, 'attribute' );
92
+		$manager = \Aimeos\MShop::create($this->context, 'attribute');
93 93
 
94
-		$length = $manager->findItem( '30', [], 'product', 'length' )->getId();
95
-		$width = $manager->findItem( '29', [], 'product', 'width' )->getId();
94
+		$length = $manager->findItem('30', [], 'product', 'length')->getId();
95
+		$width = $manager->findItem('29', [], 'product', 'width')->getId();
96 96
 
97
-		$this->assertEquals( 4, count( $this->object->oneOf( [$length, $width] )->search() ) );
97
+		$this->assertEquals(4, count($this->object->oneOf([$length, $width])->search()));
98 98
 	}
99 99
 
100 100
 
101 101
 	public function testOneOfList()
102 102
 	{
103
-		$manager = \Aimeos\MShop::create( $this->context, 'attribute' );
103
+		$manager = \Aimeos\MShop::create($this->context, 'attribute');
104 104
 
105
-		$length = $manager->findItem( '30', [], 'product', 'length' )->getId();
106
-		$width = $manager->findItem( '29', [], 'product', 'width' )->getId();
105
+		$length = $manager->findItem('30', [], 'product', 'length')->getId();
106
+		$width = $manager->findItem('29', [], 'product', 'width')->getId();
107 107
 
108
-		$this->assertEquals( 4, count( $this->object->oneOf( [[$length, $width]] )->search() ) );
108
+		$this->assertEquals(4, count($this->object->oneOf([[$length, $width]])->search()));
109 109
 	}
110 110
 
111 111
 
112 112
 	public function testParse()
113 113
 	{
114 114
 		$cond = ['&&' => [['>' => ['product.status' => 0]], ['==' => ['product.type' => 'default']]]];
115
-		$this->assertEquals( 4, count( $this->object->parse( $cond )->search() ) );
115
+		$this->assertEquals(4, count($this->object->parse($cond)->search()));
116 116
 	}
117 117
 
118 118
 
119 119
 	public function testProduct()
120 120
 	{
121
-		$manager = \Aimeos\MShop::create( $this->context, 'product' );
121
+		$manager = \Aimeos\MShop::create($this->context, 'product');
122 122
 
123
-		$cncId = $manager->findItem( 'CNC' )->getId();
124
-		$cneId = $manager->findItem( 'CNE' )->getId();
123
+		$cncId = $manager->findItem('CNC')->getId();
124
+		$cneId = $manager->findItem('CNE')->getId();
125 125
 
126
-		$this->assertEquals( 2, count( $this->object->product( [$cncId, $cneId] )->search() ) );
126
+		$this->assertEquals(2, count($this->object->product([$cncId, $cneId])->search()));
127 127
 	}
128 128
 
129 129
 
130 130
 	public function testSearch()
131 131
 	{
132
-		$this->assertEquals( 8, count( $this->object->search() ) );
132
+		$this->assertEquals(8, count($this->object->search()));
133 133
 	}
134 134
 
135 135
 
136 136
 	public function testSlice()
137 137
 	{
138
-		$this->assertEquals( 2, count( $this->object->slice( 0, 2 )->search() ) );
138
+		$this->assertEquals(2, count($this->object->slice(0, 2)->search()));
139 139
 	}
140 140
 
141 141
 
142 142
 	public function testSort()
143 143
 	{
144
-		$this->assertEquals( 8, count( $this->object->sort( 'relevance' )->search() ) );
144
+		$this->assertEquals(8, count($this->object->sort('relevance')->search()));
145 145
 	}
146 146
 
147 147
 
148 148
 	public function testSortCode()
149 149
 	{
150
-		$result = $this->object->sort( 'code' )->search( [] );
151
-		$this->assertEquals( 'CNC', reset( $result )->getCode() );
150
+		$result = $this->object->sort('code')->search([]);
151
+		$this->assertEquals('CNC', reset($result)->getCode());
152 152
 	}
153 153
 
154 154
 
155 155
 	public function testSortCodeDesc()
156 156
 	{
157
-		$result = $this->object->sort( '-code' )->search( [] );
158
-		$this->assertStringStartsWith( 'U:', reset( $result )->getCode() );
157
+		$result = $this->object->sort('-code')->search([]);
158
+		$this->assertStringStartsWith('U:', reset($result)->getCode());
159 159
 	}
160 160
 
161 161
 
162 162
 	public function testSortCtime()
163 163
 	{
164
-		$this->assertEquals( 8, count( $this->object->sort( 'ctime' )->search( [] ) ) );
164
+		$this->assertEquals(8, count($this->object->sort('ctime')->search([])));
165 165
 	}
166 166
 
167 167
 
168 168
 	public function testSortCtimeDesc()
169 169
 	{
170
-		$this->assertEquals( 8, count( $this->object->sort( '-ctime' )->search( [] ) ) );
170
+		$this->assertEquals(8, count($this->object->sort('-ctime')->search([])));
171 171
 	}
172 172
 
173 173
 
174 174
 	public function testSortName()
175 175
 	{
176
-		$result = $this->object->sort( 'name' )->search( ['text'] );
177
-		$this->assertEquals( 'Cafe Noire Cappuccino', reset( $result )->getName() );
176
+		$result = $this->object->sort('name')->search(['text']);
177
+		$this->assertEquals('Cafe Noire Cappuccino', reset($result)->getName());
178 178
 	}
179 179
 
180 180
 
181 181
 	public function testSortNameDesc()
182 182
 	{
183
-		$result = $this->object->sort( '-name' )->search( ['text'] );
184
-		$this->assertEquals( 'Unterproduct 3', reset( $result )->getName() );
183
+		$result = $this->object->sort('-name')->search(['text']);
184
+		$this->assertEquals('Unterproduct 3', reset($result)->getName());
185 185
 	}
186 186
 
187 187
 
188 188
 	public function testSortPrice()
189 189
 	{
190
-		$result = $this->object->sort( 'price' )->search( [] );
191
-		$this->assertEquals( 'IJKL', reset( $result )->getCode() );
190
+		$result = $this->object->sort('price')->search([]);
191
+		$this->assertEquals('IJKL', reset($result)->getCode());
192 192
 	}
193 193
 
194 194
 
195 195
 	public function testSortPriceDesc()
196 196
 	{
197
-		$result = $this->object->sort( '-price' )->search( [] );
198
-		$this->assertTrue( in_array( reset( $result )->getCode(), ['CNC', 'U:BUNDLE'] ) );
197
+		$result = $this->object->sort('-price')->search([]);
198
+		$this->assertTrue(in_array(reset($result)->getCode(), ['CNC', 'U:BUNDLE']));
199 199
 	}
200 200
 
201 201
 
202 202
 	public function testSortRelevanceCategory()
203 203
 	{
204
-		$manager = \Aimeos\MShop::create( $this->context, 'catalog' );
205
-		$catId = $manager->findItem( 'new' )->getId();
204
+		$manager = \Aimeos\MShop::create($this->context, 'catalog');
205
+		$catId = $manager->findItem('new')->getId();
206 206
 
207
-		$result = $this->object->category( $catId )->sort( 'relevance' )->search( [] );
207
+		$result = $this->object->category($catId)->sort('relevance')->search([]);
208 208
 
209
-		$this->assertEquals( 3, count( $result ) );
210
-		$this->assertEquals( 'CNE', reset( $result )->getCode() );
211
-		$this->assertEquals( 'U:BUNDLE', end( $result )->getCode() );
209
+		$this->assertEquals(3, count($result));
210
+		$this->assertEquals('CNE', reset($result)->getCode());
211
+		$this->assertEquals('U:BUNDLE', end($result)->getCode());
212 212
 	}
213 213
 
214 214
 
215 215
 	public function testSortRelevanceSupplier()
216 216
 	{
217
-		$manager = \Aimeos\MShop::create( $this->context, 'supplier' );
218
-		$supId = $manager->findItem( 'unitCode001' )->getId();
217
+		$manager = \Aimeos\MShop::create($this->context, 'supplier');
218
+		$supId = $manager->findItem('unitCode001')->getId();
219 219
 
220
-		$result = $this->object->supplier( $supId )->sort( 'relevance' )->search( [] );
220
+		$result = $this->object->supplier($supId)->sort('relevance')->search([]);
221 221
 
222
-		$this->assertEquals( 2, count( $result ) );
223
-		$this->assertEquals( 'CNC', reset( $result )->getCode() );
224
-		$this->assertEquals( 'CNE', end( $result )->getCode() );
222
+		$this->assertEquals(2, count($result));
223
+		$this->assertEquals('CNC', reset($result)->getCode());
224
+		$this->assertEquals('CNE', end($result)->getCode());
225 225
 	}
226 226
 
227 227
 
228 228
 	public function testSupplier()
229 229
 	{
230
-		$manager = \Aimeos\MShop::create( $this->context, 'supplier' );
231
-		$supId = $manager->findItem( 'unitCode001' )->getId();
230
+		$manager = \Aimeos\MShop::create($this->context, 'supplier');
231
+		$supId = $manager->findItem('unitCode001')->getId();
232 232
 
233
-		$this->assertEquals( 2, count( $this->object->supplier( $supId )->search( [] ) ) );
233
+		$this->assertEquals(2, count($this->object->supplier($supId)->search([])));
234 234
 	}
235 235
 
236 236
 
237 237
 	public function testText()
238 238
 	{
239
-		$this->assertEquals( 3, count( $this->object->text( 'Cafe' )->search( [] ) ) );
239
+		$this->assertEquals(3, count($this->object->text('Cafe')->search([])));
240 240
 	}
241 241
 }
Please login to merge, or discard this patch.
controller/frontend/src/Controller/Frontend/Product/Decorator/Base.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -30,12 +30,12 @@  discard block
 block discarded – undo
30 30
 	 * @param \Aimeos\Controller\Frontend\Iface $controller Controller object
31 31
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object with required objects
32 32
 	 */
33
-	public function __construct( \Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context )
33
+	public function __construct(\Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context)
34 34
 	{
35 35
 		$iface = \Aimeos\Controller\Frontend\Product\Iface::class;
36
-		$this->controller = \Aimeos\MW\Common\Base::checkClass( $iface, $controller );
36
+		$this->controller = \Aimeos\MW\Common\Base::checkClass($iface, $controller);
37 37
 
38
-		parent::__construct( $context );
38
+		parent::__construct($context);
39 39
 	}
40 40
 
41 41
 
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
 	 * @return mixed Returns the value of the called method
57 57
 	 * @throws \Aimeos\Controller\Frontend\Exception If method call failed
58 58
 	 */
59
-	public function __call( $name, array $param )
59
+	public function __call($name, array $param)
60 60
 	{
61
-		return @call_user_func_array( array( $this->controller, $name ), $param );
61
+		return @call_user_func_array(array($this->controller, $name), $param);
62 62
 	}
63 63
 
64 64
 
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
 	 * @return array Associative list of key values as key and the product count for this key as value
70 70
 	 * @since 2019.04
71 71
 	 */
72
-	public function aggregate( $key )
72
+	public function aggregate($key)
73 73
 	{
74
-		return $this->controller->aggregate( $key );
74
+		return $this->controller->aggregate($key);
75 75
 	}
76 76
 
77 77
 
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
 	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
83 83
 	 * @since 2019.04
84 84
 	 */
85
-	public function allOf( $attrIds )
85
+	public function allOf($attrIds)
86 86
 	{
87
-		$this->controller->allOf( $attrIds );
87
+		$this->controller->allOf($attrIds);
88 88
 		return $this;
89 89
 	}
90 90
 
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
 	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
99 99
 	 * @since 2019.04
100 100
 	 */
101
-	public function category( $catIds, $listtype = 'default', $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE )
101
+	public function category($catIds, $listtype = 'default', $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE)
102 102
 	{
103
-		$this->controller->category( $catIds, $listtype, $level );
103
+		$this->controller->category($catIds, $listtype, $level);
104 104
 		return $this;
105 105
 	}
106 106
 
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
 	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
115 115
 	 * @since 2019.04
116 116
 	 */
117
-	public function compare( $operator, $key, $value )
117
+	public function compare($operator, $key, $value)
118 118
 	{
119
-		$this->controller->compare( $operator, $key, $value );
119
+		$this->controller->compare($operator, $key, $value);
120 120
 		return $this;
121 121
 	}
122 122
 
@@ -129,9 +129,9 @@  discard block
 block discarded – undo
129 129
 	 * @return \Aimeos\MShop\Product\Item\Iface Product item including the referenced domains items
130 130
 	 * @since 2019.04
131 131
 	 */
132
-	public function get( $id, $domains = ['media', 'price', 'text'] )
132
+	public function get($id, $domains = ['media', 'price', 'text'])
133 133
 	{
134
-		return $this->controller->get( $id, $domains );
134
+		return $this->controller->get($id, $domains);
135 135
 	}
136 136
 
137 137
 
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
 	 * @return \Aimeos\MShop\Product\Item\Iface Product item including the referenced domains items
144 144
 	 * @since 2019.04
145 145
 	 */
146
-	public function find( $code, $domains = ['media', 'price', 'text'] )
146
+	public function find($code, $domains = ['media', 'price', 'text'])
147 147
 	{
148
-		return $this->controller->find( $code, $domains );
148
+		return $this->controller->find($code, $domains);
149 149
 	}
150 150
 
151 151
 
@@ -156,9 +156,9 @@  discard block
 block discarded – undo
156 156
 	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
157 157
 	 * @since 2019.04
158 158
 	 */
159
-	public function oneOf( $attrIds )
159
+	public function oneOf($attrIds)
160 160
 	{
161
-		$this->controller->oneOf( $attrIds );
161
+		$this->controller->oneOf($attrIds);
162 162
 		return $this;
163 163
 	}
164 164
 
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
 	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
171 171
 	 * @since 2019.04
172 172
 	 */
173
-	public function parse( array $conditions )
173
+	public function parse(array $conditions)
174 174
 	{
175
-		$this->controller->parse( $conditions );
175
+		$this->controller->parse($conditions);
176 176
 		return $this;
177 177
 	}
178 178
 
@@ -184,9 +184,9 @@  discard block
 block discarded – undo
184 184
 	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
185 185
 	 * @since 2019.04
186 186
 	 */
187
-	public function product( $prodIds )
187
+	public function product($prodIds)
188 188
 	{
189
-		$this->controller->product( $prodIds );
189
+		$this->controller->product($prodIds);
190 190
 		return $this;
191 191
 	}
192 192
 
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
 	 * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface
200 200
 	 * @since 2019.04
201 201
 	 */
202
-	public function search( $domains = ['media', 'price', 'text'], &$total = null )
202
+	public function search($domains = ['media', 'price', 'text'], &$total = null)
203 203
 	{
204
-		return $this->controller->search( $domains, $total );
204
+		return $this->controller->search($domains, $total);
205 205
 	}
206 206
 
207 207
 
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
 	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
214 214
 	 * @since 2019.04
215 215
 	 */
216
-	public function slice( $start, $limit )
216
+	public function slice($start, $limit)
217 217
 	{
218
-		$this->controller->slice( $start, $limit );
218
+		$this->controller->slice($start, $limit);
219 219
 		return $this;
220 220
 	}
221 221
 
@@ -227,9 +227,9 @@  discard block
 block discarded – undo
227 227
 	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
228 228
 	 * @since 2019.04
229 229
 	 */
230
-	public function sort( $key = null )
230
+	public function sort($key = null)
231 231
 	{
232
-		$this->controller->sort( $key );
232
+		$this->controller->sort($key);
233 233
 		return $this;
234 234
 	}
235 235
 
@@ -242,9 +242,9 @@  discard block
 block discarded – undo
242 242
 	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
243 243
 	 * @since 2019.04
244 244
 	 */
245
-	public function supplier( $supIds, $listtype = 'default' )
245
+	public function supplier($supIds, $listtype = 'default')
246 246
 	{
247
-		$this->controller->supplier( $supIds, $listtype );
247
+		$this->controller->supplier($supIds, $listtype);
248 248
 		return $this;
249 249
 	}
250 250
 
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
 	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
257 257
 	 * @since 2019.04
258 258
 	 */
259
-	public function text( $text )
259
+	public function text($text)
260 260
 	{
261
-		$this->controller->text( $text );
261
+		$this->controller->text($text);
262 262
 		return $this;
263 263
 	}
264 264
 
Please login to merge, or discard this patch.