|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* File containing the TrashItemTest class. |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
|
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
|
8
|
|
|
*/ |
|
9
|
|
|
namespace eZ\Publish\Core\Repository\Tests\Values\Content; |
|
10
|
|
|
|
|
11
|
|
|
use eZ\Publish\Core\Repository\Values\Content\TrashItem; |
|
12
|
|
|
use PHPUnit_Framework_TestCase; |
|
13
|
|
|
|
|
14
|
|
View Code Duplication |
class TrashItemTest extends PHPUnit_Framework_TestCase |
|
|
|
|
|
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* @covers \eZ\Publish\Core\Repository\Values\Content\TrashItem::getProperties |
|
18
|
|
|
*/ |
|
19
|
|
|
public function testObjectProperties() |
|
20
|
|
|
{ |
|
21
|
|
|
$object = new TrashItem(); |
|
22
|
|
|
$properties = $object->attributes(); |
|
|
|
|
|
|
23
|
|
|
//self::assertNotContains( 'internalFields', $properties, 'Internal property found ' ); |
|
24
|
|
|
self::assertContains('contentInfo', $properties, 'Property not found'); |
|
25
|
|
|
self::assertContains('contentId', $properties, 'Property not found'); |
|
26
|
|
|
self::assertContains('id', $properties, 'Property not found'); |
|
27
|
|
|
self::assertContains('priority', $properties, 'Property not found'); |
|
28
|
|
|
self::assertContains('hidden', $properties, 'Property not found'); |
|
29
|
|
|
self::assertContains('invisible', $properties, 'Property not found'); |
|
30
|
|
|
self::assertContains('remoteId', $properties, 'Property not found'); |
|
31
|
|
|
self::assertContains('parentLocationId', $properties, 'Property not found'); |
|
32
|
|
|
self::assertContains('pathString', $properties, 'Property not found'); |
|
33
|
|
|
self::assertContains('path', $properties, 'Property not found'); |
|
34
|
|
|
self::assertContains('depth', $properties, 'Property not found'); |
|
35
|
|
|
self::assertContains('sortField', $properties, 'Property not found'); |
|
36
|
|
|
self::assertContains('sortOrder', $properties, 'Property not found'); |
|
37
|
|
|
|
|
38
|
|
|
// check for duplicates and double check existence of property |
|
39
|
|
|
$propertiesHash = array(); |
|
40
|
|
|
foreach ($properties as $property) { |
|
41
|
|
|
if (isset($propertiesHash[$property])) { |
|
42
|
|
|
self::fail("Property '{$property}' exists several times in properties list"); |
|
43
|
|
|
} elseif (!isset($object->$property)) { |
|
44
|
|
|
self::fail("Property '{$property}' does not exist on object, even though it was hinted to be there"); |
|
45
|
|
|
} |
|
46
|
|
|
$propertiesHash[$property] = 1; |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.