forked from ezsystems/ezpublish-kernel
/
AuthorIntegrationTest.php
154 lines (145 loc) · 4.21 KB
/
AuthorIntegrationTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
/**
* File contains: eZ\Publish\SPI\Tests\FieldType\AuthorIntegrationTest class.
*
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace eZ\Publish\SPI\Tests\FieldType;
use eZ\Publish\Core\Persistence\Legacy;
use eZ\Publish\Core\FieldType;
use eZ\Publish\SPI\Persistence\Content;
/**
* Integration test for legacy storage field types.
*
* This abstract base test case is supposed to be the base for field type
* integration tests. It basically calls all involved methods in the field type
* ``Converter`` and ``Storage`` implementations. Fo get it working implement
* the abstract methods in a sensible way.
*
* The following actions are performed by this test using the custom field
* type:
*
* - Create a new content type with the given field type
* - Load create content type
* - Create content object of new content type
* - Load created content
* - Copy created content
* - Remove copied content
*
* @group integration
*/
class AuthorIntegrationTest extends BaseIntegrationTest
{
/**
* Get name of tested field type.
*
* @return string
*/
public function getTypeName()
{
return 'ezauthor';
}
/**
* Get handler with required custom field types registered.
*
* @return \eZ\Publish\SPI\Persistence\Handler
*/
public function getCustomHandler()
{
$fieldType = new FieldType\Author\Type();
$fieldType->setTransformationProcessor($this->getTransformationProcessor());
return $this->getHandler(
'ezauthor',
$fieldType,
new Legacy\Content\FieldValue\Converter\AuthorConverter(),
new FieldType\NullStorage()
);
}
/**
* Returns the FieldTypeConstraints to be used to create a field definition
* of the FieldType under test.
*
* @return \eZ\Publish\SPI\Persistence\Content\FieldTypeConstraints
*/
public function getTypeConstraints()
{
return new Content\FieldTypeConstraints();
}
/**
* Get field definition data values.
*
* This is a PHPUnit data provider
*
* @return array
*/
public function getFieldDefinitionData()
{
return array(
// The ezauthor field type does not have any special field definition
// properties
array('fieldType', 'ezauthor'),
array(
'fieldTypeConstraints',
new Content\FieldTypeConstraints(
array(
'fieldSettings' => new FieldType\FieldSettings(
array(
'defaultAuthor' => 0,
)
),
)
),
),
);
}
/**
* Get initial field value.
*
* @return \eZ\Publish\SPI\Persistence\Content\FieldValue
*/
public function getInitialValue()
{
return new Content\FieldValue(
array(
'data' => array(
array(
'id' => 14,
'name' => 'Hans Mueller',
'email' => 'hans@example.com',
),
),
'externalData' => null,
'sortKey' => null,
)
);
}
/**
* Get update field value.
*
* Use to update the field
*
* @return \eZ\Publish\SPI\Persistence\Content\FieldValue
*/
public function getUpdatedValue()
{
return new Content\FieldValue(
array(
'data' => array(
array(
'id' => 14,
'name' => 'Hans Mueller',
'email' => 'hans@example.com',
),
array(
'id' => 10,
'name' => 'Lieschen Mueller',
'email' => 'lieschen@example.com',
),
),
'externalData' => null,
'sortKey' => null,
)
);
}
}