Completed
Push — ezp26970-login_no_siteaccess_l... ( 42bede...99b8e7 )
by
unknown
22:52 queued 11:39
created

TrashItemTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 36
loc 36
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
B testObjectProperties() 30 30 4

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

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.

Loading history...
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();
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\API\Repositor...lueObject::attributes() has been deprecated with message: Since 5.0, available purely for legacy eZTemplate compatibility

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
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