Skip to content
Snippets Groups Projects
Commit fb2b2a32 authored by Demian Katz's avatar Demian Katz Committed by Robert Lange
Browse files

Add more tests.

parent fee48874
No related merge requests found
<?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())
);
}
}
<?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())
);
}
}
<?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())
);
}
}
<?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;
}
}
<?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())
);
}
}
<?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())
);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment