74 lines
2.4 KiB
PHP
74 lines
2.4 KiB
PHP
<?php
|
|
|
|
/**
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; under version 2
|
|
* of the License (non-upgradable).
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*
|
|
* Copyright (c) 2015 Open Assessment Technologies S.A.
|
|
*
|
|
*/
|
|
|
|
namespace oat\tao\test\unit\lock;
|
|
|
|
use common_exception_InconsistentData;
|
|
use oat\tao\model\lock\implementation\OntoLockData;
|
|
use oat\generis\test\TestCase;
|
|
|
|
class OntoLockDataTest extends TestCase
|
|
{
|
|
|
|
/**
|
|
*
|
|
* @author Lionel Lecaque, lionel@taotesting.com
|
|
*/
|
|
public function testGetOwner()
|
|
{
|
|
$resource = $this->prophesize('core_kernel_classes_Resource');
|
|
$owner = $this->prophesize('core_kernel_classes_Resource');
|
|
$owner->getUri()->willReturn('#ownerUri');
|
|
$lock = new OntoLockData($resource->reveal(), $owner->reveal(), 'epoch');
|
|
$this->assertInstanceOf('core_kernel_classes_Resource', $lock->getOwner());
|
|
$this->assertEquals('#ownerUri', $lock->getOwner()->getUri());
|
|
}
|
|
/**
|
|
*
|
|
* @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([
|
|
'resource' => '#resourceUri',
|
|
'owner' => '#ownerUri',
|
|
'epoch' => 'epoch'
|
|
]);
|
|
|
|
$this->assertEquals($expected, $lock->toJson());
|
|
}
|
|
/**
|
|
* @author Lionel Lecaque, lionel@taotesting.com
|
|
*/
|
|
public function testGetLockDataExeption()
|
|
{
|
|
$this->expectException(common_exception_InconsistentData::class);
|
|
OntoLockData::getLockData(json_encode([]));
|
|
}
|
|
}
|