Simplify the test

This commit is contained in:
Sébastien Lucas 2014-02-12 14:09:18 +01:00
parent 01ba1a2342
commit ddb461d0ae

View file

@ -12,18 +12,22 @@ require_once (dirname(__FILE__) . "/../epubfs.php");
class EpubFsTest extends PHPUnit_Framework_TestCase class EpubFsTest extends PHPUnit_Framework_TestCase
{ {
public function testUrlImage () { private static $book;
private static $add;
public static function setUpBeforeClass()
{
$idData = 20; $idData = 20;
$add = "data=$idData&"; self::$add = "data=$idData&";
$myBook = Book::getBookByDataId($idData); $myBook = Book::getBookByDataId($idData);
$this->assertNotNull($myBook); self::$book = new EPub ($myBook->getFilePath ("EPUB", $idData));
self::$book->initSpineComponent ();
}
$book = new EPub ($myBook->getFilePath ("EPUB", $idData)); public function testUrlImage () {
$data = getComponentContent (self::$book, "cover.xml", self::$add);
$book->initSpineComponent ();
$data = getComponentContent ($book, "cover.xml", $add);
$src = ""; $src = "";
if (preg_match("/src\=\'(.*?)\'/", $data, $matches)) { if (preg_match("/src\=\'(.*?)\'/", $data, $matches)) {
@ -34,17 +38,7 @@ class EpubFsTest extends PHPUnit_Framework_TestCase
} }
public function testUrlHref () { public function testUrlHref () {
$idData = 20; $data = getComponentContent (self::$book, "title.xml", self::$add);
$add = "data=$idData&";
$myBook = Book::getBookByDataId($idData);
$this->assertNotNull($myBook);
$book = new EPub ($myBook->getFilePath ("EPUB", $idData));
$book->initSpineComponent ();
$data = getComponentContent ($book, "title.xml", $add);
$src = ""; $src = "";
if (preg_match("/src\=\'(.*?)\'/", $data, $matches)) { if (preg_match("/src\=\'(.*?)\'/", $data, $matches)) {
@ -61,17 +55,7 @@ class EpubFsTest extends PHPUnit_Framework_TestCase
} }
public function testImportCss () { public function testImportCss () {
$idData = 20; $data = getComponentContent (self::$book, "css~SLASH~title.css", self::$add);
$add = "data=$idData&";
$myBook = Book::getBookByDataId($idData);
$this->assertNotNull($myBook);
$book = new EPub ($myBook->getFilePath ("EPUB", $idData));
$book->initSpineComponent ();
$data = getComponentContent ($book, "css~SLASH~title.css", $add);
$import = ""; $import = "";
if (preg_match("/import \'(.*?)\'/", $data, $matches)) { if (preg_match("/import \'(.*?)\'/", $data, $matches)) {