2009-07-07 02:45:17 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once('PHPUnit/Framework.php');
|
|
|
|
require_once(dirname(__FILE__) . '/../../mockpress/mockpress.php');
|
2009-07-08 23:54:56 +00:00
|
|
|
require_once(dirname(__FILE__) . '/../classes/ComicPress.inc');
|
|
|
|
|
|
|
|
class ComicPressTest extends PHPUnit_Framework_TestCase {
|
|
|
|
function setUp() {
|
|
|
|
_reset_wp();
|
|
|
|
$this->cp = new ComicPress();
|
|
|
|
}
|
2009-07-07 02:45:17 +00:00
|
|
|
|
|
|
|
function providerTestGenerateComicTag() {
|
|
|
|
return array(
|
|
|
|
array(
|
|
|
|
"150x150",
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
false,
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider providerTestGenerateComicTag
|
|
|
|
*/
|
|
|
|
function testGenerateComicImgTag($dimensions) {
|
2009-07-08 23:54:56 +00:00
|
|
|
$this->cp->comicpress_options['comic_dimensions'] = $dimensions;
|
2009-07-07 02:45:17 +00:00
|
|
|
|
2009-07-08 23:54:56 +00:00
|
|
|
$source = $this->cp->get_comic_img_tag("test.gif", "comic");
|
2009-07-07 02:45:17 +00:00
|
|
|
|
|
|
|
if (count($parts = explode("x", $dimensions)) == 2) {
|
|
|
|
list($width, $height) = $parts;
|
|
|
|
$dimensions = compact('width', 'height');
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (array('width', 'height') as $field) {
|
|
|
|
if (isset($dimensions[$field])) {
|
|
|
|
$this->assertTrue(strpos($source, "${field}=\"{$dimensions[$field]}\"") !== false, $field);
|
|
|
|
} else {
|
|
|
|
$this->assertTrue(strpos($source, "${field}=") === false, 'not set');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|