|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* File contains: eZ\Publish\SPI\Tests\FieldType\PageIntegrationTest 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
|
|
|
* @version //autogentag// |
|
10
|
|
|
*/ |
|
11
|
|
|
namespace eZ\Publish\SPI\Tests\FieldType; |
|
12
|
|
|
|
|
13
|
|
|
use eZ\Publish\Core\FieldType; |
|
14
|
|
|
use eZ\Publish\Core\FieldType\FieldSettings; |
|
15
|
|
|
use eZ\Publish\Core\FieldType\Page\Parts\Block; |
|
16
|
|
|
use eZ\Publish\Core\FieldType\Page\Parts\Page; |
|
17
|
|
|
use eZ\Publish\Core\FieldType\Page\Parts\Zone; |
|
18
|
|
|
use eZ\Publish\Core\Persistence\Legacy; |
|
19
|
|
|
use eZ\Publish\SPI\Persistence\Content; |
|
20
|
|
|
use eZ\Publish\SPI\Persistence\Content\FieldTypeConstraints; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Integration test for legacy storage field types. |
|
24
|
|
|
* |
|
25
|
|
|
* This abstract base test case is supposed to be the base for field type |
|
26
|
|
|
* integration tests. It basically calls all involved methods in the field type |
|
27
|
|
|
* ``Converter`` and ``Storage`` implementations. Fo get it working implement |
|
28
|
|
|
* the abstract methods in a sensible way. |
|
29
|
|
|
* |
|
30
|
|
|
* The following actions are performed by this test using the custom field |
|
31
|
|
|
* type: |
|
32
|
|
|
* |
|
33
|
|
|
* - Create a new content type with the given field type |
|
34
|
|
|
* - Load create content type |
|
35
|
|
|
* - Create content object of new content type |
|
36
|
|
|
* - Load created content |
|
37
|
|
|
* - Copy created content |
|
38
|
|
|
* - Remove copied content |
|
39
|
|
|
* |
|
40
|
|
|
* @group integration |
|
41
|
|
|
*/ |
|
42
|
|
|
class PageIntegrationTest extends BaseIntegrationTest |
|
43
|
|
|
{ |
|
44
|
|
|
/** |
|
45
|
|
|
* Get name of tested field type. |
|
46
|
|
|
* |
|
47
|
|
|
* @return string |
|
48
|
|
|
*/ |
|
49
|
|
|
public function getTypeName() |
|
50
|
|
|
{ |
|
51
|
|
|
return 'ezpage'; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Get handler with required custom field types registered. |
|
56
|
|
|
* |
|
57
|
|
|
* @return \eZ\Publish\SPI\Persistence\Handler |
|
58
|
|
|
*/ |
|
59
|
|
|
public function getCustomHandler() |
|
60
|
|
|
{ |
|
61
|
|
|
$contentService = $this->getMockBuilder('eZ\Publish\Core\Repository\ContentService') |
|
62
|
|
|
->disableOriginalConstructor()->getMock(); |
|
63
|
|
|
$pageService = new FieldType\Page\PageService($contentService); |
|
64
|
|
|
$hashConverter = new FieldType\Page\HashConverter(); |
|
65
|
|
|
$fieldType = new FieldType\Page\Type($pageService, $hashConverter); |
|
66
|
|
|
$fieldType->setTransformationProcessor($this->getTransformationProcessor()); |
|
67
|
|
|
|
|
68
|
|
|
return $this->getHandler('ezpage', $fieldType, new Legacy\Content\FieldValue\Converter\PageConverter(), new FieldType\NullStorage()); |
|
|
|
|
|
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Returns the FieldTypeConstraints to be used to create a field definition |
|
73
|
|
|
* of the FieldType under test. |
|
74
|
|
|
* |
|
75
|
|
|
* @return \eZ\Publish\SPI\Persistence\Content\FieldTypeConstraints |
|
76
|
|
|
*/ |
|
77
|
|
|
public function getTypeConstraints() |
|
78
|
|
|
{ |
|
79
|
|
|
return new Content\FieldTypeConstraints(); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Get field definition data values. |
|
84
|
|
|
* |
|
85
|
|
|
* This is a PHPUnit data provider |
|
86
|
|
|
* |
|
87
|
|
|
* @return array |
|
88
|
|
|
*/ |
|
89
|
|
|
public function getFieldDefinitionData() |
|
90
|
|
|
{ |
|
91
|
|
|
return array( |
|
92
|
|
|
// properties |
|
93
|
|
|
array('fieldType', 'ezpage'), |
|
94
|
|
|
array( |
|
95
|
|
|
'fieldTypeConstraints', |
|
96
|
|
|
new FieldTypeConstraints( |
|
97
|
|
|
array( |
|
98
|
|
|
'fieldSettings' => new FieldSettings( |
|
99
|
|
|
array( |
|
100
|
|
|
'defaultLayout' => '', |
|
101
|
|
|
) |
|
102
|
|
|
), |
|
103
|
|
|
) |
|
104
|
|
|
), |
|
105
|
|
|
), |
|
106
|
|
|
); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* Get initial field value. |
|
111
|
|
|
* |
|
112
|
|
|
* @return \eZ\Publish\SPI\Persistence\Content\FieldValue |
|
113
|
|
|
*/ |
|
114
|
|
|
public function getInitialValue() |
|
115
|
|
|
{ |
|
116
|
|
|
return new Content\FieldValue( |
|
117
|
|
|
array( |
|
118
|
|
|
'data' => $this->getPage(), |
|
119
|
|
|
'externalData' => null, |
|
120
|
|
|
'sortKey' => null, |
|
121
|
|
|
) |
|
122
|
|
|
); |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* Get update field value. |
|
127
|
|
|
* |
|
128
|
|
|
* Use to update the field |
|
129
|
|
|
* |
|
130
|
|
|
* @return \eZ\Publish\SPI\Persistence\Content\FieldValue |
|
131
|
|
|
*/ |
|
132
|
|
|
public function getUpdatedValue() |
|
133
|
|
|
{ |
|
134
|
|
|
return new Content\FieldValue( |
|
135
|
|
|
array( |
|
136
|
|
|
'data' => $this->getPage(), |
|
137
|
|
|
'externalData' => null, |
|
138
|
|
|
'sortKey' => null, |
|
139
|
|
|
) |
|
140
|
|
|
); |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* Create a dummy page object. |
|
145
|
|
|
* |
|
146
|
|
|
* @return Page |
|
147
|
|
|
*/ |
|
148
|
|
View Code Duplication |
protected function getPage() |
|
149
|
|
|
{ |
|
150
|
|
|
$blockData = array( |
|
151
|
|
|
'name' => 'Block 1', |
|
152
|
|
|
'id' => '50dc64c82efa83cfe53959240e159915', |
|
153
|
|
|
); |
|
154
|
|
|
$block = new Block($blockData); |
|
155
|
|
|
$zoneData = array( |
|
156
|
|
|
'id' => '8386907d951657e087507f49a92bb06c', |
|
157
|
|
|
'identifier' => 'Zone 1', |
|
158
|
|
|
'blocks' => array($block), |
|
159
|
|
|
); |
|
160
|
|
|
$zone = new Zone($zoneData); |
|
161
|
|
|
$pageData = array( |
|
162
|
|
|
'zones' => array($zone), |
|
163
|
|
|
'layout' => 'my_layout', |
|
164
|
|
|
); |
|
165
|
|
|
|
|
166
|
|
|
return new Page($pageData); |
|
167
|
|
|
} |
|
168
|
|
|
} |
|
169
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: