From 7fd3b1f678aff91ce9bc13f66f1f216767bd6d1c Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Fri, 11 Jul 2014 13:09:40 -0400 Subject: [PATCH] More test coverage. --- .../Content/Covers/BooksiteTest.php | 69 ++++++++++++++++++ .../Content/Covers/ContentCafeTest.php | 70 +++++++++++++++++++ .../Content/Covers/LibraryThingTest.php | 69 ++++++++++++++++++ .../Content/Covers/OpenLibraryTest.php | 69 ++++++++++++++++++ .../VuFindTest/Content/Covers/SummonTest.php | 70 +++++++++++++++++++ 5 files changed, 347 insertions(+) create mode 100644 module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/BooksiteTest.php create mode 100644 module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/ContentCafeTest.php create mode 100644 module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/LibraryThingTest.php create mode 100644 module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/OpenLibraryTest.php create mode 100644 module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/SummonTest.php diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/BooksiteTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/BooksiteTest.php new file mode 100644 index 00000000000..bf659abd09f --- /dev/null +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/BooksiteTest.php @@ -0,0 +1,69 @@ +<?php + +/** + * Unit tests for Booksite cover loader. + * + * 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 Search + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org + */ +namespace VuFindTest\Content\Covers; +use VuFind\Code\ISBN, VuFind\Content\Covers\Booksite; + +/** + * Unit tests for Booksite cover loader. + * + * @category VuFind2 + * @package Search + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org + */ +class BooksiteTest extends \PHPUnit_Framework_TestCase +{ + /** + * Test cover loading + * + * @return void + */ + public function testValidCoverLoading() + { + $loader = new Booksite('http://base', 'mykey'); + $this->assertEquals( + 'http://base/poca/content_img?apikey=mykey&ean=9780739313121', + $loader->getUrl( + 'mykey', 'small', array('isbn' => new ISBN('0739313126')) + ) + ); + } + + /** + * Test missing ISBN + * + * @return void + */ + public function testMissingIsbn() + { + $loader = new Booksite('http://base', 'mykey'); + $this->assertEquals(false, $loader->getUrl('mykey', 'small', array())); + } +} \ No newline at end of file diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/ContentCafeTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/ContentCafeTest.php new file mode 100644 index 00000000000..4a3132837cd --- /dev/null +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/ContentCafeTest.php @@ -0,0 +1,70 @@ +<?php + +/** + * Unit tests for ContentCafe cover loader. + * + * 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 Search + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org + */ +namespace VuFindTest\Content\Covers; +use VuFind\Code\ISBN, VuFind\Content\Covers\ContentCafe, Zend\Config\Config; + +/** + * Unit tests for ContentCafe cover loader. + * + * @category VuFind2 + * @package Search + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org + */ +class ContentCafeTest extends \PHPUnit_Framework_TestCase +{ + /** + * Test cover loading + * + * @return void + */ + public function testValidCoverLoading() + { + $loader = new ContentCafe(new Config(array('pw' => 'fakepw'))); + $this->assertEquals( + 'http://contentcafe2.btol.com/ContentCafe/Jacket.aspx?UserID=mykey' + . '&Password=fakepw&Return=1&Type=S&Value=9780739313121&erroroverride=1', + $loader->getUrl( + 'mykey', 'small', array('isbn' => new ISBN('0739313126')) + ) + ); + } + + /** + * Test missing ISBN + * + * @return void + */ + public function testMissingIsbn() + { + $loader = new ContentCafe(new Config(array('pw' => 'fakepw'))); + $this->assertEquals(false, $loader->getUrl('mykey', 'small', array())); + } +} \ No newline at end of file diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/LibraryThingTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/LibraryThingTest.php new file mode 100644 index 00000000000..51d2c43116c --- /dev/null +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/LibraryThingTest.php @@ -0,0 +1,69 @@ +<?php + +/** + * Unit tests for LibraryThing cover loader. + * + * 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 Search + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org + */ +namespace VuFindTest\Content\Covers; +use VuFind\Code\ISBN, VuFind\Content\Covers\LibraryThing; + +/** + * Unit tests for LibraryThing cover loader. + * + * @category VuFind2 + * @package Search + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org + */ +class LibraryThingTest extends \PHPUnit_Framework_TestCase +{ + /** + * Test cover loading + * + * @return void + */ + public function testValidCoverLoading() + { + $loader = new LibraryThing(); + $this->assertEquals( + 'http://covers.librarything.com/devkey/mykey/small/isbn/9780739313121', + $loader->getUrl( + 'mykey', 'small', array('isbn' => new ISBN('0739313126')) + ) + ); + } + + /** + * Test missing ISBN + * + * @return void + */ + public function testMissingIsbn() + { + $loader = new LibraryThing(); + $this->assertEquals(false, $loader->getUrl('mykey', 'small', array())); + } +} \ No newline at end of file diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/OpenLibraryTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/OpenLibraryTest.php new file mode 100644 index 00000000000..b2eaa5816d5 --- /dev/null +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/OpenLibraryTest.php @@ -0,0 +1,69 @@ +<?php + +/** + * Unit tests for OpenLibrary cover loader. + * + * 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 Search + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org + */ +namespace VuFindTest\Content\Covers; +use VuFind\Code\ISBN, VuFind\Content\Covers\OpenLibrary; + +/** + * Unit tests for OpenLibrary cover loader. + * + * @category VuFind2 + * @package Search + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org + */ +class OpenLibraryTest extends \PHPUnit_Framework_TestCase +{ + /** + * Test cover loading + * + * @return void + */ + public function testValidCoverLoading() + { + $ol = new OpenLibrary(); + $this->assertEquals( + 'http://covers.openlibrary.org/b/isbn/9780739313121-S.jpg?default=false', + $ol->getUrl( + 'mykey', 'small', array('isbn' => new ISBN('0739313126')) + ) + ); + } + + /** + * Test missing ISBN + * + * @return void + */ + public function testMissingIsbn() + { + $ol = new OpenLibrary(); + $this->assertEquals(false, $ol->getUrl('mykey', 'small', array())); + } +} \ No newline at end of file diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/SummonTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/SummonTest.php new file mode 100644 index 00000000000..937e7fbd9e9 --- /dev/null +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/SummonTest.php @@ -0,0 +1,70 @@ +<?php + +/** + * Unit tests for Summon cover loader. + * + * 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 Search + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org + */ +namespace VuFindTest\Content\Covers; +use VuFind\Code\ISBN, VuFind\Content\Covers\Summon; + +/** + * Unit tests for Summon cover loader. + * + * @category VuFind2 + * @package Search + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org + */ +class SummonTest extends \PHPUnit_Framework_TestCase +{ + /** + * Test cover loading + * + * @return void + */ + public function testValidCoverLoading() + { + $summon = new Summon(); + $this->assertEquals( + 'http://api.summon.serialssolutions.com/2.0.0/image/isbn/' + . 'mykey/9780739313121/small', + $summon->getUrl( + 'mykey', 'small', array('isbn' => new ISBN('0739313126')) + ) + ); + } + + /** + * Test missing ISBN + * + * @return void + */ + public function testMissingIsbn() + { + $summon = new Summon(); + $this->assertEquals(false, $summon->getUrl('mykey', 'small', array())); + } +} \ No newline at end of file -- GitLab