/** * (non-PHPdoc) * @see \oat\tao\model\lock\LockSystem::setLock() */ public function setLock(core_kernel_classes_Resource $resource, $ownerId) { $lock = $this->getLockData($resource); if (is_null($lock)) { $lock = new OntoLockData($resource, $ownerId, microtime(true)); $resource->setPropertyValue($this->getLockProperty(), $lock->toJson()); } elseif ($lock->getOwnerId() != $ownerId) { throw new ResourceLockedException($lock); } }
/** * * @author Lionel Lecaque, lionel@taotesting.com */ public function testToJson() { $resource = $this->prophesize('core_kernel_classes_Resource'); $owner = $this->prophesize('core_kernel_classes_Resource'); $owner->getUri()->willReturn('#ownerUri'); $resource->getUri()->willReturn('#resourceUri'); $lock = new OntoLockData($resource->reveal(), $owner->reveal(), 'epoch'); $expected = json_encode(array('resource' => '#resourceUri', 'owner' => '#ownerUri', 'epoch' => 'epoch')); $this->assertEquals($expected, $lock->toJson()); }