diff --git a/module/VuFind/tests/RecordDriver/SolrMarcTest.php b/module/VuFind/tests/RecordDriver/SolrMarcTest.php new file mode 100644 index 0000000000000000000000000000000000000000..a2f6a488058456af69d226ad84b77bc5277b6af8 --- /dev/null +++ b/module/VuFind/tests/RecordDriver/SolrMarcTest.php @@ -0,0 +1,66 @@ +<?php +/** + * SolrMarc Record Driver Test Class + * + * PHP version 5 + * + * Copyright (C) Villanova University 2010. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @author Preetha Rao <vufind-tech@lists.sourceforge.net> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/unit_tests Wiki + */ +namespace VuFind\Test\RecordDriver; + +/** + * SolrMarc Record Driver Test Class + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @author Preetha Rao <vufind-tech@lists.sourceforge.net> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/unit_tests Wiki + */ +class SolrMarcTest extends \VuFind\Tests\TestCase +{ + /** + * Test a record that used to be known to cause problems because of the way + * series name was handled (the old "Bug2" test from VuFind 1.x). + * + * @return void + */ + public function testBug2() + { + $record = \VuFind\Search\Solr\Results::getRecord('testbug2'); + $this->assertEquals( + $record->getPrimaryAuthor(), + 'Vico, Giambattista, 1668-1744.' + ); + $secondary = $record->getSecondaryAuthors(); + $this->assertEquals(count($secondary), 1); + $this->assertTrue(in_array('Pandolfi, Claudia.', $secondary)); + $series = $record->getSeries(); + $this->assertEquals(count($series), 1); + $this->assertEquals( + 'Vico, Giambattista, 1668-1744. Works. 1982 ;', $series[0]['name'] + ); + $this->assertEquals('2, pt. 1.', $series[0]['number']); + } +} \ No newline at end of file diff --git a/module/VuFind/tests/Search/Base/ParamsTest.php b/module/VuFind/tests/Search/Base/ParamsTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e072e78f82c06c5cf01b816cf48631d3e10372b4 --- /dev/null +++ b/module/VuFind/tests/Search/Base/ParamsTest.php @@ -0,0 +1,73 @@ +<?php +/** + * Base Search Object Parameters Test + * + * PHP version 5 + * + * Copyright (C) Villanova University 2010. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @author Preetha Rao <vufind-tech@lists.sourceforge.net> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/unit_tests Wiki + */ +namespace VuFind\Tests\Search\Base; + +/** + * Base Search Object Parameters Test + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @author Preetha Rao <vufind-tech@lists.sourceforge.net> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/unit_tests Wiki + */ +class ParamsTest extends \VuFind\Tests\TestCase +{ + /** + * Test a record that used to be known to cause problems because of the way + * series name was handled (the old "Bug2" test from VuFind 1.x). + * + * @return void + */ + public function testSpellingReplacements() + { + // Use Solr options since base options is an abstract class. + $options = new \VuFind\Search\Solr\Options(); + + // Create Params object for testing purposes. + $params = new \VuFind\Search\Base\Params($options); + + // Key test: word boundaries: + $params->setBasicSearch('go good googler'); + $this->assertEquals( + 'run good googler', + $params->getDisplayQueryWithReplacedTerm('go', 'run') + ); + + // Key test: replacement of wildcard queries: + $params->setBasicSearch('oftamologie*'); + $this->assertEquals( + 'ophtalmologie*', + $params->getDisplayQueryWithReplacedTerm( + 'oftamologie*', 'ophtalmologie*' + ) + ); + } +} \ No newline at end of file