cops/test/EpubFsTest.php

66 lines
2 KiB
PHP
Raw Normal View History

2014-02-11 21:51:26 +02:00
<?php
/**
* COPS (Calibre OPDS PHP Server) test file
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Sébastien Lucas <sebastien@slucas.fr>
*/
require_once (dirname(__FILE__) . "/config_test.php");
require_once (dirname(__FILE__) . "/../book.php");
require_once (dirname(__FILE__) . "/../epubfs.php");
class EpubFsTest extends PHPUnit_Framework_TestCase
{
2014-02-12 15:09:18 +02:00
private static $book;
private static $add;
2014-02-11 21:51:26 +02:00
2014-02-12 15:09:18 +02:00
public static function setUpBeforeClass()
{
$idData = 20;
self::$add = "data=$idData&";
$myBook = Book::getBookByDataId($idData);
2014-02-11 21:51:26 +02:00
2014-02-12 15:09:18 +02:00
self::$book = new EPub ($myBook->getFilePath ("EPUB", $idData));
self::$book->initSpineComponent ();
}
2014-02-11 21:51:26 +02:00
2014-02-12 15:09:18 +02:00
public function testUrlImage () {
$data = getComponentContent (self::$book, "cover.xml", self::$add);
2014-02-11 21:51:26 +02:00
$src = "";
if (preg_match("/src\=\'(.*?)\'/", $data, $matches)) {
$src = $matches [1];
}
$this->assertEquals ('epubfs.php?data=20&amp;comp=images~SLASH~cover.png', $src);
}
public function testUrlHref () {
2014-02-12 15:09:18 +02:00
$data = getComponentContent (self::$book, "title.xml", self::$add);
2014-02-11 21:51:26 +02:00
$src = "";
if (preg_match("/src\=\'(.*?)\'/", $data, $matches)) {
$src = $matches [1];
}
$this->assertEquals ('epubfs.php?data=20&amp;comp=images~SLASH~logo~DASH~feedbooks~DASH~tiny.png', $src);
$href = "";
if (preg_match("/href\=\'(.*?)\'/", $data, $matches)) {
$href = $matches [1];
}
$this->assertEquals ('epubfs.php?data=20&amp;comp=css~SLASH~title.css', $href);
}
public function testImportCss () {
2014-02-12 15:09:18 +02:00
$data = getComponentContent (self::$book, "css~SLASH~title.css", self::$add);
2014-02-11 21:51:26 +02:00
$import = "";
if (preg_match("/import \'(.*?)\'/", $data, $matches)) {
$import = $matches [1];
}
$this->assertEquals ('epubfs.php?data=20&amp;comp=css~SLASH~page.css', $import);
}
}