|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* File containing the Functional\ContentTypeTest 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\Bundle\EzPublishRestBundle\Tests\Functional; |
|
10
|
|
|
|
|
11
|
|
|
use eZ\Bundle\EzPublishRestBundle\Tests\Functional\TestCase as RESTFunctionalTestCase; |
|
12
|
|
|
|
|
13
|
|
|
class ContentTypeTest extends RESTFunctionalTestCase |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* Covers POST /content/typegroups. |
|
17
|
|
|
*/ |
|
18
|
|
View Code Duplication |
public function testCreateContentTypeGroup() |
|
19
|
|
|
{ |
|
20
|
|
|
$body = <<< XML |
|
21
|
|
|
<?xml version="1.0" encoding="UTF-8"?> |
|
22
|
|
|
<ContentTypeGroupInput> |
|
23
|
|
|
<identifier>testCreateContentTypeGroup</identifier> |
|
24
|
|
|
</ContentTypeGroupInput> |
|
25
|
|
|
XML; |
|
26
|
|
|
$request = $this->createHttpRequest( |
|
27
|
|
|
'POST', |
|
28
|
|
|
'/api/ezp/v2/content/typegroups', |
|
29
|
|
|
'ContentTypeGroupInput+xml', |
|
30
|
|
|
'ContentTypeGroup+json', |
|
31
|
|
|
$body |
|
32
|
|
|
); |
|
33
|
|
|
$response = $this->sendHttpRequest($request); |
|
34
|
|
|
|
|
35
|
|
|
self::assertHttpResponseCodeEquals($response, 201); |
|
36
|
|
|
self::assertHttpResponseHasHeader($response, 'Location'); |
|
37
|
|
|
|
|
38
|
|
|
$href = $response->getHeader('Location')[0]; |
|
39
|
|
|
$this->addCreatedElement($href); |
|
40
|
|
|
|
|
41
|
|
|
return $href; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @depends testCreateContentTypeGroup |
|
46
|
|
|
* Covers PATCH /content/typegroups/<contentTypeGroupId> |
|
47
|
|
|
* |
|
48
|
|
|
* @return string the updated content type href |
|
49
|
|
|
*/ |
|
50
|
|
View Code Duplication |
public function testUpdateContentTypeGroup($contentTypeGroupHref) |
|
51
|
|
|
{ |
|
52
|
|
|
$body = <<< XML |
|
53
|
|
|
<?xml version="1.0" encoding="UTF-8"?> |
|
54
|
|
|
<ContentTypeGroupInput> |
|
55
|
|
|
<identifier>testUpdateContentTypeGroup</identifier> |
|
56
|
|
|
</ContentTypeGroupInput> |
|
57
|
|
|
XML; |
|
58
|
|
|
|
|
59
|
|
|
$request = $this->createHttpRequest( |
|
60
|
|
|
'PATCH', |
|
61
|
|
|
$contentTypeGroupHref, |
|
62
|
|
|
'ContentTypeGroupInput+xml', |
|
63
|
|
|
'ContentTypeGroup+json', |
|
64
|
|
|
$body |
|
65
|
|
|
); |
|
66
|
|
|
$response = $this->sendHttpRequest($request); |
|
67
|
|
|
|
|
68
|
|
|
self::assertHttpResponseCodeEquals($response, 200); |
|
69
|
|
|
|
|
70
|
|
|
return $contentTypeGroupHref; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @depends testCreateContentTypeGroup |
|
75
|
|
|
* @returns string The created content type href |
|
76
|
|
|
* Covers POST /content/typegroups/<contentTypeGroupId>/types?publish=true |
|
77
|
|
|
* |
|
78
|
|
|
* @todo write test with full workflow (draft, edit, publish) |
|
79
|
|
|
*/ |
|
80
|
|
|
public function testCreateContentType($contentTypeGroupHref) |
|
81
|
|
|
{ |
|
82
|
|
|
$body = <<< XML |
|
83
|
|
|
<?xml version="1.0" encoding="UTF-8"?> |
|
84
|
|
|
<ContentTypeCreate> |
|
85
|
|
|
<identifier>tCreate</identifier> |
|
86
|
|
|
<names> |
|
87
|
|
|
<value languageCode="eng-GB">testCreateContentType</value> |
|
88
|
|
|
</names> |
|
89
|
|
|
<remoteId>testCreateContentType</remoteId> |
|
90
|
|
|
<urlAliasSchema><title></urlAliasSchema> |
|
91
|
|
|
<nameSchema><title></nameSchema> |
|
92
|
|
|
<isContainer>true</isContainer> |
|
93
|
|
|
<mainLanguageCode>eng-GB</mainLanguageCode> |
|
94
|
|
|
<defaultAlwaysAvailable>true</defaultAlwaysAvailable> |
|
95
|
|
|
<defaultSortField>PATH</defaultSortField> |
|
96
|
|
|
<defaultSortOrder>ASC</defaultSortOrder> |
|
97
|
|
|
<FieldDefinitions> |
|
98
|
|
|
<FieldDefinition> |
|
99
|
|
|
<identifier>title</identifier> |
|
100
|
|
|
<fieldType>ezstring</fieldType> |
|
101
|
|
|
<fieldGroup>content</fieldGroup> |
|
102
|
|
|
<position>1</position> |
|
103
|
|
|
<isTranslatable>true</isTranslatable> |
|
104
|
|
|
<isRequired>true</isRequired> |
|
105
|
|
|
<isInfoCollector>false</isInfoCollector> |
|
106
|
|
|
<defaultValue>New Title</defaultValue> |
|
107
|
|
|
<isSearchable>true</isSearchable> |
|
108
|
|
|
<names> |
|
109
|
|
|
<value languageCode="eng-GB">Title</value> |
|
110
|
|
|
</names> |
|
111
|
|
|
<descriptions> |
|
112
|
|
|
<value languageCode="eng-GB">This is the title</value> |
|
113
|
|
|
</descriptions> |
|
114
|
|
|
</FieldDefinition> |
|
115
|
|
|
</FieldDefinitions> |
|
116
|
|
|
</ContentTypeCreate> |
|
117
|
|
|
XML; |
|
118
|
|
|
|
|
119
|
|
|
$request = $this->createHttpRequest( |
|
120
|
|
|
'POST', |
|
121
|
|
|
"$contentTypeGroupHref/types?publish=true", |
|
122
|
|
|
'ContentTypeCreate+xml', |
|
123
|
|
|
'ContentType+json', |
|
124
|
|
|
$body |
|
125
|
|
|
); |
|
126
|
|
|
$response = $this->sendHttpRequest($request); |
|
127
|
|
|
|
|
128
|
|
|
self::assertHttpResponseCodeEquals($response, 201); |
|
129
|
|
|
self::assertHttpResponseHasHeader($response, 'Location'); |
|
130
|
|
|
|
|
131
|
|
|
$this->addCreatedElement($response->getHeader('Location')[0]); |
|
132
|
|
|
|
|
133
|
|
|
return $response->getHeader('Location')[0]; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* @depends testCreateContentTypeGroup |
|
138
|
|
|
* Covers GET /content/typegroups/<contentTypeGroupId> |
|
139
|
|
|
* |
|
140
|
|
|
* @param string $contentTypeGroupHref |
|
141
|
|
|
*/ |
|
142
|
|
|
public function testListContentTypesForGroup($contentTypeGroupHref) |
|
143
|
|
|
{ |
|
144
|
|
|
$response = $this->sendHttpRequest( |
|
145
|
|
|
$request = $this->createHttpRequest('GET', "$contentTypeGroupHref/types") |
|
146
|
|
|
); |
|
147
|
|
|
|
|
148
|
|
|
self::assertHttpResponseCodeEquals($response, 200); |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
/** |
|
152
|
|
|
* Covers GET /content/typegroups. |
|
153
|
|
|
*/ |
|
154
|
|
|
public function testLoadContentTypeGroupList() |
|
155
|
|
|
{ |
|
156
|
|
|
$response = $this->sendHttpRequest( |
|
157
|
|
|
$this->createHttpRequest('GET', '/api/ezp/v2/content/typegroups') |
|
158
|
|
|
); |
|
159
|
|
|
self::assertHttpResponseCodeEquals($response, 200); |
|
160
|
|
|
|
|
161
|
|
|
// @todo test data |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
/** |
|
165
|
|
|
* @depends testUpdateContentTypeGroup |
|
166
|
|
|
* Covers GET /content/typegroups?identifier=<contentTypeGroupIdentifier> |
|
167
|
|
|
*/ |
|
168
|
|
|
public function testLoadContentTypeGroupListWithIdentifier() |
|
169
|
|
|
{ |
|
170
|
|
|
$response = $this->sendHttpRequest( |
|
171
|
|
|
$this->createHttpRequest('GET', '/api/ezp/v2/content/typegroups?identifier=testUpdateContentTypeGroup') |
|
172
|
|
|
); |
|
173
|
|
|
// @todo Check if list filtered by identifier is supposed to send a 307 |
|
174
|
|
|
self::assertHttpResponseCodeEquals($response, 307); |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
/** |
|
178
|
|
|
* @depends testUpdateContentTypeGroup |
|
179
|
|
|
* Covers GET /content/typegroups/<contentTypeGroupId> |
|
180
|
|
|
* |
|
181
|
|
|
* @param string $contentTypeGroupHref |
|
182
|
|
|
*/ |
|
183
|
|
|
public function testLoadContentTypeGroup($contentTypeGroupHref) |
|
184
|
|
|
{ |
|
185
|
|
|
$response = $this->sendHttpRequest( |
|
186
|
|
|
$this->createHttpRequest('GET', $contentTypeGroupHref) |
|
187
|
|
|
); |
|
188
|
|
|
|
|
189
|
|
|
self::assertHttpResponseCodeEquals($response, 200); |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
/** |
|
193
|
|
|
* @depends testUpdateContentTypeGroup |
|
194
|
|
|
* Covers GET /content/typegroups/<contentTypeGroupId> |
|
195
|
|
|
* |
|
196
|
|
|
* @param string $contentTypeGroupHref |
|
197
|
|
|
*/ |
|
198
|
|
|
public function testLoadContentTypeGroupNotFound($contentTypeGroupHref) |
|
199
|
|
|
{ |
|
200
|
|
|
$response = $this->sendHttpRequest( |
|
201
|
|
|
$this->createHttpRequest('GET', "{$contentTypeGroupHref}1234") |
|
202
|
|
|
); |
|
203
|
|
|
|
|
204
|
|
|
self::assertHttpResponseCodeEquals($response, 404); |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
/** |
|
208
|
|
|
* @depends testCreateContentType |
|
209
|
|
|
* Covers GET /content/types/<contentTypeId> |
|
210
|
|
|
*/ |
|
211
|
|
|
public function testLoadContentType($contentTypeHref) |
|
212
|
|
|
{ |
|
213
|
|
|
$response = $this->sendHttpRequest( |
|
214
|
|
|
$this->createHttpRequest('GET', $contentTypeHref) |
|
215
|
|
|
); |
|
216
|
|
|
|
|
217
|
|
|
self::assertHttpResponseCodeEquals($response, 200); |
|
218
|
|
|
} |
|
219
|
|
|
|
|
220
|
|
|
/** |
|
221
|
|
|
* @depends testCreateContentType |
|
222
|
|
|
* Covers GET /content/types/<contentTypeId> |
|
223
|
|
|
*/ |
|
224
|
|
|
public function testLoadContentTypeNotFound($contentTypeHref) |
|
225
|
|
|
{ |
|
226
|
|
|
$response = $this->sendHttpRequest( |
|
227
|
|
|
$this->createHttpRequest('GET', "{$contentTypeHref}1234") |
|
228
|
|
|
); |
|
229
|
|
|
|
|
230
|
|
|
self::assertHttpResponseCodeEquals($response, 404); |
|
231
|
|
|
} |
|
232
|
|
|
|
|
233
|
|
|
/** |
|
234
|
|
|
* @depends testCreateContentType |
|
235
|
|
|
* Covers GET /content/types |
|
236
|
|
|
*/ |
|
237
|
|
|
public function testListContentTypes() |
|
238
|
|
|
{ |
|
239
|
|
|
$response = $this->sendHttpRequest( |
|
240
|
|
|
$this->createHttpRequest('GET', '/api/ezp/v2/content/types') |
|
241
|
|
|
); |
|
242
|
|
|
|
|
243
|
|
|
self::assertHttpResponseCodeEquals($response, 200); |
|
244
|
|
|
} |
|
245
|
|
|
|
|
246
|
|
|
/** |
|
247
|
|
|
* @depends testCreateContentType |
|
248
|
|
|
* Covers GET /content/types?identifier=<contentTypeIdentifier> |
|
249
|
|
|
*/ |
|
250
|
|
|
public function testListContentTypesByIdentifier() |
|
251
|
|
|
{ |
|
252
|
|
|
$response = $this->sendHttpRequest( |
|
253
|
|
|
$this->createHttpRequest('GET', '/api/ezp/v2/content/types?identifier=tCreate') |
|
254
|
|
|
); |
|
255
|
|
|
|
|
256
|
|
|
// @todo This isn't consistent with the behaviour of /content/typegroups?identifier= |
|
257
|
|
|
self::assertHttpResponseCodeEquals($response, 200); |
|
258
|
|
|
} |
|
259
|
|
|
|
|
260
|
|
|
/** |
|
261
|
|
|
* @depends testCreateContentType |
|
262
|
|
|
* Covers GET /content/types?remoteid=<contentTypeRemoteId> |
|
263
|
|
|
*/ |
|
264
|
|
|
public function testListContentTypesByRemoteId() |
|
265
|
|
|
{ |
|
266
|
|
|
$response = $this->sendHttpRequest( |
|
267
|
|
|
$this->createHttpRequest('GET', '/api/ezp/v2/content/types?remoteId=testCreateContentType') |
|
268
|
|
|
); |
|
269
|
|
|
|
|
270
|
|
|
// @todo This isn't consistent with the behaviour of /content/typegroups?identifier= |
|
271
|
|
|
self::assertHttpResponseCodeEquals($response, 200); |
|
272
|
|
|
} |
|
273
|
|
|
|
|
274
|
|
|
/** |
|
275
|
|
|
* @depends testCreateContentType |
|
276
|
|
|
* Covers COPY /content/types/<contentTypeId> |
|
277
|
|
|
* |
|
278
|
|
|
* @return string The copied content type href |
|
279
|
|
|
*/ |
|
280
|
|
|
public function testCopyContentType($sourceContentTypeHref) |
|
281
|
|
|
{ |
|
282
|
|
|
$response = $this->sendHttpRequest( |
|
283
|
|
|
$this->createHttpRequest('COPY', $sourceContentTypeHref, '', 'ContentType+json') |
|
284
|
|
|
); |
|
285
|
|
|
|
|
286
|
|
|
self::assertHttpResponseCodeEquals($response, 201); |
|
287
|
|
|
self::assertHttpResponseHasHeader($response, 'Location'); |
|
288
|
|
|
|
|
289
|
|
|
$href = $response->getHeader('Location')[0]; |
|
290
|
|
|
$this->addCreatedElement($href); |
|
291
|
|
|
|
|
292
|
|
|
return $href; |
|
293
|
|
|
|
|
294
|
|
|
// @todo test identifier (copy_of_<originalBaseIdentifier>_<newTypeId>) |
|
295
|
|
|
} |
|
296
|
|
|
|
|
297
|
|
|
/** |
|
298
|
|
|
* Covers POST /content/type/<contentTypeId>. |
|
299
|
|
|
* @depends testCopyContentType |
|
300
|
|
|
* |
|
301
|
|
|
* @return string the created content type draft href |
|
302
|
|
|
*/ |
|
303
|
|
View Code Duplication |
public function testCreateContentTypeDraft($contentTypeHref) |
|
304
|
|
|
{ |
|
305
|
|
|
$content = <<< XML |
|
306
|
|
|
<?xml version="1.0" encoding="UTF-8"?> |
|
307
|
|
|
<ContentTypeUpdate> |
|
308
|
|
|
<names> |
|
309
|
|
|
<value languageCode="eng-GB">testCreateContentTypeDraft</value> |
|
310
|
|
|
</names> |
|
311
|
|
|
</ContentTypeUpdate> |
|
312
|
|
|
XML; |
|
313
|
|
|
|
|
314
|
|
|
$request = $this->createHttpRequest( |
|
315
|
|
|
'POST', |
|
316
|
|
|
$contentTypeHref, |
|
317
|
|
|
'ContentTypeUpdate+xml', |
|
318
|
|
|
'ContentTypeInfo+json', |
|
319
|
|
|
$content |
|
320
|
|
|
); |
|
321
|
|
|
$response = $this->sendHttpRequest($request); |
|
322
|
|
|
|
|
323
|
|
|
self::assertHttpResponseCodeEquals($response, 201); |
|
324
|
|
|
self::assertHttpResponseHasHeader($response, 'Location'); |
|
325
|
|
|
|
|
326
|
|
|
$href = $response->getHeader('Location')[0]; |
|
327
|
|
|
$this->addCreatedElement($href); |
|
328
|
|
|
|
|
329
|
|
|
return $href; |
|
330
|
|
|
} |
|
331
|
|
|
|
|
332
|
|
|
/** |
|
333
|
|
|
* @depends testCreateContentTypeDraft |
|
334
|
|
|
* Covers GET /content/types/<contentTypeId>/draft |
|
335
|
|
|
*/ |
|
336
|
|
|
public function testLoadContentTypeDraft($contentTypeDraftHref) |
|
337
|
|
|
{ |
|
338
|
|
|
$response = $this->sendHttpRequest( |
|
339
|
|
|
$this->createHttpRequest('GET', $contentTypeDraftHref) |
|
340
|
|
|
); |
|
341
|
|
|
|
|
342
|
|
|
self::assertHttpResponseCodeEquals($response, 200); |
|
343
|
|
|
} |
|
344
|
|
|
|
|
345
|
|
|
/** |
|
346
|
|
|
* @depends testCreateContentTypeDraft |
|
347
|
|
|
* Covers PATCH /content/types/<contentTypeId>/draft |
|
348
|
|
|
*/ |
|
349
|
|
View Code Duplication |
public function testUpdateContentTypeDraft($contentTypeDraftHref) |
|
350
|
|
|
{ |
|
351
|
|
|
$content = <<< XML |
|
352
|
|
|
<?xml version="1.0" encoding="UTF-8"?> |
|
353
|
|
|
<ContentTypeUpdate> |
|
354
|
|
|
<names> |
|
355
|
|
|
<value languageCode="eng-GB">testUpdateContentTypeDraft</value> |
|
356
|
|
|
</names> |
|
357
|
|
|
</ContentTypeUpdate> |
|
358
|
|
|
XML; |
|
359
|
|
|
|
|
360
|
|
|
$request = $this->createHttpRequest( |
|
361
|
|
|
'PATCH', |
|
362
|
|
|
$contentTypeDraftHref, |
|
363
|
|
|
'ContentTypeUpdate+xml', |
|
364
|
|
|
'ContentTypeInfo+json', |
|
365
|
|
|
$content |
|
366
|
|
|
); |
|
367
|
|
|
$response = $this->sendHttpRequest($request); |
|
368
|
|
|
|
|
369
|
|
|
self::assertHttpResponseCodeEquals($response, 200); |
|
370
|
|
|
} |
|
371
|
|
|
|
|
372
|
|
|
/** |
|
373
|
|
|
* Covers POST /content/types/<contentTypeId>/draft/fielddefinitions. |
|
374
|
|
|
* @depends testCreateContentTypeDraft |
|
375
|
|
|
* |
|
376
|
|
|
* @return string The content type draft field definition href |
|
377
|
|
|
*/ |
|
378
|
|
View Code Duplication |
public function testAddContentTypeDraftFieldDefinition($contentTypeDraftHref) |
|
379
|
|
|
{ |
|
380
|
|
|
$body = <<< XML |
|
381
|
|
|
<?xml version="1.0" encoding="UTF-8"?> |
|
382
|
|
|
<FieldDefinition> |
|
383
|
|
|
<identifier>secondtext</identifier> |
|
384
|
|
|
<fieldType>ezstring</fieldType> |
|
385
|
|
|
<fieldGroup>content</fieldGroup> |
|
386
|
|
|
<position>1</position> |
|
387
|
|
|
<isTranslatable>true</isTranslatable> |
|
388
|
|
|
<isRequired>true</isRequired> |
|
389
|
|
|
<isInfoCollector>false</isInfoCollector> |
|
390
|
|
|
<defaultValue>Second text</defaultValue> |
|
391
|
|
|
<isSearchable>true</isSearchable> |
|
392
|
|
|
<names> |
|
393
|
|
|
<value languageCode="eng-GB">Second text</value> |
|
394
|
|
|
</names> |
|
395
|
|
|
</FieldDefinition> |
|
396
|
|
|
XML; |
|
397
|
|
|
|
|
398
|
|
|
$request = $this->createHttpRequest( |
|
399
|
|
|
'POST', |
|
400
|
|
|
"$contentTypeDraftHref/fieldDefinitions", |
|
401
|
|
|
'FieldDefinitionCreate+xml', |
|
402
|
|
|
'FieldDefinition+json', |
|
403
|
|
|
$body |
|
404
|
|
|
); |
|
405
|
|
|
$response = $this->sendHttpRequest($request); |
|
406
|
|
|
|
|
407
|
|
|
self::assertHttpResponseCodeEquals($response, 201); |
|
408
|
|
|
self::assertHttpResponseHasHeader($response, 'Location'); |
|
409
|
|
|
|
|
410
|
|
|
return $response->getHeader('Location')[0]; |
|
411
|
|
|
} |
|
412
|
|
|
|
|
413
|
|
|
/** |
|
414
|
|
|
* @depends testCreateContentType |
|
415
|
|
|
* Covers GET /content/types/<contentTypeId>/fieldDefinitions |
|
416
|
|
|
* |
|
417
|
|
|
* @return string the href of the first field definition in the list |
|
418
|
|
|
*/ |
|
419
|
|
|
public function testContentTypeLoadFieldDefinitionList($contentTypeHref) |
|
420
|
|
|
{ |
|
421
|
|
|
$response = $this->sendHttpRequest( |
|
422
|
|
|
$this->createHttpRequest('GET', "$contentTypeHref/fieldDefinitions", '', 'FieldDefinitionList+json') |
|
423
|
|
|
); |
|
424
|
|
|
|
|
425
|
|
|
self::assertHttpResponseCodeEquals($response, 200); |
|
426
|
|
|
|
|
427
|
|
|
$data = json_decode($response->getBody(), true); |
|
428
|
|
|
|
|
429
|
|
|
return $data['FieldDefinitions']['FieldDefinition'][0]['_href']; |
|
430
|
|
|
} |
|
431
|
|
|
|
|
432
|
|
|
/** |
|
433
|
|
|
* @depends testAddContentTypeDraftFieldDefinition |
|
434
|
|
|
* Covers GET /content/types/<contentTypeId>/fieldDefinitions/<fieldDefinitionId> |
|
435
|
|
|
* |
|
436
|
|
|
* @param string $fieldDefinitionHref |
|
437
|
|
|
* |
|
438
|
|
|
* @throws \Psr\Http\Client\ClientException |
|
439
|
|
|
*/ |
|
440
|
|
|
public function testLoadContentTypeFieldDefinition(string $fieldDefinitionHref) |
|
441
|
|
|
{ |
|
442
|
|
|
$response = $this->sendHttpRequest( |
|
443
|
|
|
$this->createHttpRequest('GET', $fieldDefinitionHref) |
|
444
|
|
|
); |
|
445
|
|
|
|
|
446
|
|
|
self::assertHttpResponseCodeEquals($response, 200); |
|
447
|
|
|
} |
|
448
|
|
|
|
|
449
|
|
|
/** |
|
450
|
|
|
* @depends testAddContentTypeDraftFieldDefinition |
|
451
|
|
|
* Covers PATCH /content/types/<contentTypeId>/fieldDefinitions/<fieldDefinitionId> |
|
452
|
|
|
* |
|
453
|
|
|
* @todo the spec says PUT... |
|
454
|
|
|
*/ |
|
455
|
|
View Code Duplication |
public function testUpdateContentTypeDraftFieldDefinition($fieldDefinitionHref) |
|
456
|
|
|
{ |
|
457
|
|
|
$body = <<< XML |
|
458
|
|
|
<?xml version="1.0" encoding="UTF-8"?> |
|
459
|
|
|
<FieldDefinitionUpdate> |
|
460
|
|
|
<identifier>updated_secondtext</identifier> |
|
461
|
|
|
<names> |
|
462
|
|
|
<value languageCode="eng-GB">Updated second text</value> |
|
463
|
|
|
</names> |
|
464
|
|
|
<defaultValue>Updated default value</defaultValue> |
|
465
|
|
|
</FieldDefinitionUpdate> |
|
466
|
|
|
XML; |
|
467
|
|
|
|
|
468
|
|
|
$request = $this->createHttpRequest( |
|
469
|
|
|
'PATCH', |
|
470
|
|
|
$fieldDefinitionHref, |
|
471
|
|
|
'FieldDefinitionUpdate+xml', |
|
472
|
|
|
'FieldDefinition+json', |
|
473
|
|
|
$body |
|
474
|
|
|
); |
|
475
|
|
|
$response = $this->sendHttpRequest($request); |
|
476
|
|
|
|
|
477
|
|
|
self::assertHttpResponseCodeEquals($response, 200); |
|
478
|
|
|
} |
|
479
|
|
|
|
|
480
|
|
|
/** |
|
481
|
|
|
* Covers DELETE /content/types/<contentTypeId>/draft/fieldDefinitions/<fieldDefinitionId>. |
|
482
|
|
|
* @depends testAddContentTypeDraftFieldDefinition |
|
483
|
|
|
* |
|
484
|
|
|
* @param string $fieldDefinitionHref |
|
485
|
|
|
*/ |
|
486
|
|
|
public function deleteContentTypeDraftFieldDefinition(string $fieldDefinitionHref) |
|
487
|
|
|
{ |
|
488
|
|
|
$response = $this->sendHttpRequest( |
|
489
|
|
|
$this->createHttpRequest('DELETE', $fieldDefinitionHref) |
|
490
|
|
|
); |
|
491
|
|
|
|
|
492
|
|
|
self::assertHttpResponseCodeEquals($response, 204); |
|
493
|
|
|
} |
|
494
|
|
|
|
|
495
|
|
|
/** |
|
496
|
|
|
* Covers DELETE /content/types/<contentTypeId>/draft. |
|
497
|
|
|
* @depends testCreateContentTypeDraft |
|
498
|
|
|
*/ |
|
499
|
|
|
public function testDeleteContentTypeDraft($contentTypeDraftHref) |
|
500
|
|
|
{ |
|
501
|
|
|
$response = $this->sendHttpRequest( |
|
502
|
|
|
$this->createHttpRequest('DELETE', $contentTypeDraftHref) |
|
503
|
|
|
); |
|
504
|
|
|
|
|
505
|
|
|
self::assertHttpResponseCodeEquals($response, 204); |
|
506
|
|
|
} |
|
507
|
|
|
|
|
508
|
|
|
/** |
|
509
|
|
|
* @depends testCreateContentType |
|
510
|
|
|
* Covers PUBLISH /content/types/<contentTypeId>/draft |
|
511
|
|
|
*/ |
|
512
|
|
|
public function testPublishContentTypeDraft($contentTypeHref) |
|
513
|
|
|
{ |
|
514
|
|
|
// we need to create a content type draft first since we deleted the previous one in testDeleteContentTypeDraft |
|
515
|
|
|
$contentTypeDraftHref = $this->testCreateContentTypeDraft($contentTypeHref); |
|
516
|
|
|
|
|
517
|
|
|
$response = $this->sendHttpRequest( |
|
518
|
|
|
$this->createHttpRequest('PUBLISH', $contentTypeDraftHref) |
|
519
|
|
|
); |
|
520
|
|
|
|
|
521
|
|
|
self::assertHttpResponseCodeEquals($response, 200); |
|
522
|
|
|
} |
|
523
|
|
|
|
|
524
|
|
|
/** |
|
525
|
|
|
* @depends testCreateContentType |
|
526
|
|
|
* Covers GET /content/types/<contentTypeId>/groups |
|
527
|
|
|
*/ |
|
528
|
|
|
public function testLoadGroupsOfContentType($contentTypeHref) |
|
529
|
|
|
{ |
|
530
|
|
|
$response = $this->sendHttpRequest( |
|
531
|
|
|
$this->createHttpRequest('GET', "$contentTypeHref/groups", '', 'ContentTypeGroupRefList+json') |
|
532
|
|
|
); |
|
533
|
|
|
|
|
534
|
|
|
self::assertHttpResponseCodeEquals($response, 200); |
|
535
|
|
|
} |
|
536
|
|
|
|
|
537
|
|
|
/** |
|
538
|
|
|
* @depends testCreateContentType |
|
539
|
|
|
* Covers POST /content/types/<contentTypeId>/groups |
|
540
|
|
|
* |
|
541
|
|
|
* @return string the content type href |
|
542
|
|
|
*/ |
|
543
|
|
|
public function testLinkContentTypeToGroup($contentTypeHref) |
|
544
|
|
|
{ |
|
545
|
|
|
// @todo Spec example is invalid, missing parameter name |
|
546
|
|
|
$request = $this->createHttpRequest('POST', "$contentTypeHref/groups?group=/api/ezp/v2/content/typegroups/1"); |
|
547
|
|
|
$response = $this->sendHttpRequest($request); |
|
548
|
|
|
self::assertHttpResponseCodeEquals($response, 200); |
|
549
|
|
|
|
|
550
|
|
|
return $contentTypeHref; |
|
551
|
|
|
} |
|
552
|
|
|
|
|
553
|
|
|
/** |
|
554
|
|
|
* @depends testLinkContentTypeToGroup |
|
555
|
|
|
* Covers DELETE /content/types/{contentTypeId}/groups/{contentTypeGroupId} |
|
556
|
|
|
*/ |
|
557
|
|
|
public function testUnlinkContentTypeFromGroup($contentTypeHref) |
|
558
|
|
|
{ |
|
559
|
|
|
$response = $this->sendHttpRequest( |
|
560
|
|
|
$this->createHttpRequest('DELETE', "$contentTypeHref/groups/1") |
|
561
|
|
|
); |
|
562
|
|
|
|
|
563
|
|
|
self::assertHttpResponseCodeEquals($response, 200); |
|
564
|
|
|
} |
|
565
|
|
|
|
|
566
|
|
|
/** |
|
567
|
|
|
* @depends testCreateContentType |
|
568
|
|
|
*/ |
|
569
|
|
|
public function testDeleteContentType($contentTypeHref) |
|
570
|
|
|
{ |
|
571
|
|
|
$response = $this->sendHttpRequest( |
|
572
|
|
|
$this->createHttpRequest('DELETE', $contentTypeHref) |
|
573
|
|
|
); |
|
574
|
|
|
|
|
575
|
|
|
self::assertHttpResponseCodeEquals($response, 204); |
|
576
|
|
|
} |
|
577
|
|
|
|
|
578
|
|
|
/** |
|
579
|
|
|
* @depends testCreateContentTypeGroup |
|
580
|
|
|
* Covers DELETE /content/typegroups/<contentTypeGroupId> |
|
581
|
|
|
*/ |
|
582
|
|
|
public function testDeleteContentTypeGroupNotEmpty($contentTypeGroupHref) |
|
583
|
|
|
{ |
|
584
|
|
|
$response = $this->sendHttpRequest( |
|
585
|
|
|
$this->createHttpRequest('DELETE', $contentTypeGroupHref) |
|
586
|
|
|
); |
|
587
|
|
|
|
|
588
|
|
|
self::assertHttpResponseCodeEquals($response, 403); |
|
589
|
|
|
} |
|
590
|
|
|
} |
|
591
|
|
|
|