Completed
Push — api_content_name_shorthand ( 929e38...fc49b1 )
by André
20:47
created

ContentTest::testGetName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * File containing the ContentTest 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\Content;
12
use eZ\Publish\API\Repository\Values\Content\VersionInfo;
13
use Mockery;
14
use PHPUnit_Framework_TestCase;
15
16
class ContentTest extends PHPUnit_Framework_TestCase
17
{
18
    /**
19
     * @covers \eZ\Publish\Core\Repository\Values\Content\Content::getProperties
20
     */
21
    public function testObjectProperties()
22
    {
23
        $object = new Content(array('internalFields' => array()));
24
        $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...
25
        self::assertNotContains('internalFields', $properties, 'Internal property found ');
26
        self::assertContains('id', $properties, 'Property not found ');
27
        self::assertContains('fields', $properties, 'Property not found ');
28
        self::assertContains('versionInfo', $properties, 'Property not found ');
29
        self::assertContains('contentInfo', $properties, 'Property not found ');
30
31
        // check for duplicates and double check existence of property
32
        $propertiesHash = array();
33
        foreach ($properties as $property) {
34
            if (isset($propertiesHash[$property])) {
35
                self::fail("Property '{$property}' exists several times in properties list");
36
            } elseif (!isset($object->$property)) {
37
                self::fail("Property '{$property}' does not exist on object, even though it was hinted to be there");
38
            }
39
            $propertiesHash[$property] = 1;
40
        }
41
    }
42
43
    /**
44
     * Test getName method.
45
     *
46
     * @covers \eZ\Publish\Core\Repository\Values\Content\Content::getName
47
     */
48
    public function testGetName()
49
    {
50
        $name = 'Translated name';
51
        $versionInfoMock = Mockery::mock(VersionInfo::class);
52
        $versionInfoMock->shouldReceive('getName')->andReturn($name);
53
54
        $object = new Content(['versionInfo' => $versionInfoMock]);
55
56
        $this->assertEquals($name, $object->getName());
57
    }
58
}
59