diff --git a/Tests/Fixtures/MetsDocument/fulltext_0003.xml b/Tests/Fixtures/MetsDocument/fulltext_0003.xml new file mode 100644 index 000000000..f78f3f33e --- /dev/null +++ b/Tests/Fixtures/MetsDocument/fulltext_0003.xml @@ -0,0 +1,66 @@ + + + + pixel + + + 2020-05-14 + + ABBYY + ABBYY FineReader Engine + 12 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/Fixtures/MetsDocument/mets_with_pages.xml b/Tests/Fixtures/MetsDocument/mets_with_pages.xml new file mode 100644 index 000000000..176deaade --- /dev/null +++ b/Tests/Fixtures/MetsDocument/mets_with_pages.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/Fixtures/MetsDocument/two_dmdsec.xml b/Tests/Fixtures/MetsDocument/two_dmdsec.xml index 61836b6d6..6a9f70a1f 100644 --- a/Tests/Fixtures/MetsDocument/two_dmdsec.xml +++ b/Tests/Fixtures/MetsDocument/two_dmdsec.xml @@ -49,6 +49,11 @@ + + + + + diff --git a/Tests/Functional/Common/MetsDocumentTest.php b/Tests/Functional/Common/MetsDocumentTest.php index 4cfaeef88..a4f91e663 100644 --- a/Tests/Functional/Common/MetsDocumentTest.php +++ b/Tests/Functional/Common/MetsDocumentTest.php @@ -1,4 +1,13 @@ + * + * This file is part of the Kitodo and TYPO3 projects. + * + * @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 Kitodo\Dlf\Tests\Functional\Common; @@ -11,6 +20,7 @@ public function setUp(): void { parent::setUp(); + $this->importDataSet(__DIR__ . '/../../Fixtures/Common/documents_1.xml'); $this->importDataSet(__DIR__ . '/../../Fixtures/Common/metadata.xml'); $this->importDataSet(__DIR__ . '/../../Fixtures/MetsDocument/metadata_mets.xml'); } @@ -128,4 +138,109 @@ public function returnsEmptyMetadataWhenNoDmdSec() $metadata = $doc->getMetadata('LOG_0002', 20000); $this->assertEquals([], $metadata); } + + /** + * @test + */ + public function canGetDownloadLocation() + { + $doc = $this->doc('two_dmdsec.xml'); + + $correct = $doc->getDownloadLocation('FILE_0000_DOWNLOAD'); + $this->assertEquals('https://example.com/download?&CVT=jpeg', $correct); + + /* + * The method `getDownloadLocation` should return a string, but returns null in some cases. + * Therefor, a TypeError must be expected here. + */ + $this->expectException('TypeError'); + $doc->getDownloadLocation('ID_DOES_NOT_EXIST'); + } + + + /** + * @test + */ + public function canGetFileLocation() + { + $doc = $this->doc('two_dmdsec.xml'); + + $correct = $doc->getFileLocation('FILE_0000_DEFAULT'); + $this->assertEquals('https://digital.slub-dresden.de/data/kitodo/1703800435/video.mov', $correct); + + $incorrect = $doc->getFileLocation('ID_DOES_NOT_EXIST'); + $this->assertEquals('', $incorrect); + } + + /** + * @test + */ + public function canGetFileMimeType() + { + $doc = $this->doc('two_dmdsec.xml'); + + $correct = $doc->getFileMimeType('FILE_0000_DEFAULT'); + $this->assertEquals('video/quicktime', $correct); + + $incorrect = $doc->getFileMimeType('ID_DOES_NOT_EXIST'); + $this->assertEquals('', $incorrect); + } + + // FIXME: Method getPhysicalPage does not work as expected + /** + * @test + */ + public function canGetPhysicalPage() + { + $doc = $this->doc('mets_with_pages.xml'); + + // pass orderlabel and retrieve order + $physicalPage = $doc->getPhysicalPage('1'); + $this->assertEquals(1, $physicalPage); + } + + /** + * @test + */ + public function canGetTitle() + { + $doc = $this->doc('mets_with_pages.xml'); + + $correct = $doc->getTitle(1001); + $this->assertEquals('10 Keyboard pieces - Go. S. 658', $correct); + + $incorrect = $doc->getTitle(1234); + $this->assertEquals('', $incorrect); + } + + /** + * @test + */ + public function canGetFullText() + { + $doc = $this->doc('mets_with_pages.xml'); + + $fulltext = $doc->getFullText('PHYS_0003'); + $expected = ' + +'; + $this->assertEquals($expected, $fulltext); + + $incorrect = $doc->getFullText('ID_DOES_NOT_EXIST'); + $this->assertEquals('', $incorrect); + } + + /** + * @test + */ + public function canGetStructureDepth() + { + $doc = $this->doc('mets_with_pages.xml'); + + $correct = $doc->getStructureDepth('LOG_0001'); + $this->assertEquals(3, $correct); + + $incorrect = $doc->getStructureDepth('ID_DOES_NOT_EXIST'); + $this->assertEquals(0, $incorrect); + } }