1 | <?php |
||
21 | class SectionServiceAuthorizationTest extends BaseTest |
||
22 | { |
||
23 | /** |
||
24 | * Test for the createSection() method. |
||
25 | * |
||
26 | * @see \eZ\Publish\API\Repository\SectionService::createSection() |
||
27 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
28 | * @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testCreateSection |
||
29 | */ |
||
30 | public function testCreateSectionThrowsUnauthorizedException() |
||
31 | { |
||
32 | $repository = $this->getRepository(); |
||
33 | |||
34 | $anonymousUserId = $this->generateId('user', 10); |
||
35 | /* BEGIN: Use Case */ |
||
36 | // $anonymousUserId is the ID of the "Anonymous" user in a eZ |
||
37 | // Publish demo installation. |
||
38 | $userService = $repository->getUserService(); |
||
39 | $sectionService = $repository->getSectionService(); |
||
40 | |||
41 | $sectionCreate = $sectionService->newSectionCreateStruct(); |
||
42 | $sectionCreate->name = 'Test Section'; |
||
43 | $sectionCreate->identifier = 'uniqueKey'; |
||
44 | |||
45 | // Set anonymous user |
||
46 | $repository->setCurrentUser($userService->loadUser($anonymousUserId)); |
||
|
|||
47 | |||
48 | // This call will fail with a "UnauthorizedException" |
||
49 | $sectionService->createSection($sectionCreate); |
||
50 | /* END: Use Case */ |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * Test for the loadSection() method. |
||
55 | * |
||
56 | * @see \eZ\Publish\API\Repository\SectionService::loadSection() |
||
57 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
58 | * @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testLoadSection |
||
59 | */ |
||
60 | public function testLoadSectionThrowsUnauthorizedException() |
||
84 | |||
85 | /** |
||
86 | * Test for the updateSection() method. |
||
87 | * |
||
88 | * @see \eZ\Publish\API\Repository\SectionService::updateSection() |
||
89 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
90 | * @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testUpdateSection |
||
91 | */ |
||
92 | public function testUpdateSectionThrowsUnauthorizedException() |
||
93 | { |
||
94 | $repository = $this->getRepository(); |
||
95 | |||
96 | $standardSectionId = $this->generateId('section', 1); |
||
97 | $anonymousUserId = $this->generateId('user', 10); |
||
98 | /* BEGIN: Use Case */ |
||
99 | // $anonymousUserId is the ID of the "Anonymous" user in a eZ |
||
100 | // Publish demo installation. |
||
101 | // $standardSectionId is the ID of the "Standard" section in a eZ |
||
102 | // Publish demo installation. |
||
103 | |||
104 | $userService = $repository->getUserService(); |
||
105 | $sectionService = $repository->getSectionService(); |
||
106 | |||
107 | $section = $sectionService->loadSection($standardSectionId); |
||
108 | |||
109 | $sectionUpdate = $sectionService->newSectionUpdateStruct(); |
||
110 | $sectionUpdate->name = 'New section name'; |
||
111 | $sectionUpdate->identifier = 'newUniqueKey'; |
||
112 | |||
113 | // Set anonymous user |
||
114 | $repository->setCurrentUser($userService->loadUser($anonymousUserId)); |
||
115 | |||
116 | // This call will fail with a "UnauthorizedException" |
||
117 | $sectionService->updateSection($section, $sectionUpdate); |
||
118 | /* END: Use Case */ |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * Test for the loadSections() method. |
||
123 | * |
||
124 | * @see \eZ\Publish\API\Repository\SectionService::loadSections() |
||
125 | * @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testLoadSections |
||
126 | */ |
||
127 | public function testLoadSectionsLoadsEmptyListForAnonymousUser() |
||
158 | |||
159 | /** |
||
160 | * Test for the loadSections() method. |
||
161 | * |
||
162 | * @see \eZ\Publish\API\Repository\SectionService::loadSections() |
||
163 | * @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testLoadSections |
||
164 | */ |
||
165 | public function testLoadSectionFiltersSections() |
||
204 | |||
205 | /** |
||
206 | * Test for the loadSectionByIdentifier() method. |
||
207 | * |
||
208 | * @see \eZ\Publish\API\Repository\SectionService::loadSectionByIdentifier() |
||
209 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
210 | */ |
||
211 | public function testLoadSectionByIdentifierThrowsUnauthorizedException() |
||
235 | |||
236 | /** |
||
237 | * Test for the assignSection() method. |
||
238 | * |
||
239 | * @see \eZ\Publish\API\Repository\SectionService::assignSection() |
||
240 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
241 | */ |
||
242 | public function testAssignSectionThrowsUnauthorizedException() |
||
276 | |||
277 | /** |
||
278 | * Test for the deleteSection() method. |
||
279 | * |
||
280 | * @see \eZ\Publish\API\Repository\SectionService::deleteSection() |
||
281 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
282 | */ |
||
283 | public function testDeleteSectionThrowsUnauthorizedException() |
||
307 | } |
||
308 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.