-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
e3ff7f2
commit 659700e
Showing
20 changed files
with
3,389 additions
and
1,474 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,94 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright (C) 2024 Saxon State and University Library Dresden | ||
* | ||
* This file is part of the php-mods-reader. | ||
* | ||
* @license GNU General Public License version 3 or later. | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Slub\Mods\Reader; | ||
|
||
use Slub\Mods\ModsReaderTest; | ||
|
||
/** | ||
* Tests for reading Abstract element | ||
*/ | ||
class AbstractReaderTest extends ModsReaderTest | ||
{ | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getAbstractForBookDocument() | ||
{ | ||
$abstract = $this->bookReader->getAbstract(); | ||
self::assertNotNull($abstract); | ||
self::assertNotEmpty($abstract->getDisplayLabel()); | ||
self::assertEquals('Content description', $abstract->getDisplayLabel()); | ||
self::assertNotEmpty($abstract->getValue()); | ||
self::assertEquals('Test description for document which contains display label.', $abstract->getValue()); | ||
self::assertTrue($abstract->isShareable()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getAbstractByQueryForBookDocument() | ||
{ | ||
$abstract = $this->bookReader->getAbstract('[@displayLabel="Content description"]'); | ||
self::assertNotNull($abstract); | ||
self::assertNotEmpty($abstract->getDisplayLabel()); | ||
self::assertEquals('Content description', $abstract->getDisplayLabel()); | ||
self::assertNotEmpty($abstract->getValue()); | ||
self::assertEquals('Test description for document which contains display label.', $abstract->getValue()); | ||
self::assertTrue($abstract->isShareable()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getNoAbstractByQueryForBookDocument() | ||
{ | ||
$abstract = $this->bookReader->getAbstract('[@displayLabel="Random"]'); | ||
self::assertNull($abstract); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getAbstractForSerialDocument() | ||
{ | ||
$abstract = $this->serialReader->getAbstract(); | ||
self::assertNotNull($abstract); | ||
self::assertEmpty($abstract->getDisplayLabel()); | ||
self::assertNotEmpty($abstract->getValue()); | ||
self::assertEquals('Test description for non shareable document.', $abstract->getValue()); | ||
self::assertFalse($abstract->isShareable()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getAbstractByQueryForSerialDocument() | ||
{ | ||
$abstract = $this->serialReader->getAbstract('[@shareable="no"]'); | ||
self::assertNotNull($abstract); | ||
self::assertEmpty($abstract->getDisplayLabel()); | ||
self::assertNotEmpty($abstract->getValue()); | ||
self::assertEquals('Test description for non shareable document.', $abstract->getValue()); | ||
self::assertFalse($abstract->isShareable()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getNoAbstractByQueryForSerialDocument() | ||
{ | ||
$abstract = $this->serialReader->getAbstract('[@shareable="yes"]'); | ||
self::assertNull($abstract); | ||
} | ||
} |
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,179 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright (C) 2024 Saxon State and University Library Dresden | ||
* | ||
* This file is part of the php-mods-reader. | ||
* | ||
* @license GNU General Public License version 3 or later. | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Slub\Mods\Reader; | ||
|
||
use Slub\Mods\Element\AccessCondition; | ||
use Slub\Mods\ModsReaderTest; | ||
|
||
/** | ||
* Tests for reading AccessCondition element | ||
*/ | ||
class AccessConditionReaderTest extends ModsReaderTest | ||
{ | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getAccessConditionsForBookDocument() | ||
{ | ||
$accessConditions = $this->bookReader->getAccessConditions(); | ||
self::assertNotEmpty($accessConditions); | ||
self::assertEquals(1, count($accessConditions)); | ||
self::assertAccessConditionForBookDocument($accessConditions[0]); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getAccessConditionForBookDocument() | ||
{ | ||
$accessCondition = $this->bookReader->getAccessCondition(0); | ||
self::assertAccessConditionForBookDocument($accessCondition); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getFirstAccessConditionForBookDocument() | ||
{ | ||
$accessCondition = $this->bookReader->getFirstAccessCondition(); | ||
self::assertAccessConditionForBookDocument($accessCondition); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getLastAccessConditionForBookDocument() | ||
{ | ||
$accessCondition = $this->bookReader->getLastAccessCondition(); | ||
self::assertAccessConditionForBookDocument($accessCondition); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getAccessConditionsByQueryForBookDocument() | ||
{ | ||
$accessConditions = $this->bookReader->getAccessConditions('[@type="use and reproduction"]'); | ||
self::assertNotEmpty($accessConditions); | ||
self::assertEquals(1, count($accessConditions)); | ||
self::assertAccessConditionForBookDocument($accessConditions[0]); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getFirstAccessConditionByQueryForBookDocument() | ||
{ | ||
$accessCondition = $this->bookReader->getFirstAccessCondition('[@type="use and reproduction"]'); | ||
self::assertAccessConditionForBookDocument($accessCondition); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getLastAccessConditionByQueryForBookDocument() | ||
{ | ||
$accessCondition = $this->bookReader->getLastAccessCondition('[@type="use and reproduction"]'); | ||
self::assertAccessConditionForBookDocument($accessCondition); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getNoAccessConditionsByQueryForBookDocument() | ||
{ | ||
$accessConditions = $this->bookReader->getAccessConditions('[@type="restriction on access"]'); | ||
self::assertEmpty($accessConditions); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getNoAccessConditionByQueryForBookDocument() | ||
{ | ||
$accessCondition = $this->bookReader->getAccessCondition(1, '[@type="restriction on access"]'); | ||
self::assertNull($accessCondition); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getNoFirstAccessConditionsByQueryForBookDocument() | ||
{ | ||
$accessCondition = $this->bookReader->getFirstAccessCondition('[@type="restriction on access"]'); | ||
self::assertNull($accessCondition); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getNoLastAccessConditionsByQueryForBookDocument() | ||
{ | ||
$accessCondition = $this->bookReader->getLastAccessCondition('[@type="restriction on access"]'); | ||
self::assertNull($accessCondition); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getAccessConditionsForSerialDocument() | ||
{ | ||
$accessConditions = $this->serialReader->getAccessConditions(); | ||
self::assertNotEmpty($accessConditions); | ||
self::assertEquals(1, count($accessConditions)); | ||
self::assertAccessConditionForSerialDocument($accessConditions[0]); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getAccessConditionsByQueryForSerialDocument() | ||
{ | ||
$accessConditions = $this->serialReader->getAccessConditions('[@type="restriction on access"]'); | ||
self::assertNotEmpty($accessConditions); | ||
self::assertEquals(1, count($accessConditions)); | ||
self::assertAccessConditionForSerialDocument($accessConditions[0]); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getNoAccessConditionsByQueryForSerialDocument() | ||
{ | ||
$accessConditions = $this->serialReader->getAccessConditions('[@type="use and reproduction"]'); | ||
self::assertEmpty($accessConditions); | ||
} | ||
|
||
private static function assertAccessConditionForBookDocument(AccessCondition $accessCondition) | ||
{ | ||
self::assertNotEmpty($accessCondition->getValue()); | ||
self::assertEquals('Use of this public-domain resource is unrestricted.', $accessCondition->getValue()); | ||
self::assertNotEmpty($accessCondition->getType()); | ||
self::assertEquals('use and reproduction', $accessCondition->getType()); | ||
self::assertEmpty($accessCondition->getDisplayLabel()); | ||
self::assertEmpty($accessCondition->getXlinkHref()); | ||
} | ||
|
||
private static function assertAccessConditionForSerialDocument(AccessCondition $accessCondition) | ||
{ | ||
self::assertNotEmpty($accessCondition->getValue()); | ||
self::assertEquals('Open Access', $accessCondition->getValue()); | ||
self::assertNotEmpty($accessCondition->getType()); | ||
self::assertEquals('restriction on access', $accessCondition->getType()); | ||
self::assertNotEmpty($accessCondition->getDisplayLabel()); | ||
self::assertEquals('Access Status', $accessCondition->getDisplayLabel()); | ||
// TODO: check out xlink | ||
// self::assertEquals('http://purl.org/eprint/accessRights/OpenAccess', $accessCondition->getXlinkHref()); | ||
} | ||
} |
Oops, something went wrong.