diff --git a/classes/ComicPress.inc b/classes/ComicPress.inc
index 9fc3c4a..7a16cd5 100644
--- a/classes/ComicPress.inc
+++ b/classes/ComicPress.inc
@@ -23,7 +23,30 @@ class ComicPress {
function init() {
$this->load();
- }
+ }
+
+ function get_comic_img_tag($url, $type, $additional_parameters = array()) {
+ $dimensions = array();
+ if (isset($this->comicpress_options["${type}_dimensions"])) {
+ list($width, $height) = explode("x", $this->comicpress_options["${type}_dimensions"]);
+ $dimensions = compact('width', 'height');
+ }
+
+ $output = ' $value) {
+ $output .= $parameter . '="' . $value . '" ';
+ }
+ }
+ $output .= "/>";
+
+ return $output;
+ }
}
?>
\ No newline at end of file
diff --git a/functions.php b/functions.php
index e743b97..8bc1ec4 100644
--- a/functions.php
+++ b/functions.php
@@ -36,6 +36,8 @@ require_once(dirname(__FILE__) . '/options.php');
add_action('init', '__comicpress_init');
function __comicpress_init() {
+ global $comicpress;
+
foreach (glob(dirname(__FILE__) . '/classes/*.inc') as $file) {
if (is_file($file)) { require_once($file); }
}
@@ -81,26 +83,6 @@ function get_last_comic() {
}
function the_comic_img_tag($url, $type, $additional_parameters = array()) {
- global $comicpress_options_admin;
-
- $dimensions = array();
- if (isset($comicpress_options_admin->comicpress_options["${type}_dimensions"])) {
- list($width, $height) = explode("x", $comicpress_options_admin->comicpress_options["${type}_dimensions"]);
- $dimensions = compact('width', 'height');
- }
-
- echo ' $value) {
- echo $parameter . '="' . $value . '" ';
- }
- }
- echo "/>";
}
/**
diff --git a/test/FunctionsTest.php b/test/ComicPressTest.php
similarity index 71%
rename from test/FunctionsTest.php
rename to test/ComicPressTest.php
index f16922c..26f84a9 100644
--- a/test/FunctionsTest.php
+++ b/test/ComicPressTest.php
@@ -2,9 +2,14 @@
require_once('PHPUnit/Framework.php');
require_once(dirname(__FILE__) . '/../../mockpress/mockpress.php');
-require_once(dirname(__FILE__) . '/../functions.php');
+require_once(dirname(__FILE__) . '/../classes/ComicPress.inc');
+
+class ComicPressTest extends PHPUnit_Framework_TestCase {
+ function setUp() {
+ _reset_wp();
+ $this->cp = new ComicPress();
+ }
-class FunctionsTest extends PHPUnit_Framework_TestCase {
function providerTestGenerateComicTag() {
return array(
array(
@@ -20,13 +25,9 @@ class FunctionsTest extends PHPUnit_Framework_TestCase {
* @dataProvider providerTestGenerateComicTag
*/
function testGenerateComicImgTag($dimensions) {
- global $comicpress_options_admin;
+ $this->cp->comicpress_options['comic_dimensions'] = $dimensions;
- $comicpress_options_admin->comicpress_options['comic_dimensions'] = $dimensions;
-
- ob_start();
- the_comic_img_tag("test.gif", "comic");
- $source = ob_get_clean();
+ $source = $this->cp->get_comic_img_tag("test.gif", "comic");
if (count($parts = explode("x", $dimensions)) == 2) {
list($width, $height) = $parts;