1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* File contains: eZ\Publish\Core\Persistence\Legacy\Tests\Content\FieldValueConverterRegistryTest 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\Persistence\Legacy\Tests\Content; |
10
|
|
|
|
11
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Tests\TestCase; |
12
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\ConverterRegistry as Registry; |
13
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Test case for FieldValue Converter Registry. |
17
|
|
|
*/ |
18
|
|
|
class FieldValueConverterRegistryTest extends TestCase |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\ConverterRegistry::register |
22
|
|
|
*/ |
23
|
|
|
public function testRegister(): void |
24
|
|
|
{ |
25
|
|
|
$converter = $this->getFieldValueConverterMock(); |
26
|
|
|
$registry = new Registry(array('some-type' => $converter)); |
27
|
|
|
|
28
|
|
|
$this->assertAttributeSame( |
|
|
|
|
29
|
|
|
array( |
30
|
|
|
'some-type' => $converter, |
31
|
|
|
), |
32
|
|
|
'converterMap', |
33
|
|
|
$registry |
34
|
|
|
); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\ConverterRegistry::getConverter |
39
|
|
|
*/ |
40
|
|
|
public function testGetStorage(): void |
41
|
|
|
{ |
42
|
|
|
$converter = $this->getFieldValueConverterMock(); |
43
|
|
|
$registry = new Registry(array('some-type' => $converter)); |
44
|
|
|
|
45
|
|
|
$res = $registry->getConverter('some-type'); |
46
|
|
|
|
47
|
|
|
$this->assertSame( |
48
|
|
|
$converter, |
49
|
|
|
$res |
50
|
|
|
); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\ConverterRegistry::getConverter |
55
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\Exception\NotFound |
56
|
|
|
* @expectedException \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\Exception\NotFound |
57
|
|
|
*/ |
58
|
|
|
public function testGetNotFound(): void |
59
|
|
|
{ |
60
|
|
|
$registry = new Registry(array()); |
61
|
|
|
|
62
|
|
|
$registry->getConverter('not-found'); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\ConverterRegistry::hasConverter |
67
|
|
|
*/ |
68
|
|
View Code Duplication |
public function testHasStorage(): void |
69
|
|
|
{ |
70
|
|
|
$converter = $this->getFieldValueConverterMock(); |
71
|
|
|
$registry = new Registry(array('some-type' => $converter)); |
72
|
|
|
|
73
|
|
|
$this->assertTrue( |
74
|
|
|
$registry->hasConverter('some-type') |
75
|
|
|
); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\ConverterRegistry::hasConverter |
80
|
|
|
*/ |
81
|
|
View Code Duplication |
public function testHasNoStorage(): void |
82
|
|
|
{ |
83
|
|
|
$converter = $this->getFieldValueConverterMock(); |
84
|
|
|
$registry = new Registry(array('some-type' => $converter)); |
85
|
|
|
|
86
|
|
|
$this->assertFalse( |
87
|
|
|
$registry->hasConverter('some-other-type') |
88
|
|
|
); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @return \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter|\PHPUnit\Framework\MockObject\MockObject |
93
|
|
|
*/ |
94
|
|
|
protected function getFieldValueConverterMock() |
95
|
|
|
{ |
96
|
|
|
return $this->createMock(Converter::class); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
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.