more code coverage cleanups
This commit is contained in:
parent
510fadcf43
commit
843d3eb34c
|
@ -3,15 +3,19 @@
|
||||||
class ComicPressBackend {
|
class ComicPressBackend {
|
||||||
function _embed_image($size) {
|
function _embed_image($size) {
|
||||||
$extras = array();
|
$extras = array();
|
||||||
if (($dims = $this->dims($size)) !== false) {
|
$dims = $this->dims($size);
|
||||||
$extras = array_merge($extras, $dims);
|
if (!empty($dims)) {
|
||||||
|
if (is_array($dims)) {
|
||||||
|
$extras = array_merge($extras, $dims);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($extras as $field => $value) {
|
foreach ($extras as $field => $value) {
|
||||||
$extras[] = "${field}=\"${value}\"";
|
$extras[] = "${field}=\"${value}\" ";
|
||||||
unset($extras[$field]);
|
unset($extras[$field]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = sprintf('<img src="%s" alt="%s" title="%s" %s />', $this->url(), $this->alt(), $this->title(), implode(" ", $extras));
|
$output = sprintf('<img src="%s" alt="%s" title="%s" %s/>', $this->url(), $this->alt(), $this->title(), implode("", $extras));
|
||||||
return apply_filters('comicpress_embed_image', $output, $this);
|
return apply_filters('comicpress_embed_image', $output, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,10 +4,12 @@ require_once('ComicPressStoryline.inc');
|
||||||
require_once('ComicPressDBInterface.inc');
|
require_once('ComicPressDBInterface.inc');
|
||||||
|
|
||||||
class ComicPressNavigation {
|
class ComicPressNavigation {
|
||||||
|
// @codeCoverageIgnoreStart
|
||||||
function init($storyline) {
|
function init($storyline) {
|
||||||
$this->_storyline = $storyline;
|
$this->_storyline = $storyline;
|
||||||
$this->_dbi = ComicPressDBInterface::get_instance();
|
$this->_dbi = ComicPressDBInterface::get_instance();
|
||||||
}
|
}
|
||||||
|
// @codeCoverageIgnoreEnd
|
||||||
|
|
||||||
function get_post_nav($post) {
|
function get_post_nav($post) {
|
||||||
$nav = array();
|
$nav = array();
|
||||||
|
@ -61,6 +63,7 @@ class ComicPressNavigation {
|
||||||
return $nav;
|
return $nav;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once('PHPUnit/Framework.php');
|
||||||
|
require_once('MockPress/mockpress.php');
|
||||||
|
require_once('ComicPressBackend.inc');
|
||||||
|
|
||||||
|
class ComicPressBackendTest extends PHPUnit_Framework_TestCase {
|
||||||
|
function providerTestEmbedImage() {
|
||||||
|
return array(
|
||||||
|
array(
|
||||||
|
false, array(
|
||||||
|
'#^<img src="http://comic" alt="alt" title="title" />$#'
|
||||||
|
)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array(), array(
|
||||||
|
'#^<img src="http://comic" alt="alt" title="title" />$#'
|
||||||
|
)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('width' => 320, 'height' => 240), array(
|
||||||
|
'#^<img src="http://comic" alt="alt" title="title" width="320" height="240" />$#'
|
||||||
|
)
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider providerTestEmbedImage
|
||||||
|
*/
|
||||||
|
function testEmbedImage($dims_result, $expected_result_patterns) {
|
||||||
|
$backend = $this->getMock('ComicPressBackend', array('dims', 'url', 'alt', 'title'));
|
||||||
|
|
||||||
|
$backend->expects($this->once())->method('dims')->with('comic')->will($this->returnValue($dims_result));
|
||||||
|
$backend->expects($this->once())->method('url')->will($this->returnValue('http://comic'));
|
||||||
|
$backend->expects($this->once())->method('alt')->will($this->returnValue('alt'));
|
||||||
|
$backend->expects($this->once())->method('title')->will($this->returnValue('title'));
|
||||||
|
|
||||||
|
$result = $backend->_embed_image('comic');
|
||||||
|
|
||||||
|
foreach ($expected_result_patterns as $pattern) {
|
||||||
|
$this->assertTrue(preg_match($pattern, $result) > 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,6 +13,14 @@ class ComicPressNavigationTest extends PHPUnit_Framework_TestCase {
|
||||||
$this->nav = new ComicPressNavigation();
|
$this->nav = new ComicPressNavigation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testGetPostNavNotAPost() {
|
||||||
|
$this->assertTrue($this->nav->get_post_nav(false) === false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testGetPostNavFromCache() {
|
||||||
|
$this->markTestIncomplete();
|
||||||
|
}
|
||||||
|
|
||||||
function testGetPostNav() {
|
function testGetPostNav() {
|
||||||
$dbi = $this->getMock('ComicPressDBInterface', array('get_previous_comic', 'get_next_comic', 'get_first_comic', 'get_last_comic'));
|
$dbi = $this->getMock('ComicPressDBInterface', array('get_previous_comic', 'get_next_comic', 'get_first_comic', 'get_last_comic'));
|
||||||
$storyline = new ComicPressStoryline();
|
$storyline = new ComicPressStoryline();
|
||||||
|
|
Loading…
Reference in New Issue