1 | <?php |
||
14 | { |
||
15 | private static $book; |
||
16 | private static $add; |
||
17 | |||
18 | |||
19 | public static function setUpBeforeClass() |
||
20 | { |
||
21 | $idData = 20; |
||
22 | self::$add = "data=$idData&"; |
||
23 | $myBook = Book::getBookByDataId($idData); |
||
24 | |||
25 | self::$book = new EPub ($myBook->getFilePath ("EPUB", $idData)); |
||
26 | self::$book->initSpineComponent (); |
||
27 | } |
||
28 | |||
29 | public function testUrlImage () { |
||
30 | $data = getComponentContent (self::$book, "cover.xml", self::$add); |
||
31 | |||
32 | $src = ""; |
||
33 | if (preg_match("/src\=\'(.*?)\'/", $data, $matches)) { |
||
34 | $src = $matches [1]; |
||
35 | } |
||
36 | $this->assertEquals ('epubfs.php?data=20&comp=images~SLASH~cover.png', $src); |
||
37 | |||
38 | } |
||
39 | |||
40 | public function testUrlHref () { |
||
41 | $data = getComponentContent (self::$book, "title.xml", self::$add); |
||
42 | |||
43 | $src = ""; |
||
44 | if (preg_match("/src\=\'(.*?)\'/", $data, $matches)) { |
||
45 | $src = $matches [1]; |
||
46 | } |
||
47 | $this->assertEquals ('epubfs.php?data=20&comp=images~SLASH~logo~DASH~feedbooks~DASH~tiny.png', $src); |
||
48 | |||
49 | $href = ""; |
||
50 | if (preg_match("/href\=\'(.*?)\'/", $data, $matches)) { |
||
51 | $href = $matches [1]; |
||
52 | } |
||
53 | $this->assertEquals ('epubfs.php?data=20&comp=css~SLASH~title.css', $href); |
||
54 | |||
55 | } |
||
56 | |||
57 | public function testImportCss () { |
||
58 | $data = getComponentContent (self::$book, "css~SLASH~title.css", self::$add); |
||
59 | |||
60 | $import = ""; |
||
61 | if (preg_match("/import \'(.*?)\'/", $data, $matches)) { |
||
62 | $import = $matches [1]; |
||
63 | } |
||
64 | $this->assertEquals ('epubfs.php?data=20&comp=css~SLASH~page.css', $import); |
||
65 | } |
||
66 | |||
67 | public function testUrlInCss () { |
||
68 | $data = getComponentContent (self::$book, "css~SLASH~main.css", self::$add); |
||
69 | |||
70 | $src = ""; |
||
71 | if (preg_match("/url\s*\(\'(.*?)\'\)/", $data, $matches)) { |
||
72 | $src = $matches [1]; |
||
73 | } |
||
74 | $this->assertEquals ('epubfs.php?data=20&comp=fonts~SLASH~times.ttf', $src); |
||
75 | } |
||
76 | |||
77 | public function testDirectLink () { |
||
78 | $data = getComponentContent (self::$book, "main10.xml", self::$add); |
||
79 | |||
80 | $src = ""; |
||
81 | if (preg_match("/href\='(.*?)' title=\"Direct Link\"/", $data, $matches)) { |
||
82 | $src = $matches [1]; |
||
83 | } |
||
84 | $this->assertEquals ('epubfs.php?data=20&comp=main2.xml', $src); |
||
85 | } |
||
86 | |||
87 | public function testDirectLinkWithAnchor () { |
||
88 | $data = getComponentContent (self::$book, "main10.xml", self::$add); |
||
89 | |||
90 | $src = ""; |
||
91 | if (preg_match("/href\='(.*?)' title=\"Direct Link with anchor\"/", $data, $matches)) { |
||
92 | $src = $matches [1]; |
||
93 | } |
||
94 | $this->assertEquals ('epubfs.php?data=20&comp=main2.xml#anchor', $src); |
||
95 | } |
||
96 | |||
97 | public function testAnchorOnly () { |
||
98 | $data = getComponentContent (self::$book, "main10.xml", self::$add); |
||
99 | |||
100 | $src = ""; |
||
101 | if (preg_match("/href\='(.*?)' title=\"Link to anchor\"/", $data, $matches)) { |
||
102 | $src = $matches [1]; |
||
103 | } |
||
104 | $this->assertEquals ('#anchor', $src); |
||
105 | } |
||
106 | } |