diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/MetadataVocabulary/BEPressTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/MetadataVocabulary/BEPressTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c6407f6474b05a1aad7206d6332881f957e79376 --- /dev/null +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/MetadataVocabulary/BEPressTest.php @@ -0,0 +1,71 @@ +<?php +/** + * BEPress Test Class + * + * PHP version 7 + * + * Copyright (C) Villanova University 2020. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * 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 + * + * @category VuFind + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development:testing:unit_tests Wiki + */ +namespace VuFindTest\MetadataVocabulary; + +use VuFind\MetadataVocabulary\BEPress; + +/** + * BEPress Test Class + * + * @category VuFind + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development:testing:unit_tests Wiki + */ +class BEPressTest extends \VuFindTest\Unit\TestCase +{ + use FakeDriverTrait; + + /** + * Test basic functionality of the class. + * + * @return void + */ + public function testMappings() + { + $meta = new BEPress(); + $this->assertEquals( + [ + 'bepress_citation_title' => ['Fake Title'], + 'bepress_citation_doi' => ['FakeDOI'], + 'bepress_citation_lastpage' => [10], + 'bepress_citation_isbn' => ['FakeISBN'], + 'bepress_citation_issn' => ['FakeISSN'], + 'bepress_citation_firstpage' => [1], + 'bepress_citation_volume' => [7], + 'bepress_citation_author' => ['Mr. Person'], + 'bepress_citation_issue' => [5], + 'bepress_citation_journal_title' => ['My Journal'], + 'bepress_citation_publisher' => ['Fake Publisher'], + 'bepress_citation_date' => [2020], + ], + $meta->getMappedData($this->getDriver()) + ); + } +} diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/MetadataVocabulary/DublinCoreTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/MetadataVocabulary/DublinCoreTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c53c958496f986554058d3dd8b64a04c93b20384 --- /dev/null +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/MetadataVocabulary/DublinCoreTest.php @@ -0,0 +1,70 @@ +<?php +/** + * DublinCore Test Class + * + * PHP version 7 + * + * Copyright (C) Villanova University 2020. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * 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 + * + * @category VuFind + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development:testing:unit_tests Wiki + */ +namespace VuFindTest\MetadataVocabulary; + +use VuFind\MetadataVocabulary\DublinCore; + +/** + * DublinCore Test Class + * + * @category VuFind + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development:testing:unit_tests Wiki + */ +class DublinCoreTest extends \VuFindTest\Unit\TestCase +{ + use FakeDriverTrait; + + /** + * Test basic functionality of the class. + * + * @return void + */ + public function testMappings() + { + $meta = new DublinCore(); + $this->assertEquals( + [ + 'DC.title' => ['Fake Title'], + 'DC.language' => ['English'], + 'DC.citation.epage' => [10], + 'DC.identifier' => ['FakeDOI', 'FakeISBN', 'FakeISSN'], + 'DC.citation.spage' => [1], + 'DC.citation.volume' => [7], + 'DC.creator' => ['Mr. Person'], + 'DC.citation.issue' => [5], + 'DC.relation.ispartof' => ['My Journal'], + 'DC.publisher' => ['Fake Publisher'], + 'DC.issued' => [2020], + ], + $meta->getMappedData($this->getDriver()) + ); + } +} diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/MetadataVocabulary/EprintsTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/MetadataVocabulary/EprintsTest.php new file mode 100644 index 0000000000000000000000000000000000000000..eefb15ac84da29370be4106d36e69237790fb8e1 --- /dev/null +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/MetadataVocabulary/EprintsTest.php @@ -0,0 +1,67 @@ +<?php +/** + * Eprints Test Class + * + * PHP version 7 + * + * Copyright (C) Villanova University 2020. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * 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 + * + * @category VuFind + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development:testing:unit_tests Wiki + */ +namespace VuFindTest\MetadataVocabulary; + +use VuFind\MetadataVocabulary\Eprints; + +/** + * Eprints Test Class + * + * @category VuFind + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development:testing:unit_tests Wiki + */ +class EprintsTest extends \VuFindTest\Unit\TestCase +{ + use FakeDriverTrait; + + /** + * Test basic functionality of the class. + * + * @return void + */ + public function testMappings() + { + $meta = new Eprints(); + $this->assertEquals( + [ + 'eprints.title' => ['Fake Title'], + 'eprints.issn' => ['FakeISSN'], + 'eprints.pagerange' => ['1-10'], + 'eprints.number' => [7], + 'eprints.creators_name' => ['Mr. Person'], + 'eprints.publication' => ['My Journal'], + 'eprints.publisher' => ['Fake Publisher'], + 'eprints.date' => [2020], + ], + $meta->getMappedData($this->getDriver()) + ); + } +} diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/MetadataVocabulary/FakeDriverTrait.php b/module/VuFind/tests/unit-tests/src/VuFindTest/MetadataVocabulary/FakeDriverTrait.php new file mode 100644 index 0000000000000000000000000000000000000000..aa98ee0825e8b794a1fbe207dc938cb4bf5139ae --- /dev/null +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/MetadataVocabulary/FakeDriverTrait.php @@ -0,0 +1,69 @@ +<?php +/** + * Trait containing method to generate fake drivers for metadata testing. + * + * PHP version 7 + * + * Copyright (C) Villanova University 2020. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * 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 + * + * @category VuFind + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development:testing:unit_tests Wiki + */ +namespace VuFindTest\MetadataVocabulary; + +use VuFindTest\RecordDriver\TestHarness; + +/** + * Trait containing method to generate fake drivers for metadata testing. + * + * @category VuFind + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development:testing:unit_tests Wiki + */ +trait FakeDriverTrait +{ + /** + * Get a fake record driver + * + * @return TestHarness + */ + protected function getDriver() + { + $data = [ + 'Title' => 'Fake Title', + 'PrimaryAuthors' => ['Mr. Person'], + 'ContainerTitle' => 'My Journal', + 'PublicationDates' => [2020], + 'CleanDOI' => 'FakeDOI', + 'ContainerEndPage' => 10, + 'CleanISBN' => 'FakeISBN', + 'CleanISSN' => 'FakeISSN', + 'ContainerIssue' => 5, + 'Languages' => ['English'], + 'Publishers' => ['Fake Publisher'], + 'ContainerStartPage' => 1, + 'ContainerVolume' => 7, + ]; + $driver = new TestHarness(); + $driver->setRawData($data); + return $driver; + } +} diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/MetadataVocabulary/HighwirePressTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/MetadataVocabulary/HighwirePressTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d1654865994938263f762dfe9778fd3a7de21aa6 --- /dev/null +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/MetadataVocabulary/HighwirePressTest.php @@ -0,0 +1,72 @@ +<?php +/** + * HighwirePress Test Class + * + * PHP version 7 + * + * Copyright (C) Villanova University 2020. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * 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 + * + * @category VuFind + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development:testing:unit_tests Wiki + */ +namespace VuFindTest\MetadataVocabulary; + +use VuFind\MetadataVocabulary\HighwirePress; + +/** + * HighwirePress Test Class + * + * @category VuFind + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development:testing:unit_tests Wiki + */ +class HighwirePressTest extends \VuFindTest\Unit\TestCase +{ + use FakeDriverTrait; + + /** + * Test basic functionality of the class. + * + * @return void + */ + public function testMappings() + { + $meta = new HighwirePress(); + $this->assertEquals( + [ + 'citation_title' => ['Fake Title'], + 'citation_doi' => ['FakeDOI'], + 'citation_lastpage' => [10], + 'citation_isbn' => ['FakeISBN'], + 'citation_issn' => ['FakeISSN'], + 'citation_firstpage' => [1], + 'citation_volume' => [7], + 'citation_author' => ['Mr. Person'], + 'citation_issue' => [5], + 'citation_journal_title' => ['My Journal'], + 'citation_publisher' => ['Fake Publisher'], + 'citation_date' => [2020], + 'citation_language' => ['English'], + ], + $meta->getMappedData($this->getDriver()) + ); + } +} diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/MetadataVocabulary/PRISMTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/MetadataVocabulary/PRISMTest.php new file mode 100644 index 0000000000000000000000000000000000000000..4c9b1165bd153eb0830f2635c45e0349c59477a4 --- /dev/null +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/MetadataVocabulary/PRISMTest.php @@ -0,0 +1,66 @@ +<?php +/** + * PRISM Test Class + * + * PHP version 7 + * + * Copyright (C) Villanova University 2020. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * 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 + * + * @category VuFind + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development:testing:unit_tests Wiki + */ +namespace VuFindTest\MetadataVocabulary; + +use VuFind\MetadataVocabulary\PRISM; + +/** + * PRISM Test Class + * + * @category VuFind + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development:testing:unit_tests Wiki + */ +class PRISMTest extends \VuFindTest\Unit\TestCase +{ + use FakeDriverTrait; + + /** + * Test basic functionality of the class. + * + * @return void + */ + public function testMappings() + { + $meta = new PRISM(); + $this->assertEquals( + [ + 'prism.title' => ['Fake Title'], + 'prism.doi' => ['FakeDOI'], + 'prism.endingPage' => [10], + 'prism.isbn' => ['FakeISBN'], + 'prism.issn' => ['FakeISSN'], + 'prism.startingPage' => [1], + 'prism.volume' => [7], + ], + $meta->getMappedData($this->getDriver()) + ); + } +}