|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* File containing the Functional\SectionTest 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 SectionTest extends RESTFunctionalTestCase |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* Covers GET /content/sections. |
|
17
|
|
|
*/ |
|
18
|
|
|
public function testListSections() |
|
19
|
|
|
{ |
|
20
|
|
|
$response = $this->sendHttpRequest( |
|
21
|
|
|
$this->createHttpRequest('GET', '/api/ezp/v2/content/sections') |
|
22
|
|
|
); |
|
23
|
|
|
|
|
24
|
|
|
self::assertHttpResponseCodeEquals($response, 200); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Covers POST /content/sections. |
|
29
|
|
|
* |
|
30
|
|
|
* @return string The created section href |
|
31
|
|
|
*/ |
|
32
|
|
View Code Duplication |
public function testCreateSection() |
|
33
|
|
|
{ |
|
34
|
|
|
$xml = <<< XML |
|
35
|
|
|
<SectionInput> |
|
36
|
|
|
<identifier>testCreateSection</identifier> |
|
37
|
|
|
<name>testCreateSection</name> |
|
38
|
|
|
</SectionInput> |
|
39
|
|
|
XML; |
|
40
|
|
|
$request = $this->createHttpRequest( |
|
41
|
|
|
'POST', |
|
42
|
|
|
'/api/ezp/v2/content/sections', |
|
43
|
|
|
'SectionInput+xml', |
|
44
|
|
|
'Section+json', |
|
45
|
|
|
$xml |
|
46
|
|
|
); |
|
47
|
|
|
$response = $this->sendHttpRequest($request); |
|
48
|
|
|
|
|
49
|
|
|
self::assertHttpResponseCodeEquals($response, 201); |
|
50
|
|
|
self::assertHttpResponseHasHeader($response, 'Location'); |
|
51
|
|
|
|
|
52
|
|
|
$href = $response->getHeader('Location')[0]; |
|
53
|
|
|
$this->addCreatedElement($href); |
|
54
|
|
|
|
|
55
|
|
|
return $href; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @param $sectionHref |
|
60
|
|
|
* @depends testCreateSection |
|
61
|
|
|
* Covers PATCH /content/sections/{sectionId} |
|
62
|
|
|
*/ |
|
63
|
|
View Code Duplication |
public function testUpdateSection($sectionHref) |
|
64
|
|
|
{ |
|
65
|
|
|
$xml = <<< XML |
|
66
|
|
|
<SectionInput> |
|
67
|
|
|
<identifier>testUpdateSection</identifier> |
|
68
|
|
|
<name>testUpdateSection</name> |
|
69
|
|
|
</SectionInput> |
|
70
|
|
|
XML; |
|
71
|
|
|
$request = $this->createHttpRequest( |
|
72
|
|
|
'PATCH', |
|
73
|
|
|
$sectionHref, |
|
74
|
|
|
'SectionInput+xml', |
|
75
|
|
|
'Section+json', |
|
76
|
|
|
$xml |
|
77
|
|
|
); |
|
78
|
|
|
$response = $this->sendHttpRequest($request); |
|
79
|
|
|
|
|
80
|
|
|
self::assertHttpResponseCodeEquals($response, 200); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Covers GET /content/sections/{sectionId}. |
|
85
|
|
|
* @depends testCreateSection |
|
86
|
|
|
*/ |
|
87
|
|
|
public function testLoadSection($sectionHref) |
|
88
|
|
|
{ |
|
89
|
|
|
$response = $this->sendHttpRequest( |
|
90
|
|
|
$this->createHttpRequest('GET', $sectionHref) |
|
91
|
|
|
); |
|
92
|
|
|
|
|
93
|
|
|
self::assertHttpResponseCodeEquals($response, 200); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* @depends testCreateSection |
|
98
|
|
|
* Covers GET /content/sections?identifier={sectionIdentifier} |
|
99
|
|
|
*/ |
|
100
|
|
|
public function testLoadSectionByIdentifier($sectionHref) |
|
|
|
|
|
|
101
|
|
|
{ |
|
102
|
|
|
$response = $this->sendHttpRequest( |
|
103
|
|
|
$this->createHttpRequest('GET', '/api/ezp/v2/content/sections?identifier=testUpdateSection') |
|
104
|
|
|
); |
|
105
|
|
|
|
|
106
|
|
|
self::assertHttpResponseCodeEquals($response, 200); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @depends testCreateSection |
|
111
|
|
|
* Covers DELETE /content/sections/{sectionId} |
|
112
|
|
|
*/ |
|
113
|
|
|
public function testDeleteSection($sectionHref) |
|
114
|
|
|
{ |
|
115
|
|
|
$response = $this->sendHttpRequest( |
|
116
|
|
|
$this->createHttpRequest('DELETE', $sectionHref) |
|
117
|
|
|
); |
|
118
|
|
|
|
|
119
|
|
|
self::assertHttpResponseCodeEquals($response, 204); |
|
120
|
|
|
} |
|
121
|
|
|
} |
|
122
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.