|
@@ 686-710 (lines=25) @@
|
| 683 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 684 |
|
* @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testUpdateUserGroup |
| 685 |
|
*/ |
| 686 |
|
public function testUpdateUserGroupThrowsInvalidArgumentExceptionOnFieldTypeNotAccept() |
| 687 |
|
{ |
| 688 |
|
$repository = $this->getRepository(); |
| 689 |
|
$userService = $repository->getUserService(); |
| 690 |
|
|
| 691 |
|
/* BEGIN: Use Case */ |
| 692 |
|
$userGroup = $this->createUserGroupVersion1(); |
| 693 |
|
|
| 694 |
|
// Load the content service |
| 695 |
|
$contentService = $repository->getContentService(); |
| 696 |
|
|
| 697 |
|
// Create a content update struct and update the group name |
| 698 |
|
$contentUpdate = $contentService->newContentUpdateStruct(); |
| 699 |
|
// An object of stdClass is not accepted as a value by the field "name" |
| 700 |
|
$contentUpdate->setField('name', new \stdClass(), 'eng-US'); |
| 701 |
|
|
| 702 |
|
// Create a group update struct and set content update struct |
| 703 |
|
$groupUpdate = $userService->newUserGroupUpdateStruct(); |
| 704 |
|
$groupUpdate->contentUpdateStruct = $contentUpdate; |
| 705 |
|
|
| 706 |
|
// This call will fail with an InvalidArgumentException, because the |
| 707 |
|
// field "name" does not accept the given value |
| 708 |
|
$userService->updateUserGroup($userGroup, $groupUpdate); |
| 709 |
|
/* END: Use Case */ |
| 710 |
|
} |
| 711 |
|
|
| 712 |
|
/** |
| 713 |
|
* Test for the newUserCreateStruct() method. |
|
@@ 1550-1577 (lines=28) @@
|
| 1547 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\ContentValidationException |
| 1548 |
|
* @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testUpdateUser |
| 1549 |
|
*/ |
| 1550 |
|
public function testUpdateUserThrowsContentValidationException() |
| 1551 |
|
{ |
| 1552 |
|
$repository = $this->getRepository(); |
| 1553 |
|
|
| 1554 |
|
$userService = $repository->getUserService(); |
| 1555 |
|
|
| 1556 |
|
/* BEGIN: Use Case */ |
| 1557 |
|
$user = $this->createUserVersion1(); |
| 1558 |
|
|
| 1559 |
|
// Get the ContentService implementation |
| 1560 |
|
$contentService = $repository->getContentService(); |
| 1561 |
|
|
| 1562 |
|
// Create a content update struct and change the remote id. |
| 1563 |
|
$contentUpdate = $contentService->newContentUpdateStruct(); |
| 1564 |
|
$contentUpdate->setField('first_name', null, 'eng-US'); |
| 1565 |
|
|
| 1566 |
|
// Create a new update struct instance |
| 1567 |
|
$userUpdate = $userService->newUserUpdateStruct(); |
| 1568 |
|
|
| 1569 |
|
// Set the content update struct. |
| 1570 |
|
$userUpdate->contentUpdateStruct = $contentUpdate; |
| 1571 |
|
|
| 1572 |
|
// This call will fail with a "ContentValidationException" because the |
| 1573 |
|
// mandatory field "first_name" is set to an empty value. |
| 1574 |
|
$userService->updateUser($user, $userUpdate); |
| 1575 |
|
|
| 1576 |
|
/* END: Use Case */ |
| 1577 |
|
} |
| 1578 |
|
|
| 1579 |
|
/** |
| 1580 |
|
* Test for the updateUser() method. |
|
@@ 1586-1613 (lines=28) @@
|
| 1583 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 1584 |
|
* @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testUpdateUser |
| 1585 |
|
*/ |
| 1586 |
|
public function testUpdateUserThrowsInvalidArgumentExceptionOnFieldTypeNotAccept() |
| 1587 |
|
{ |
| 1588 |
|
$repository = $this->getRepository(); |
| 1589 |
|
|
| 1590 |
|
$userService = $repository->getUserService(); |
| 1591 |
|
|
| 1592 |
|
/* BEGIN: Use Case */ |
| 1593 |
|
$user = $this->createUserVersion1(); |
| 1594 |
|
|
| 1595 |
|
// Get the ContentService implementation |
| 1596 |
|
$contentService = $repository->getContentService(); |
| 1597 |
|
|
| 1598 |
|
$contentUpdate = $contentService->newContentUpdateStruct(); |
| 1599 |
|
// An object of stdClass is not valid for the field first_name |
| 1600 |
|
$contentUpdate->setField('first_name', new \stdClass(), 'eng-US'); |
| 1601 |
|
|
| 1602 |
|
// Create a new update struct instance |
| 1603 |
|
$userUpdate = $userService->newUserUpdateStruct(); |
| 1604 |
|
|
| 1605 |
|
// Set the content update struct. |
| 1606 |
|
$userUpdate->contentUpdateStruct = $contentUpdate; |
| 1607 |
|
|
| 1608 |
|
// This call will fail with a "InvalidArgumentException" because the |
| 1609 |
|
// the field "first_name" does not accept the given value. |
| 1610 |
|
$userService->updateUser($user, $userUpdate); |
| 1611 |
|
|
| 1612 |
|
/* END: Use Case */ |
| 1613 |
|
} |
| 1614 |
|
|
| 1615 |
|
/** |
| 1616 |
|
* Test for the loadUserGroupsOfUser() method. |