-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
94 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
|
||
namespace Pimcore\Tests\Rest; | ||
|
||
use DachcomBundle\Test\Util\MembersHelper; | ||
use MembersBundle\Adapter\Group\GroupInterface; | ||
use MembersBundle\Adapter\User\UserInterface; | ||
use Pimcore\Model\DataObject\AbstractObject; | ||
use Pimcore\Model\DataObject\MembersGroup; | ||
use Pimcore\Model\DataObject\MembersUser; | ||
use Pimcore\Tests\Test\RestTestCase; | ||
use Pimcore\Tests\Util\TestHelper; | ||
|
||
class UserTest extends RestTestCase | ||
{ | ||
protected function _after() | ||
{ | ||
TestHelper::cleanUp(); | ||
MembersHelper::cleanUp(); | ||
MembersHelper::reCreateMembersStructure(); | ||
|
||
parent::_after(); | ||
} | ||
|
||
public function testUserCreate() | ||
{ | ||
$unsavedObject = new MembersUser(); | ||
$unsavedObject->setParentId(1); | ||
$unsavedObject->setUserOwner(1); | ||
$unsavedObject->setUserModification(1); | ||
$unsavedObject->setCreationDate(time()); | ||
$unsavedObject->setKey(uniqid() . rand(10, 99)); | ||
|
||
$time = time(); | ||
|
||
$result = $this->restClient->createObjectConcrete($unsavedObject); | ||
|
||
$this->assertTrue($result->success, 'request not successful . ' . $result->msg); | ||
$this->assertEquals(2, TestHelper::getObjectCount()); | ||
|
||
$id = $result->id; | ||
$this->assertTrue($id > 1, 'id must be greater than 1'); | ||
|
||
$objectDirect = AbstractObject::getById($id); | ||
$creationDate = $objectDirect->getCreationDate(); | ||
|
||
$this->assertTrue($creationDate >= $time, 'wrong creation date'); | ||
|
||
// as the object key is unique there must be exactly one object with that key | ||
$list = $this->restClient->getObjectList('{ "o_key" : "' . $unsavedObject->getKey() . '"}'); | ||
$this->assertEquals(1, count($list)); | ||
|
||
$fetchedObject = $this->restClient->getObjectById($id); | ||
$this->assertInstanceOf(UserInterface::class, $fetchedObject); | ||
} | ||
|
||
public function testUserGroupCreate() | ||
{ | ||
$unsavedObject = new MembersGroup(); | ||
$unsavedObject->setParentId(1); | ||
$unsavedObject->setUserOwner(1); | ||
$unsavedObject->setUserModification(1); | ||
$unsavedObject->setCreationDate(time()); | ||
$unsavedObject->setKey(uniqid() . rand(10, 99)); | ||
|
||
$time = time(); | ||
|
||
$result = $this->restClient->createObjectConcrete($unsavedObject); | ||
|
||
$this->assertTrue($result->success, 'request not successful . ' . $result->msg); | ||
$this->assertEquals(2, TestHelper::getObjectCount()); | ||
|
||
$id = $result->id; | ||
$this->assertTrue($id > 1, 'id must be greater than 1'); | ||
|
||
$objectDirect = AbstractObject::getById($id); | ||
$creationDate = $objectDirect->getCreationDate(); | ||
|
||
$this->assertTrue($creationDate >= $time, 'wrong creation date'); | ||
|
||
// as the object key is unique there must be exactly one object with that key | ||
$list = $this->restClient->getObjectList('{ "o_key" : "' . $unsavedObject->getKey() . '"}'); | ||
$this->assertEquals(1, count($list)); | ||
|
||
$fetchedObject = $this->restClient->getObjectById($id); | ||
$this->assertInstanceOf(GroupInterface::class, $fetchedObject); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.