set up backward resolving of ids
This commit is contained in:
parent
8c9d8c02d6
commit
621b2b1cbe
|
@ -18,4 +18,15 @@ class ComicPressBackend {
|
||||||
$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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function generate_from_id($id) {
|
||||||
|
$comicpress = ComicPress::get_instance();
|
||||||
|
foreach ($comicpress->backends as $backend) {
|
||||||
|
$result = $backend->generate_from_id($id);
|
||||||
|
if ($result !== false) {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -42,4 +42,25 @@ class ComicPressBackendTest extends PHPUnit_Framework_TestCase {
|
||||||
$this->assertTrue(preg_match($pattern, $result) > 0);
|
$this->assertTrue(preg_match($pattern, $result) > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function providerTestGenerateFromID() {
|
||||||
|
return array(
|
||||||
|
array(null, false),
|
||||||
|
array('1', false),
|
||||||
|
array('attachment-1', (object)array('ID' => 1))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider providerTestGenerateFromID
|
||||||
|
*/
|
||||||
|
function testGenerateFromID($id, $expected_result) {
|
||||||
|
$backend = $this->getMock('ComicPressFakeBackend', array('generate_from_id'));
|
||||||
|
$backend->expects($this->once())->method('generate_from_id')->with($id)->will($this->returnValue($expected_result));
|
||||||
|
|
||||||
|
$comicpress = ComicPress::get_instance();
|
||||||
|
$comicpress->backends = array($backend);
|
||||||
|
|
||||||
|
$this->assertEquals($expected_result, ComicPressBackend::generate_from_id($id));
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue