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 0000000000000000000000000000000000000000..bf659abd09f1846e254a1687d707354de528043a --- /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 0000000000000000000000000000000000000000..4a3132837cda3539f745c71015ab488134a554a7 --- /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 0000000000000000000000000000000000000000..51d2c43116c3cd4ddc13f049c278aea0f8d7e07a --- /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 0000000000000000000000000000000000000000..b2eaa5816d5d26d94943189c335442afa799873f --- /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 0000000000000000000000000000000000000000..937e7fbd9e90152b51abc7d7f803d14830022a22 --- /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