Total Complexity | 66 |
Total Lines | 674 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
Complex classes like StandardTest often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use StandardTest, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
13 | class StandardTest extends \PHPUnit\Framework\TestCase |
||
14 | { |
||
15 | private $object; |
||
16 | private $values; |
||
17 | |||
18 | |||
19 | protected function setUp() : void |
||
20 | { |
||
21 | $this->values = array( |
||
22 | 'product.id' => 1, |
||
23 | 'product.siteid' => '1.33.99.', |
||
24 | 'product.type' => 'test', |
||
25 | 'product.status' => 1, |
||
26 | 'product.code' => 'TEST', |
||
27 | 'product.dataset' => 'Shirts', |
||
28 | 'product.url' => 'test_product', |
||
29 | 'product.label' => 'testproduct', |
||
30 | 'product.config' => array( 'css-class' => 'test' ), |
||
31 | 'product.datestart' => null, |
||
32 | 'product.dateend' => null, |
||
33 | 'product.scale' => '', |
||
34 | 'product.ctime' => '2011-01-19 17:04:32', |
||
35 | 'product.mtime' => '2011-01-19 18:04:32', |
||
36 | 'product.editor' => 'unitTestUser', |
||
37 | 'product.target' => 'testtarget', |
||
38 | 'product.rating' => '4.80', |
||
39 | 'product.ratings' => 5, |
||
40 | 'product.instock' => 1, |
||
41 | 'product.boost' => 1.5, |
||
42 | 'additional' => 'value', |
||
43 | ); |
||
44 | |||
45 | $propItems = array( |
||
46 | 2 => new \Aimeos\MShop\Common\Item\Property\Standard( 'product.property.', array( |
||
47 | 'product.property.id' => 2, |
||
48 | 'product.property.parentid' => 1, |
||
49 | 'product.property.type' => 'proptest', |
||
50 | 'product.property.languageid' => 'de', |
||
51 | '.languageid' => 'de', |
||
52 | ) ), |
||
53 | 3 => new \Aimeos\MShop\Common\Item\Property\Standard( 'product.property.', array( |
||
54 | 'product.property.id' => 3, |
||
55 | 'product.property.parentid' => 1, |
||
56 | 'product.property.type' => 'proptype', |
||
57 | 'product.property.languageid' => 'de', |
||
58 | '.languageid' => 'fr', |
||
59 | ) ), |
||
60 | ); |
||
61 | |||
62 | $this->object = new \Aimeos\MShop\Product\Item\Standard( $this->values, [], [], $propItems ); |
||
63 | } |
||
64 | |||
65 | |||
66 | protected function tearDown() : void |
||
67 | { |
||
68 | unset( $this->object, $this->values ); |
||
69 | } |
||
70 | |||
71 | |||
72 | public function testDynamicMethods() |
||
73 | { |
||
74 | \Aimeos\MShop\Product\Item\Standard::macro( 'test', function( $name ) { |
||
75 | return $this->bdata[$name]; |
||
|
|||
76 | } ); |
||
77 | |||
78 | $this->assertInstanceOf( '\Closure', \Aimeos\MShop\Product\Item\Standard::macro( 'test' ) ); |
||
79 | |||
80 | $object = new \Aimeos\MShop\Product\Item\Standard( $this->values ); |
||
81 | $this->assertEquals( 'TEST', $object->test( 'product.code' ) ); |
||
82 | |||
83 | $this->expectException( \BadMethodCallException::class ); |
||
84 | $object->invalid(); |
||
85 | } |
||
86 | |||
87 | |||
88 | public function testDynamicBaseMethods() |
||
89 | { |
||
90 | \Aimeos\MShop\Common\Item\Base::macro( 'tests', function( $name ) { |
||
91 | return $this->bdata[$name]; |
||
92 | } ); |
||
93 | |||
94 | $this->assertInstanceOf( '\Closure', \Aimeos\MShop\Product\Item\Standard::macro( 'tests' ) ); |
||
95 | |||
96 | $object = new \Aimeos\MShop\Product\Item\Standard( $this->values ); |
||
97 | $this->assertEquals( 'TEST', $object->tests( 'product.code' ) ); |
||
98 | |||
99 | $this->expectException( \BadMethodCallException::class ); |
||
100 | $object->invalid(); |
||
101 | } |
||
102 | |||
103 | |||
104 | public function testArrayMethods() |
||
105 | { |
||
106 | $this->assertFalse( isset( $this->object['test'] ) ); |
||
107 | $this->assertEquals( null, $this->object['test'] ); |
||
108 | |||
109 | $this->object['test'] = 'value'; |
||
110 | |||
111 | $this->assertTrue( isset( $this->object['test'] ) ); |
||
112 | $this->assertEquals( 'value', $this->object['test'] ); |
||
113 | |||
114 | $this->expectException( \LogicException::class ); |
||
115 | unset( $this->object['test'] ); |
||
116 | } |
||
117 | |||
118 | |||
119 | public function testMagicMethods() |
||
120 | { |
||
121 | $this->assertFalse( isset( $this->object->test ) ); |
||
122 | $this->assertEquals( null, $this->object->test ); |
||
123 | |||
124 | $this->object->test = 'value'; |
||
125 | |||
126 | $this->assertTrue( isset( $this->object->test ) ); |
||
127 | $this->assertEquals( 'value', $this->object->test ); |
||
128 | |||
129 | $this->assertEquals( '1', (string) $this->object ); |
||
130 | } |
||
131 | |||
132 | |||
133 | public function testGetSet() |
||
141 | } |
||
142 | |||
143 | |||
144 | public function testJsonSerialize() |
||
145 | { |
||
146 | $result = json_decode( json_encode( $this->object ), true ); |
||
147 | |||
148 | $this->assertEquals( 1, $result['product.id'] ); |
||
149 | $this->assertEquals( '1.33.99.', $result['product.siteid'] ); |
||
150 | |||
151 | |||
152 | $result = json_decode( json_encode( [1 => $this->object] ), true ); |
||
153 | |||
154 | $this->assertEquals( 1, $result[1]['product.id'] ); |
||
155 | $this->assertEquals( '1.33.99.', $result[1]['product.siteid'] ); |
||
156 | } |
||
157 | |||
158 | |||
159 | public function testAssign() |
||
160 | { |
||
161 | $this->assertEquals( false, $this->object->get( 'test', false ) ); |
||
162 | |||
163 | $return = $this->object->assign( ['test' => 'value'] ); |
||
164 | |||
165 | $this->assertEquals( 'value', $this->object->get( 'test', false ) ); |
||
166 | $this->assertInstanceOf( \Aimeos\MShop\Product\Item\Iface::class, $return ); |
||
167 | } |
||
168 | |||
169 | |||
170 | public function testGetId() |
||
171 | { |
||
172 | $this->assertEquals( '1', $this->object->getId() ); |
||
173 | } |
||
174 | |||
175 | |||
176 | public function testSetId() |
||
177 | { |
||
178 | $return = $this->object->setId( null ); |
||
179 | |||
180 | $this->assertInstanceOf( \Aimeos\MShop\Product\Item\Iface::class, $return ); |
||
181 | $this->assertNull( $this->object->getId() ); |
||
182 | $this->assertTrue( $this->object->isModified() ); |
||
183 | |||
184 | $return = $this->object->setId( 1 ); |
||
185 | |||
186 | $this->assertInstanceOf( \Aimeos\MShop\Product\Item\Iface::class, $return ); |
||
187 | $this->assertEquals( '1', $this->object->getId() ); |
||
188 | $this->assertFalse( $this->object->isModified() ); |
||
189 | } |
||
190 | |||
191 | |||
192 | public function testGetSiteId() |
||
193 | { |
||
194 | $this->assertEquals( '1.33.99.', $this->object->getSiteId() ); |
||
195 | } |
||
196 | |||
197 | |||
198 | public function testGetSitePath() |
||
199 | { |
||
200 | $this->assertEquals( ['1.', '1.33.', '1.33.99.'], $this->object->getSitePath() ); |
||
201 | } |
||
202 | |||
203 | |||
204 | public function testGetType() |
||
205 | { |
||
206 | $this->assertEquals( 'test', $this->object->getType() ); |
||
207 | } |
||
208 | |||
209 | |||
210 | public function testSetType() |
||
211 | { |
||
212 | $this->assertFalse( $this->object->isModified() ); |
||
213 | |||
214 | $return = $this->object->setType( 'default' ); |
||
215 | |||
216 | $this->assertInstanceOf( \Aimeos\MShop\Product\Item\Iface::class, $return ); |
||
217 | $this->assertEquals( 'default', $this->object->getType() ); |
||
218 | $this->assertTrue( $this->object->isModified() ); |
||
219 | } |
||
220 | |||
221 | |||
222 | public function testGetCode() |
||
223 | { |
||
224 | $this->assertEquals( 'TEST', $this->object->getCode() ); |
||
225 | } |
||
226 | |||
227 | |||
228 | public function testSetCode() |
||
229 | { |
||
230 | $this->assertFalse( $this->object->isModified() ); |
||
231 | |||
232 | $return = $this->object->setCode( 'NEU' ); |
||
233 | |||
234 | $this->assertInstanceOf( \Aimeos\MShop\Product\Item\Iface::class, $return ); |
||
235 | $this->assertEquals( 'NEU', $this->object->getCode() ); |
||
236 | $this->assertTrue( $this->object->isModified() ); |
||
237 | } |
||
238 | |||
239 | |||
240 | public function testGetDataset() |
||
241 | { |
||
242 | $this->assertEquals( 'Shirts', $this->object->getDataset() ); |
||
243 | } |
||
244 | |||
245 | |||
246 | public function testSetDataset() |
||
247 | { |
||
248 | $this->assertFalse( $this->object->isModified() ); |
||
249 | |||
250 | $return = $this->object->setDataset( 'Skirts' ); |
||
251 | |||
252 | $this->assertInstanceOf( \Aimeos\MShop\Product\Item\Iface::class, $return ); |
||
253 | $this->assertEquals( 'Skirts', $this->object->getDataset() ); |
||
254 | $this->assertTrue( $this->object->isModified() ); |
||
255 | } |
||
256 | |||
257 | |||
258 | public function testGetScale() |
||
259 | { |
||
260 | $this->assertEquals( 1, $this->object->getScale() ); |
||
261 | } |
||
262 | |||
263 | |||
264 | public function testSetScale() |
||
271 | } |
||
272 | |||
273 | |||
274 | public function testSetScaleInvalid() |
||
275 | { |
||
276 | $return = $this->object->setScale( -1 ); |
||
277 | |||
278 | $this->assertInstanceOf( \Aimeos\MShop\Product\Item\Iface::class, $return ); |
||
279 | $this->assertEquals( 1, $this->object->getScale() ); |
||
280 | $this->assertTrue( $this->object->isModified() ); |
||
281 | } |
||
282 | |||
283 | |||
284 | public function testGetEditor() |
||
285 | { |
||
286 | $this->assertEquals( 'unitTestUser', $this->object->editor() ); |
||
287 | } |
||
288 | |||
289 | |||
290 | public function testGetStatus() |
||
291 | { |
||
292 | $this->assertEquals( 1, $this->object->getStatus() ); |
||
293 | } |
||
294 | |||
295 | |||
296 | public function testSetStatus() |
||
303 | } |
||
304 | |||
305 | |||
306 | public function testGetLabel() |
||
307 | { |
||
308 | $this->assertEquals( 'testproduct', $this->object->getLabel() ); |
||
309 | } |
||
310 | |||
311 | |||
312 | public function testSetLabel() |
||
313 | { |
||
314 | $return = $this->object->setLabel( 'editproduct' ); |
||
315 | |||
316 | $this->assertInstanceOf( \Aimeos\MShop\Product\Item\Iface::class, $return ); |
||
317 | $this->assertEquals( 'editproduct', $this->object->getLabel() ); |
||
318 | $this->assertTrue( $this->object->isModified() ); |
||
319 | } |
||
320 | |||
321 | |||
322 | public function testGetUrl() |
||
323 | { |
||
324 | $this->assertEquals( 'test_product', $this->object->getUrl() ); |
||
325 | } |
||
326 | |||
327 | |||
328 | public function testSetUrl() |
||
329 | { |
||
330 | $return = $this->object->setUrl( 'edit_product' ); |
||
331 | |||
332 | $this->assertInstanceOf( \Aimeos\MShop\Product\Item\Iface::class, $return ); |
||
333 | $this->assertEquals( 'edit_product', $this->object->getUrl() ); |
||
334 | $this->assertTrue( $this->object->isModified() ); |
||
335 | } |
||
336 | |||
337 | |||
338 | public function testGetConfig() |
||
339 | { |
||
340 | $this->assertEquals( array( 'css-class' => 'test' ), $this->object->getConfig() ); |
||
341 | } |
||
342 | |||
343 | |||
344 | public function testGetConfigValue() |
||
345 | { |
||
346 | $this->assertEquals( 'test', $this->object->getConfigValue( 'css-class' ) ); |
||
347 | } |
||
348 | |||
349 | |||
350 | public function testSetConfig() |
||
351 | { |
||
352 | $this->assertFalse( $this->object->isModified() ); |
||
353 | |||
354 | $return = $this->object->setConfig( array( 'key' => 'value' ) ); |
||
355 | |||
356 | $this->assertInstanceOf( \Aimeos\MShop\Product\Item\Iface::class, $return ); |
||
357 | $this->assertEquals( array( 'key' => 'value' ), $this->object->getConfig() ); |
||
358 | $this->assertTrue( $this->object->isModified() ); |
||
359 | } |
||
360 | |||
361 | |||
362 | public function testSetConfigValue() |
||
363 | { |
||
364 | $result = $this->object->setConfigValue( 'path/to/value', 'test' ); |
||
365 | $expected = ['path' => ['to' => ['value' => 'test']], 'css-class' => 'test']; |
||
366 | |||
367 | $this->assertInstanceOf( \Aimeos\MShop\Product\Item\Iface::class, $result ); |
||
368 | $this->assertEquals( $expected, $this->object->getConfig() ); |
||
369 | |||
370 | $result = $this->object->setConfigValue( 'path/to/value2', 'test2' ); |
||
371 | $expected = ['path' => ['to' => ['value' => 'test', 'value2' => 'test2']], 'css-class' => 'test']; |
||
372 | |||
373 | $this->assertInstanceOf( \Aimeos\MShop\Product\Item\Iface::class, $result ); |
||
374 | $this->assertEquals( $expected, $this->object->getConfig() ); |
||
375 | } |
||
376 | |||
377 | |||
378 | public function testGetTarget() |
||
379 | { |
||
380 | $this->assertEquals( 'testtarget', $this->object->getTarget() ); |
||
381 | } |
||
382 | |||
383 | |||
384 | public function testSetTarget() |
||
385 | { |
||
386 | $this->assertFalse( $this->object->isModified() ); |
||
387 | |||
388 | $return = $this->object->setTarget( 'ttarget' ); |
||
389 | |||
390 | $this->assertInstanceOf( \Aimeos\MShop\Product\Item\Iface::class, $return ); |
||
391 | $this->assertEquals( 'ttarget', $this->object->getTarget() ); |
||
392 | $this->assertTrue( $this->object->isModified() ); |
||
393 | } |
||
394 | |||
395 | |||
396 | public function testGetDateStart() |
||
397 | { |
||
398 | $this->assertEquals( null, $this->object->getDateStart() ); |
||
399 | } |
||
400 | |||
401 | |||
402 | public function testSetDateStart() |
||
403 | { |
||
404 | $return = $this->object->setDateStart( '2010-04-22 06:22:22' ); |
||
405 | |||
406 | $this->assertInstanceOf( \Aimeos\MShop\Product\Item\Iface::class, $return ); |
||
407 | $this->assertEquals( '2010-04-22 06:22:22', $this->object->getDateStart() ); |
||
408 | $this->assertTrue( $this->object->isModified() ); |
||
409 | } |
||
410 | |||
411 | |||
412 | public function testGetDateEnd() |
||
413 | { |
||
414 | $this->assertEquals( null, $this->object->getDateEnd() ); |
||
415 | } |
||
416 | |||
417 | |||
418 | public function testSetDateEnd() |
||
419 | { |
||
420 | $return = $this->object->setDateEnd( '2010-05-22 06:22' ); |
||
421 | |||
422 | $this->assertInstanceOf( \Aimeos\MShop\Product\Item\Iface::class, $return ); |
||
423 | $this->assertEquals( '2010-05-22 06:22:00', $this->object->getDateEnd() ); |
||
424 | $this->assertTrue( $this->object->isModified() ); |
||
425 | } |
||
426 | |||
427 | |||
428 | public function testGetTimeModified() |
||
429 | { |
||
430 | $this->assertEquals( '2011-01-19 18:04:32', $this->object->getTimeModified() ); |
||
431 | } |
||
432 | |||
433 | |||
434 | public function testGetTimeCreated() |
||
435 | { |
||
436 | $this->assertEquals( '2011-01-19 17:04:32', $this->object->getTimeCreated() ); |
||
437 | } |
||
438 | |||
439 | |||
440 | public function testSetTimeCreated() |
||
441 | { |
||
442 | $return = $this->object->setTimeCreated( '2010-05-22 06:22:22' ); |
||
443 | |||
444 | $this->assertInstanceOf( \Aimeos\MShop\Product\Item\Iface::class, $return ); |
||
445 | $this->assertEquals( '2010-05-22 06:22:22', $this->object->getTimeCreated() ); |
||
446 | $this->assertTrue( $this->object->isModified() ); |
||
447 | } |
||
448 | |||
449 | |||
450 | public function testGetRating() |
||
451 | { |
||
452 | $this->assertEquals( '4.80', $this->object->getRating() ); |
||
453 | } |
||
454 | |||
455 | |||
456 | public function testGetRatings() |
||
457 | { |
||
458 | $this->assertEquals( 5, $this->object->getRatings() ); |
||
459 | } |
||
460 | |||
461 | |||
462 | public function testInStock() |
||
463 | { |
||
464 | $this->assertEquals( 1, $this->object->inStock() ); |
||
465 | } |
||
466 | |||
467 | |||
468 | public function testSetInStock() |
||
469 | { |
||
470 | $return = $this->object->setInStock( 0 ); |
||
471 | |||
472 | $this->assertInstanceOf( \Aimeos\MShop\Product\Item\Iface::class, $return ); |
||
473 | $this->assertEquals( 0, $this->object->inStock() ); |
||
474 | $this->assertTrue( $this->object->isModified() ); |
||
475 | } |
||
476 | |||
477 | |||
478 | public function testBost() |
||
479 | { |
||
480 | $this->assertEquals( 1.5, $this->object->boost() ); |
||
481 | } |
||
482 | |||
483 | |||
484 | public function testSetBoost() |
||
485 | { |
||
486 | $return = $this->object->setBoost( 1.25 ); |
||
487 | |||
488 | $this->assertInstanceOf( \Aimeos\MShop\Product\Item\Iface::class, $return ); |
||
489 | $this->assertEquals( 1.25, $this->object->boost() ); |
||
490 | $this->assertTrue( $this->object->isModified() ); |
||
491 | } |
||
492 | |||
493 | |||
494 | public function testIsAvailable() |
||
495 | { |
||
496 | $this->assertTrue( $this->object->isAvailable() ); |
||
497 | $this->object->setAvailable( false ); |
||
498 | $this->assertFalse( $this->object->isAvailable() ); |
||
499 | } |
||
500 | |||
501 | |||
502 | public function testIsAvailableOnStatus() |
||
503 | { |
||
504 | $this->assertTrue( $this->object->isAvailable() ); |
||
505 | $this->object->setStatus( 0 ); |
||
506 | $this->assertFalse( $this->object->isAvailable() ); |
||
507 | $this->object->setStatus( -1 ); |
||
508 | $this->assertFalse( $this->object->isAvailable() ); |
||
509 | } |
||
510 | |||
511 | |||
512 | public function testIsAvailableOnTime() |
||
513 | { |
||
514 | $this->assertTrue( $this->object->isAvailable() ); |
||
515 | $this->object->setDateStart( date( 'Y-m-d H:i:s', time() + 600 ) ); |
||
516 | $this->assertFalse( $this->object->isAvailable() ); |
||
517 | $this->object->setDateEnd( date( 'Y-m-d H:i:s', time() - 600 ) ); |
||
518 | $this->assertFalse( $this->object->isAvailable() ); |
||
519 | } |
||
520 | |||
521 | |||
522 | public function testIsAvailableEvent() |
||
523 | { |
||
524 | $this->object->setType( 'event' ); |
||
525 | $this->assertTrue( $this->object->isAvailable() ); |
||
526 | $this->object->setDateStart( date( 'Y-m-d H:i:s', time() + 600 ) ); |
||
527 | $this->assertTrue( $this->object->isAvailable() ); |
||
528 | $this->object->setDateEnd( date( 'Y-m-d H:i:s', time() - 600 ) ); |
||
529 | $this->assertFalse( $this->object->isAvailable() ); |
||
530 | } |
||
531 | |||
532 | |||
533 | public function testIsModified() |
||
534 | { |
||
535 | $this->assertFalse( $this->object->isModified() ); |
||
536 | } |
||
537 | |||
538 | |||
539 | public function testIsModifiedTrue() |
||
540 | { |
||
541 | $this->object->setLabel( 'reeditProduct' ); |
||
542 | $this->assertTrue( $this->object->isModified() ); |
||
543 | } |
||
544 | |||
545 | |||
546 | public function testGetResourceType() |
||
547 | { |
||
548 | $this->assertEquals( 'product', $this->object->getResourceType() ); |
||
549 | } |
||
550 | |||
551 | |||
552 | public function testGetPropertyItems() |
||
553 | { |
||
554 | $propItems = $this->object->getPropertyItems(); |
||
555 | |||
556 | $this->assertEquals( 1, count( $propItems ) ); |
||
557 | |||
558 | foreach( $propItems as $propItem ) { |
||
559 | $this->assertInstanceOf( \Aimeos\MShop\Common\Item\Property\Iface::class, $propItem ); |
||
560 | } |
||
561 | } |
||
562 | |||
563 | |||
564 | public function testGetSiteItem() |
||
565 | { |
||
566 | $siteItem = \TestHelper::context()->locale()->getSiteItem(); |
||
567 | $object = new \Aimeos\MShop\Product\Item\Standard( ['.locale/site' => $siteItem] ); |
||
568 | |||
569 | $this->assertInstanceOf( \Aimeos\MShop\Locale\Item\Site\Iface::class, $object->getSiteItem() ); |
||
570 | } |
||
571 | |||
572 | |||
573 | public function testGetStockItems() |
||
579 | } |
||
580 | |||
581 | |||
582 | public function testGetStockItemsType() |
||
583 | { |
||
584 | $stock = new \Aimeos\MShop\Stock\Item\Standard(); |
||
585 | $stocks = [123 => ( clone $stock )->setType( 'something' ), 456 => ( clone $stock )->setType( 'default' )]; |
||
586 | $object = new \Aimeos\MShop\Product\Item\Standard( ['.stock' => $stocks] ); |
||
587 | |||
588 | $this->assertInstanceOf( \Aimeos\Map::class, $object->getStockItems( 'default' ) ); |
||
589 | $this->assertEquals( 'default', $object->getStockItems( 'default' )->getType()->first() ); |
||
590 | $this->assertCount( 1, $object->getStockItems( 'default' ) ); |
||
591 | } |
||
592 | |||
593 | |||
594 | public function testGetPropertyItemsAll() |
||
595 | { |
||
596 | $propItems = $this->object->getPropertyItems( null, false ); |
||
597 | |||
598 | $this->assertEquals( 2, count( $propItems ) ); |
||
599 | |||
600 | foreach( $propItems as $propItem ) { |
||
601 | $this->assertInstanceOf( \Aimeos\MShop\Common\Item\Property\Iface::class, $propItem ); |
||
602 | } |
||
603 | } |
||
604 | |||
605 | |||
606 | public function testGetPropertyItemsType() |
||
607 | { |
||
608 | $propItems = $this->object->getPropertyItems( 'proptest' ); |
||
609 | |||
610 | $this->assertEquals( 1, count( $propItems ) ); |
||
611 | |||
612 | foreach( $propItems as $propItem ) { |
||
613 | $this->assertInstanceOf( \Aimeos\MShop\Common\Item\Property\Iface::class, $propItem ); |
||
614 | } |
||
615 | } |
||
616 | |||
617 | |||
618 | public function testFromArray() |
||
659 | } |
||
660 | |||
661 | |||
662 | public function testToArray() |
||
663 | { |
||
664 | $arrayObject = $this->object->toArray( true ); |
||
665 | $this->assertEquals( count( $this->values ), count( $arrayObject ) ); |
||
666 | |||
667 | $this->assertEquals( $this->object->getId(), $arrayObject['product.id'] ); |
||
668 | $this->assertEquals( $this->object->getSiteId(), $arrayObject['product.siteid'] ); |
||
669 | $this->assertEquals( $this->object->getCode(), $arrayObject['product.code'] ); |
||
670 | $this->assertEquals( $this->object->getType(), $arrayObject['product.type'] ); |
||
671 | $this->assertEquals( $this->object->getDataset(), $arrayObject['product.dataset'] ); |
||
672 | $this->assertEquals( $this->object->getLabel(), $arrayObject['product.label'] ); |
||
673 | $this->assertEquals( $this->object->getUrl(), $arrayObject['product.url'] ); |
||
674 | $this->assertEquals( $this->object->getStatus(), $arrayObject['product.status'] ); |
||
675 | $this->assertEquals( $this->object->getDateStart(), $arrayObject['product.datestart'] ); |
||
676 | $this->assertEquals( $this->object->getDateEnd(), $arrayObject['product.dateend'] ); |
||
677 | $this->assertEquals( $this->object->getConfig(), $arrayObject['product.config'] ); |
||
678 | $this->assertEquals( $this->object->getTimeCreated(), $arrayObject['product.ctime'] ); |
||
679 | $this->assertEquals( $this->object->getTimeModified(), $arrayObject['product.mtime'] ); |
||
680 | $this->assertEquals( $this->object->editor(), $arrayObject['product.editor'] ); |
||
681 | $this->assertEquals( $this->object->boost(), $arrayObject['product.boost'] ); |
||
682 | $this->assertEquals( $this->object->getTarget(), $arrayObject['product.target'] ); |
||
683 | $this->assertEquals( $this->object->getScale(), $arrayObject['product.scale'] ); |
||
684 | $this->assertEquals( $this->object->getRating(), $arrayObject['product.rating'] ); |
||
685 | $this->assertEquals( $this->object->getRatings(), $arrayObject['product.ratings'] ); |
||
686 | $this->assertEquals( $this->object->inStock(), $arrayObject['product.instock'] ); |
||
687 | } |
||
688 | } |
||
689 |