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(); |
|
|
|
|
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
|
|
|
|
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.