| @@ 622-646 (lines=25) @@ | ||
| 619 | * @depends eZ\Publish\API\Repository\Tests\RepositoryTest::testGetContentService |
|
| 620 | * @depends eZ\Publish\API\Repository\Tests\RepositoryTest::testHasAccessLimited |
|
| 621 | */ |
|
| 622 | public function testCanUserWithLimitationYes() |
|
| 623 | { |
|
| 624 | $repository = $this->getRepository(); |
|
| 625 | ||
| 626 | $imagesFolderId = $this->generateId('object', 49); |
|
| 627 | ||
| 628 | /* BEGIN: Use Case */ |
|
| 629 | // $imagesFolderId contains the ID of the "Images" folder |
|
| 630 | ||
| 631 | $user = $this->createUserVersion1(); |
|
| 632 | ||
| 633 | // Set created user as current user |
|
| 634 | $repository->setCurrentUser($user); |
|
| 635 | ||
| 636 | $contentService = $repository->getContentService(); |
|
| 637 | ||
| 638 | // Performing an action having necessary permissions will succeed |
|
| 639 | $imagesFolder = $contentService->loadContent($imagesFolderId); |
|
| 640 | ||
| 641 | // This call will return true |
|
| 642 | $canUser = $repository->canUser('content', 'read', $imagesFolder); |
|
| 643 | /* END: Use Case */ |
|
| 644 | ||
| 645 | $this->assertTrue($canUser); |
|
| 646 | } |
|
| 647 | ||
| 648 | /** |
|
| 649 | * Test for the canUser() method. |
|
| @@ 969-997 (lines=29) @@ | ||
| 966 | * @depends eZ\Publish\API\Repository\Tests\RepositoryTest::testHasAccessLimited |
|
| 967 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 968 | */ |
|
| 969 | public function testCanUserWithTargetThrowsInvalidArgumentException() |
|
| 970 | { |
|
| 971 | $repository = $this->getRepository(); |
|
| 972 | ||
| 973 | $homeId = $this->generateId('object', 57); |
|
| 974 | ||
| 975 | /* BEGIN: Use Case */ |
|
| 976 | // $homeId contains the ID of the "Home" frontpage |
|
| 977 | ||
| 978 | $user = $this->createUserVersion1(); |
|
| 979 | ||
| 980 | // Set created user as current user |
|
| 981 | $repository->setCurrentUser($user); |
|
| 982 | ||
| 983 | $contentService = $repository->getContentService(); |
|
| 984 | ||
| 985 | // Load the ContentInfo for "Home" frontpage |
|
| 986 | $contentInfo = $contentService->loadContentInfo($homeId); |
|
| 987 | ||
| 988 | // This call will throw "InvalidArgumentException" because $targets argument must be an |
|
| 989 | // instance of \eZ\Publish\API\Repository\Values\ValueObject class or an array of the same |
|
| 990 | $canUser = $repository->canUser( |
|
| 991 | 'content', |
|
| 992 | 'remove', |
|
| 993 | $contentInfo, |
|
| 994 | new \stdClass() |
|
| 995 | ); |
|
| 996 | /* END: Use Case */ |
|
| 997 | } |
|
| 998 | ||
| 999 | /** |
|
| 1000 | * Test for the canUser() method. |
|
| @@ 133-158 (lines=26) @@ | ||
| 130 | * @depends eZ\Publish\API\Repository\Tests\RepositoryTest::testGetUserService |
|
| 131 | * @depends eZ\Publish\API\Repository\Tests\PermissionResolverTest::testHasAccessWithAnonymousUserNo |
|
| 132 | */ |
|
| 133 | public function testHasAccessForCurrentUserNo() |
|
| 134 | { |
|
| 135 | $repository = $this->getRepository(); |
|
| 136 | ||
| 137 | $anonymousUserId = $this->generateId('user', 10); |
|
| 138 | ||
| 139 | /* BEGIN: Use Case */ |
|
| 140 | // $anonymousUserId is the ID of the "Anonymous" user in a eZ |
|
| 141 | // Publish demo installation. |
|
| 142 | ||
| 143 | $userService = $repository->getUserService(); |
|
| 144 | $permissionResolver = $repository->getPermissionResolver(); |
|
| 145 | ||
| 146 | // Load anonymous user |
|
| 147 | $anonymousUser = $userService->loadUser($anonymousUserId); |
|
| 148 | ||
| 149 | // Set anonymous user as current user reference |
|
| 150 | $permissionResolver->setCurrentUserReference($anonymousUser); |
|
| 151 | ||
| 152 | // This call will return false because anonymous user does not have access |
|
| 153 | // to content removal |
|
| 154 | $hasAccess = $permissionResolver->hasAccess('content', 'remove'); |
|
| 155 | /* END: Use Case */ |
|
| 156 | ||
| 157 | $this->assertFalse($hasAccess); |
|
| 158 | } |
|
| 159 | ||
| 160 | /** |
|
| 161 | * Test for the hasAccess() method. |
|
| @@ 196-219 (lines=24) @@ | ||
| 193 | * @depends eZ\Publish\API\Repository\Tests\PermissionResolverTest::testSetCurrentUserReference |
|
| 194 | * @depends eZ\Publish\API\Repository\Tests\PermissionResolverTest::testHasAccessWithAdministratorUser |
|
| 195 | */ |
|
| 196 | public function testHasAccessForCurrentUserYes() |
|
| 197 | { |
|
| 198 | $repository = $this->getRepository(); |
|
| 199 | ||
| 200 | $administratorUserId = $this->generateId('user', 14); |
|
| 201 | ||
| 202 | /* BEGIN: Use Case */ |
|
| 203 | // $administratorUserId contains the ID of the administrator user |
|
| 204 | ||
| 205 | $userService = $repository->getUserService(); |
|
| 206 | $permissionResolver = $repository->getPermissionResolver(); |
|
| 207 | ||
| 208 | // Load administrator user |
|
| 209 | $administratorUser = $userService->loadUser($administratorUserId); |
|
| 210 | ||
| 211 | // Set administrator user as current user reference |
|
| 212 | $permissionResolver->setCurrentUserReference($administratorUser); |
|
| 213 | ||
| 214 | // This call will return true |
|
| 215 | $hasAccess = $permissionResolver->hasAccess('content', 'read'); |
|
| 216 | /* END: Use Case */ |
|
| 217 | ||
| 218 | $this->assertTrue($hasAccess); |
|
| 219 | } |
|
| 220 | ||
| 221 | /** |
|
| 222 | * Test for the hasAccess() method. |
|
| @@ 349-375 (lines=27) @@ | ||
| 346 | * @depends eZ\Publish\API\Repository\Tests\RepositoryTest::testGetContentService |
|
| 347 | * @depends eZ\Publish\API\Repository\Tests\PermissionResolverTest::testHasAccessLimited |
|
| 348 | */ |
|
| 349 | public function testCanUserWithLimitationYes() |
|
| 350 | { |
|
| 351 | $repository = $this->getRepository(); |
|
| 352 | ||
| 353 | $imagesFolderId = $this->generateId('object', 49); |
|
| 354 | ||
| 355 | /* BEGIN: Use Case */ |
|
| 356 | // $imagesFolderId contains the ID of the "Images" folder |
|
| 357 | ||
| 358 | $user = $this->createUserVersion1(); |
|
| 359 | ||
| 360 | $permissionResolver = $repository->getPermissionResolver(); |
|
| 361 | ||
| 362 | // Set created user as current user reference |
|
| 363 | $permissionResolver->setCurrentUserReference($user); |
|
| 364 | ||
| 365 | $contentService = $repository->getContentService(); |
|
| 366 | ||
| 367 | // Performing an action having necessary permissions will succeed |
|
| 368 | $imagesFolder = $contentService->loadContent($imagesFolderId); |
|
| 369 | ||
| 370 | // This call will return true |
|
| 371 | $canUser = $permissionResolver->canUser('content', 'read', $imagesFolder); |
|
| 372 | /* END: Use Case */ |
|
| 373 | ||
| 374 | $this->assertTrue($canUser); |
|
| 375 | } |
|
| 376 | ||
| 377 | /** |
|
| 378 | * Test for the canUser() method. |
|
| @@ 309-331 (lines=23) @@ | ||
| 306 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 307 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testRemoveFieldDefinition |
|
| 308 | */ |
|
| 309 | public function testRemoveFieldDefinitionThrowsUnauthorizedException() |
|
| 310 | { |
|
| 311 | $repository = $this->getRepository(); |
|
| 312 | $contentTypeService = $repository->getContentTypeService(); |
|
| 313 | ||
| 314 | $anonymousUserId = $this->generateId('user', 10); |
|
| 315 | /* BEGIN: Use Case */ |
|
| 316 | // $anonymousUserId is the ID of the "Anonymous" user in a eZ |
|
| 317 | // Publish demo installation. |
|
| 318 | $contentTypeDraft = $this->createContentTypeDraft(); |
|
| 319 | ||
| 320 | // Load the user service |
|
| 321 | $userService = $repository->getUserService(); |
|
| 322 | ||
| 323 | // Set anonymous user |
|
| 324 | $repository->setCurrentUser($userService->loadUser($anonymousUserId)); |
|
| 325 | ||
| 326 | $bodyField = $contentTypeDraft->getFieldDefinition('body'); |
|
| 327 | ||
| 328 | // This call will fail with a "UnauthorizedException" |
|
| 329 | $contentTypeService->removeFieldDefinition($contentTypeDraft, $bodyField); |
|
| 330 | /* END: Use Case */ |
|
| 331 | } |
|
| 332 | ||
| 333 | /** |
|
| 334 | * Test for the updateFieldDefinition() method. |
|
| @@ 425-446 (lines=22) @@ | ||
| 422 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 423 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentTypeDraft |
|
| 424 | */ |
|
| 425 | public function testCreateContentTypeDraftThrowsUnauthorizedException() |
|
| 426 | { |
|
| 427 | $repository = $this->getRepository(); |
|
| 428 | ||
| 429 | $anonymousUserId = $this->generateId('user', 10); |
|
| 430 | /* BEGIN: Use Case */ |
|
| 431 | // $anonymousUserId is the ID of the "Anonymous" user in a eZ |
|
| 432 | // Publish demo installation. |
|
| 433 | $contentTypeService = $repository->getContentTypeService(); |
|
| 434 | ||
| 435 | // Load the user service |
|
| 436 | $userService = $repository->getUserService(); |
|
| 437 | ||
| 438 | // Set anonymous user |
|
| 439 | $repository->setCurrentUser($userService->loadUser($anonymousUserId)); |
|
| 440 | ||
| 441 | $commentType = $contentTypeService->loadContentTypeByIdentifier('comment'); |
|
| 442 | ||
| 443 | // This call will fail with a "UnauthorizedException" |
|
| 444 | $contentTypeService->createContentTypeDraft($commentType); |
|
| 445 | /* END: Use Case */ |
|
| 446 | } |
|
| 447 | ||
| 448 | /** |
|
| 449 | * Test for the deleteContentType() method. |
|
| @@ 455-476 (lines=22) @@ | ||
| 452 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 453 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testDeleteContentType |
|
| 454 | */ |
|
| 455 | public function testDeleteContentTypeThrowsUnauthorizedException() |
|
| 456 | { |
|
| 457 | $repository = $this->getRepository(); |
|
| 458 | ||
| 459 | $anonymousUserId = $this->generateId('user', 10); |
|
| 460 | /* BEGIN: Use Case */ |
|
| 461 | // $anonymousUserId is the ID of the "Anonymous" user in a eZ |
|
| 462 | // Publish demo installation. |
|
| 463 | $contentTypeService = $repository->getContentTypeService(); |
|
| 464 | ||
| 465 | // Load the user service |
|
| 466 | $userService = $repository->getUserService(); |
|
| 467 | ||
| 468 | // Set anonymous user |
|
| 469 | $repository->setCurrentUser($userService->loadUser($anonymousUserId)); |
|
| 470 | ||
| 471 | $commentType = $contentTypeService->loadContentTypeByIdentifier('comment'); |
|
| 472 | ||
| 473 | // This call will fail with a "UnauthorizedException" |
|
| 474 | $contentTypeService->deleteContentType($commentType); |
|
| 475 | /* END: Use Case */ |
|
| 476 | } |
|
| 477 | ||
| 478 | /** |
|
| 479 | * Test for the copyContentType() method. |
|
| @@ 485-506 (lines=22) @@ | ||
| 482 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 483 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCopyContentType |
|
| 484 | */ |
|
| 485 | public function testCopyContentTypeThrowsUnauthorizedException() |
|
| 486 | { |
|
| 487 | $repository = $this->getRepository(); |
|
| 488 | ||
| 489 | $anonymousUserId = $this->generateId('user', 10); |
|
| 490 | /* BEGIN: Use Case */ |
|
| 491 | // $anonymousUserId is the ID of the "Anonymous" user in a eZ |
|
| 492 | // Publish demo installation. |
|
| 493 | $contentTypeService = $repository->getContentTypeService(); |
|
| 494 | ||
| 495 | // Load the user service |
|
| 496 | $userService = $repository->getUserService(); |
|
| 497 | ||
| 498 | // Set anonymous user |
|
| 499 | $repository->setCurrentUser($userService->loadUser($anonymousUserId)); |
|
| 500 | ||
| 501 | $commentType = $contentTypeService->loadContentTypeByIdentifier('comment'); |
|
| 502 | ||
| 503 | // This call will fail with a "UnauthorizedException" |
|
| 504 | $contentTypeService->copyContentType($commentType); |
|
| 505 | /* END: Use Case */ |
|
| 506 | } |
|
| 507 | ||
| 508 | /** |
|
| 509 | * Test for the assignContentTypeGroup() method. |
|
| @@ 116-141 (lines=26) @@ | ||
| 113 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 114 | * @depends eZ\Publish\API\Repository\Tests\ObjectStateServiceTest::testDeleteObjectStateGroup |
|
| 115 | */ |
|
| 116 | public function testDeleteObjectStateGroupThrowsUnauthorizedException() |
|
| 117 | { |
|
| 118 | $repository = $this->getRepository(); |
|
| 119 | ||
| 120 | $objectStateGroupId = $this->generateId('objectstategroup', 2); |
|
| 121 | $anonymousUserId = $this->generateId('user', 10); |
|
| 122 | /* BEGIN: Use Case */ |
|
| 123 | // $anonymousUserId is the ID of the "Anonymous" user in a eZ |
|
| 124 | // Publish demo installation. |
|
| 125 | // Set anonymous user |
|
| 126 | $userService = $repository->getUserService(); |
|
| 127 | $repository->setCurrentUser($userService->loadUser($anonymousUserId)); |
|
| 128 | ||
| 129 | // $objectStateGroupId contains the ID of the standard object state |
|
| 130 | // group ez_lock. |
|
| 131 | $objectStateService = $repository->getObjectStateService(); |
|
| 132 | ||
| 133 | $loadedObjectStateGroup = $objectStateService->loadObjectStateGroup( |
|
| 134 | $objectStateGroupId |
|
| 135 | ); |
|
| 136 | ||
| 137 | // Throws unauthorized exception, since the anonymous user must not |
|
| 138 | // delete object state groups |
|
| 139 | $objectStateService->deleteObjectStateGroup($loadedObjectStateGroup); |
|
| 140 | /* END: Use Case */ |
|
| 141 | } |
|
| 142 | ||
| 143 | /** |
|
| 144 | * Test for the createObjectState() method. |
|
| @@ 429-454 (lines=26) @@ | ||
| 426 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 427 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByVersionInfoWithSecondParameter |
|
| 428 | */ |
|
| 429 | public function testLoadContentByVersionInfoThrowsUnauthorizedExceptionWithSecondParameter() |
|
| 430 | { |
|
| 431 | $repository = $this->getRepository(); |
|
| 432 | ||
| 433 | $anonymousUserId = $this->generateId('user', 10); |
|
| 434 | /* BEGIN: Use Case */ |
|
| 435 | // $anonymousUserId is the ID of the "Anonymous User" in an eZ Publish |
|
| 436 | // demo installation |
|
| 437 | ||
| 438 | $contentService = $repository->getContentService(); |
|
| 439 | ||
| 440 | // Load the ContentInfo for "Anonymous User" |
|
| 441 | $contentInfo = $contentService->loadContentInfo($anonymousUserId); |
|
| 442 | ||
| 443 | // Load the current VersionInfo |
|
| 444 | $versionInfo = $contentService->loadVersionInfo($contentInfo); |
|
| 445 | ||
| 446 | $pseudoEditor = $this->createAnonymousWithEditorRole(); |
|
| 447 | ||
| 448 | // Set restricted editor user |
|
| 449 | $repository->setCurrentUser($pseudoEditor); |
|
| 450 | ||
| 451 | // This call will fail with a "UnauthorizedException" |
|
| 452 | $contentService->loadContentByVersionInfo($versionInfo, ['eng-US']); |
|
| 453 | /* END: Use Case */ |
|
| 454 | } |
|
| 455 | ||
| 456 | /** |
|
| 457 | * Test for the loadContent() method. |
|
| @@ 547-573 (lines=27) @@ | ||
| 544 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 545 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent |
|
| 546 | */ |
|
| 547 | public function testLoadContentThrowsUnauthorizedExceptionOnDrafts() |
|
| 548 | { |
|
| 549 | /** @var $repository \eZ\Publish\API\Repository\Repository */ |
|
| 550 | $repository = $this->getRepository(); |
|
| 551 | ||
| 552 | $anonymousUserId = $this->generateId('user', 10); |
|
| 553 | /* BEGIN: Use Case */ |
|
| 554 | // $anonymousUserId is the ID of the "Anonymous User" in an eZ Publish |
|
| 555 | // demo installation |
|
| 556 | $user = $this->createUserVersion1(); |
|
| 557 | ||
| 558 | // Set new editor as a content owner |
|
| 559 | $repository->setCurrentUser($user); |
|
| 560 | ||
| 561 | // Create draft with this user |
|
| 562 | $draft = $this->createContentDraftVersion1(2, 'folder'); |
|
| 563 | ||
| 564 | // Load anonymous user |
|
| 565 | $userService = $repository->getUserService(); |
|
| 566 | $user = $userService->loadUser($anonymousUserId); |
|
| 567 | $repository->setCurrentUser($user); |
|
| 568 | ||
| 569 | // Try to load the draft with anonymous user to make sure access won't be allowed by throwing an exception |
|
| 570 | $contentService = $repository->getContentService(); |
|
| 571 | $contentService->loadContent($draft->id); |
|
| 572 | /* END: Use Case */ |
|
| 573 | } |
|
| 574 | ||
| 575 | /** |
|
| 576 | * Test for the ContentService::loadContent() method on an archive. |
|
| @@ 891-917 (lines=27) @@ | ||
| 888 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 889 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentDrafts |
|
| 890 | */ |
|
| 891 | public function testLoadContentDraftsThrowsUnauthorizedExceptionWithFirstParameter() |
|
| 892 | { |
|
| 893 | $repository = $this->getRepository(); |
|
| 894 | ||
| 895 | $administratorUserId = $this->generateId('user', 14); |
|
| 896 | $anonymousUserId = $this->generateId('user', 10); |
|
| 897 | /* BEGIN: Use Case */ |
|
| 898 | // $anonymousUserId is the ID of the "Anonymous User" in an eZ Publish |
|
| 899 | // demo installation |
|
| 900 | // $administratorUserId is the ID of the "Administrator" user in a eZ |
|
| 901 | // Publish demo installation. |
|
| 902 | ||
| 903 | $contentService = $repository->getContentService(); |
|
| 904 | ||
| 905 | // Load the user service |
|
| 906 | $userService = $repository->getUserService(); |
|
| 907 | ||
| 908 | // Load the "Administrator" user |
|
| 909 | $administratorUser = $userService->loadUser($administratorUserId); |
|
| 910 | ||
| 911 | // Set anonymous user |
|
| 912 | $repository->setCurrentUser($userService->loadUser($anonymousUserId)); |
|
| 913 | ||
| 914 | // This call will fail with a "UnauthorizedException" |
|
| 915 | $contentService->loadContentDrafts($administratorUser); |
|
| 916 | /* END: Use Case */ |
|
| 917 | } |
|
| 918 | ||
| 919 | /** |
|
| 920 | * Test for the updateContent() method. |
|
| @@ 1027-1051 (lines=25) @@ | ||
| 1024 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 1025 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersions |
|
| 1026 | */ |
|
| 1027 | public function testLoadVersionsThrowsUnauthorizedException() |
|
| 1028 | { |
|
| 1029 | $repository = $this->getRepository(); |
|
| 1030 | ||
| 1031 | $contentService = $repository->getContentService(); |
|
| 1032 | ||
| 1033 | $anonymousUserId = $this->generateId('user', 10); |
|
| 1034 | /* BEGIN: Use Case */ |
|
| 1035 | // $anonymousUserId is the ID of the "Anonymous User" in an eZ Publish |
|
| 1036 | // demo installation |
|
| 1037 | $contentVersion2 = $this->createContentVersion2(); |
|
| 1038 | ||
| 1039 | // Get ContentInfo instance of version 2 |
|
| 1040 | $contentInfo = $contentVersion2->contentInfo; |
|
| 1041 | ||
| 1042 | // Load the user service |
|
| 1043 | $userService = $repository->getUserService(); |
|
| 1044 | ||
| 1045 | // Set anonymous user |
|
| 1046 | $repository->setCurrentUser($userService->loadUser($anonymousUserId)); |
|
| 1047 | ||
| 1048 | // This call will fail with a "UnauthorizedException" |
|
| 1049 | $contentService->loadVersions($contentInfo); |
|
| 1050 | /* END: Use Case */ |
|
| 1051 | } |
|
| 1052 | ||
| 1053 | /** |
|
| 1054 | * Test for the copyContent() method. |
|
| @@ 570-592 (lines=23) @@ | ||
| 567 | * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testGetRoleAssignmentsForUserGroup |
|
| 568 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser |
|
| 569 | */ |
|
| 570 | public function testGetRoleAssignmentsForUserGroupThrowsUnauthorizedException() |
|
| 571 | { |
|
| 572 | $repository = $this->getRepository(); |
|
| 573 | $roleService = $repository->getRoleService(); |
|
| 574 | $userService = $repository->getUserService(); |
|
| 575 | ||
| 576 | $editorsGroupId = $this->generateId('group', 13); |
|
| 577 | ||
| 578 | /* BEGIN: Use Case */ |
|
| 579 | $user = $this->createUserVersion1(); |
|
| 580 | ||
| 581 | $this->createRole(); |
|
| 582 | ||
| 583 | // Load the "Editors" user group |
|
| 584 | $userGroup = $userService->loadUserGroup($editorsGroupId); |
|
| 585 | ||
| 586 | // Set "Editor" user as current user. |
|
| 587 | $repository->setCurrentUser($user); |
|
| 588 | ||
| 589 | // This call will fail with an "UnauthorizedException" |
|
| 590 | $roleService->getRoleAssignmentsForUserGroup($userGroup); |
|
| 591 | /* END: Use Case */ |
|
| 592 | } |
|
| 593 | ||
| 594 | /** |
|
| 595 | * Create a role fixture in a variable named <b>$role</b>,. |
|
| @@ 238-257 (lines=20) @@ | ||
| 235 | * @see \eZ\Publish\API\Repository\UserService::createUserGroup() |
|
| 236 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUserGroup |
|
| 237 | */ |
|
| 238 | public function testCreateUserGroupIncrementsParentSubGroupCount() |
|
| 239 | { |
|
| 240 | $repository = $this->getRepository(); |
|
| 241 | $userService = $repository->getUserService(); |
|
| 242 | $mainGroupId = $this->generateId('group', 4); |
|
| 243 | ||
| 244 | $parentUserGroup = $userService->loadUserGroup($mainGroupId); |
|
| 245 | $parentGroupCount = $parentUserGroup->subGroupCount; |
|
| 246 | ||
| 247 | /* BEGIN: Use Case */ |
|
| 248 | $this->createUserGroupVersion1(); |
|
| 249 | ||
| 250 | $this->refreshSearch($repository); |
|
| 251 | ||
| 252 | // This should be one greater than before |
|
| 253 | $subGroupCount = $userService->loadUserGroup($mainGroupId)->subGroupCount; |
|
| 254 | /* END: Use Case */ |
|
| 255 | ||
| 256 | $this->assertEquals($parentGroupCount + 1, $subGroupCount); |
|
| 257 | } |
|
| 258 | ||
| 259 | /** |
|
| 260 | * Test for the createUserGroup() method. |
|