1 | <?php |
||
25 | class LanguageLimitationTest extends BaseTest |
||
26 | { |
||
27 | /** |
||
28 | * Create editor who is allowed to modify only specific translations of a Content item. |
||
29 | * |
||
30 | * @param array $allowedTranslationsList list of translations (language codes) which editor can modify. |
||
31 | * |
||
32 | * @return \eZ\Publish\API\Repository\Values\User\User |
||
33 | * |
||
34 | * @throws \eZ\Publish\API\Repository\Exceptions\ForbiddenException |
||
35 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
36 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
37 | */ |
||
38 | private function createEditorUserWithLanguageLimitation(array $allowedTranslationsList): User |
||
57 | |||
58 | /** |
||
59 | * @return array |
||
60 | * @see testCreateAndPublishContent |
||
61 | */ |
||
62 | public function providerForCreateAndPublishContent(): array |
||
76 | |||
77 | /** |
||
78 | * Test creating and publishing a fresh Content item in a language restricted by LanguageLimitation. |
||
79 | * |
||
80 | * @param array $names |
||
81 | * @param array $allowedTranslationsList |
||
82 | * |
||
83 | * @dataProvider providerForCreateAndPublishContent |
||
84 | * |
||
85 | * @throws \eZ\Publish\API\Repository\Exceptions\ForbiddenException |
||
86 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
87 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
88 | */ |
||
89 | public function testCreateAndPublishContent(array $names, array $allowedTranslationsList): void |
||
105 | |||
106 | /** |
||
107 | * Data provider for testPublishVersionWithLanguageLimitation. |
||
108 | * |
||
109 | * @return array |
||
110 | * @see testPublishVersionIsNotAllowedIfModifiedOtherTranslations |
||
111 | * |
||
112 | * @see testPublishVersion |
||
113 | */ |
||
114 | public function providerForPublishVersionWithLanguageLimitation(): array |
||
144 | |||
145 | /** |
||
146 | * Test publishing Version with translations restricted by LanguageLimitation. |
||
147 | * |
||
148 | * @param array $names |
||
149 | * @param array $namesToUpdate |
||
150 | * @param array $allowedTranslationsList |
||
151 | * |
||
152 | * @dataProvider providerForPublishVersionWithLanguageLimitation |
||
153 | * |
||
154 | * @covers \eZ\Publish\API\Repository\ContentService::createContentDraft |
||
155 | * @covers \eZ\Publish\API\Repository\ContentService::updateContent |
||
156 | * @covers \eZ\Publish\API\Repository\ContentService::publishVersion |
||
157 | * |
||
158 | * @throws \eZ\Publish\API\Repository\Exceptions\ForbiddenException |
||
159 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
160 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
161 | * @throws \Exception |
||
162 | */ |
||
163 | public function testPublishVersion( |
||
200 | |||
201 | /** |
||
202 | * Test that publishing version with changes to translations outside limitation values throws unauthorized exception. |
||
203 | * |
||
204 | * @param array $names |
||
205 | * |
||
206 | * @dataProvider providerForPublishVersionWithLanguageLimitation |
||
207 | * |
||
208 | * @covers \eZ\Publish\API\Repository\ContentService::createContentDraft |
||
209 | * @covers \eZ\Publish\API\Repository\ContentService::updateContent |
||
210 | * @covers \eZ\Publish\API\Repository\ContentService::publishVersion |
||
211 | * |
||
212 | * @throws \eZ\Publish\API\Repository\Exceptions\ForbiddenException |
||
213 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
214 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
215 | */ |
||
216 | public function testPublishVersionIsNotAllowedIfModifiedOtherTranslations(array $names): void |
||
238 | } |
||
239 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.