|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* File containing a test 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\Core\REST\Server\Tests\Output\ValueObjectVisitor; |
|
12
|
|
|
|
|
13
|
|
|
use eZ\Publish\Core\REST\Common\Tests\Output\ValueObjectVisitorBaseTest; |
|
14
|
|
|
use eZ\Publish\Core\Repository\Values\User\UserGroup; |
|
15
|
|
|
use eZ\Publish\Core\REST\Server\Output\ValueObjectVisitor; |
|
16
|
|
|
use eZ\Publish\Core\REST\Server\Values\ResourceRouteReference; |
|
17
|
|
|
use eZ\Publish\Core\REST\Server\Values\UserGroupRefList; |
|
18
|
|
|
use eZ\Publish\Core\REST\Server\Values\RestUserGroup; |
|
19
|
|
|
use eZ\Publish\API\Repository\Values\Content\ContentInfo; |
|
20
|
|
|
use eZ\Publish\Core\Repository\Values\Content\Location; |
|
21
|
|
|
|
|
22
|
|
|
class UserGroupRefListTest extends ValueObjectVisitorBaseTest |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* Test the UserGroupRefList visitor. |
|
26
|
|
|
* |
|
27
|
|
|
* @return \DOMDocument |
|
28
|
|
|
*/ |
|
29
|
|
|
public function testVisit() |
|
30
|
|
|
{ |
|
31
|
|
|
$visitor = $this->getVisitor(); |
|
32
|
|
|
$generator = $this->getGenerator(); |
|
33
|
|
|
|
|
34
|
|
|
$generator->startDocument(null); |
|
35
|
|
|
|
|
36
|
|
|
$UserGroupRefList = new UserGroupRefList( |
|
37
|
|
|
array( |
|
38
|
|
|
new RestUserGroup( |
|
39
|
|
|
new UserGroup(), |
|
40
|
|
|
$this->getMockForAbstractClass('eZ\\Publish\\API\\Repository\\Values\\ContentType\\ContentType'), |
|
41
|
|
|
new ContentInfo(), |
|
42
|
|
|
new Location( |
|
43
|
|
|
array( |
|
44
|
|
|
'pathString' => '/1/5/14', |
|
45
|
|
|
'path' => array(1, 5, 14), |
|
46
|
|
|
) |
|
47
|
|
|
), |
|
48
|
|
|
array() |
|
49
|
|
|
), |
|
50
|
|
|
new RestUserGroup( |
|
51
|
|
|
new UserGroup(), |
|
52
|
|
|
$this->getMockForAbstractClass('eZ\\Publish\\API\\Repository\\Values\\ContentType\\ContentType'), |
|
53
|
|
|
new ContentInfo(), |
|
54
|
|
|
new Location( |
|
55
|
|
|
array( |
|
56
|
|
|
'pathString' => '/1/5/13', |
|
57
|
|
|
'path' => array(1, 5, 13), |
|
58
|
|
|
) |
|
59
|
|
|
), |
|
60
|
|
|
array() |
|
61
|
|
|
), |
|
62
|
|
|
), |
|
63
|
|
|
'/some/path', |
|
64
|
|
|
14 |
|
65
|
|
|
); |
|
66
|
|
|
|
|
67
|
|
|
$this->setVisitValueObjectExpectations([ |
|
68
|
|
|
new ResourceRouteReference('ezpublish_rest_loadUserGroup', ['groupPath' => '1/5/14']), |
|
|
|
|
|
|
69
|
|
|
new ResourceRouteReference('ezpublish_rest_unassignUserFromUserGroup', ['userId' => $UserGroupRefList->userId, 'groupPath' => 14]), |
|
|
|
|
|
|
70
|
|
|
new ResourceRouteReference('ezpublish_rest_loadUserGroup', ['groupPath' => '1/5/13']), |
|
|
|
|
|
|
71
|
|
|
new ResourceRouteReference('ezpublish_rest_unassignUserFromUserGroup', ['userId' => $UserGroupRefList->userId, 'groupPath' => 13]), |
|
|
|
|
|
|
72
|
|
|
]); |
|
73
|
|
|
|
|
74
|
|
|
$visitor->visit( |
|
75
|
|
|
$this->getVisitorMock(), |
|
|
|
|
|
|
76
|
|
|
$generator, |
|
77
|
|
|
$UserGroupRefList |
|
78
|
|
|
); |
|
79
|
|
|
|
|
80
|
|
|
$result = $generator->endDocument(null); |
|
81
|
|
|
|
|
82
|
|
|
$this->assertNotNull($result); |
|
83
|
|
|
|
|
84
|
|
|
$dom = new \DOMDocument(); |
|
85
|
|
|
$dom->loadXml($result); |
|
86
|
|
|
|
|
87
|
|
|
return $dom; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @param \DOMDocument $dom |
|
92
|
|
|
* |
|
93
|
|
|
* @depends testVisit |
|
94
|
|
|
*/ |
|
95
|
|
|
public function testUserGroupRefListMediaTypeCorrect(\DOMDocument $dom) |
|
96
|
|
|
{ |
|
97
|
|
|
$this->assertXPath($dom, '/UserGroupRefList[@media-type="application/vnd.ez.api.UserGroupRefList+xml"]'); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* @param \DOMDocument $dom |
|
102
|
|
|
* |
|
103
|
|
|
* @depends testVisit |
|
104
|
|
|
*/ |
|
105
|
|
|
public function testFirstUserGroupMediaTypeCorrect(\DOMDocument $dom) |
|
106
|
|
|
{ |
|
107
|
|
|
$this->assertXPath($dom, '/UserGroupRefList/UserGroup[1][@media-type="application/vnd.ez.api.UserGroup+xml"]'); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* @param \DOMDocument $dom |
|
112
|
|
|
* |
|
113
|
|
|
* @depends testVisit |
|
114
|
|
|
*/ |
|
115
|
|
|
public function testFirstUserGroupUnassignMethodCorrect(\DOMDocument $dom) |
|
116
|
|
|
{ |
|
117
|
|
|
$this->assertXPath($dom, '/UserGroupRefList/UserGroup[1]/unassign[@method="DELETE"]'); |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* @param \DOMDocument $dom |
|
122
|
|
|
* |
|
123
|
|
|
* @depends testVisit |
|
124
|
|
|
*/ |
|
125
|
|
|
public function testSecondUserGroupMediaTypeCorrect(\DOMDocument $dom) |
|
126
|
|
|
{ |
|
127
|
|
|
$this->assertXPath($dom, '/UserGroupRefList/UserGroup[2][@media-type="application/vnd.ez.api.UserGroup+xml"]'); |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @param \DOMDocument $dom |
|
132
|
|
|
* |
|
133
|
|
|
* @depends testVisit |
|
134
|
|
|
*/ |
|
135
|
|
|
public function testSecondUserGroupUnassignMethodCorrect(\DOMDocument $dom) |
|
136
|
|
|
{ |
|
137
|
|
|
$this->assertXPath($dom, '/UserGroupRefList/UserGroup[2]/unassign[@method="DELETE"]'); |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
/** |
|
141
|
|
|
* Get the UserGroupRefList visitor. |
|
142
|
|
|
* |
|
143
|
|
|
* @return \eZ\Publish\Core\REST\Server\Output\ValueObjectVisitor\UserGroupRefList |
|
144
|
|
|
*/ |
|
145
|
|
|
protected function internalGetVisitor() |
|
146
|
|
|
{ |
|
147
|
|
|
return new ValueObjectVisitor\UserGroupRefList(); |
|
148
|
|
|
} |
|
149
|
|
|
} |
|
150
|
|
|
|
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: