From c0767b0c6e4313c3d741a24d7a7bd5ef062913e6 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Tue, 10 Nov 2009 23:11:48 -0500 Subject: [PATCH] finish tests for attachment backend --- .../backends/ComicPressBackendAttachment.inc | 2 +- .../ComicPressBackendAttachmentTest.php | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/classes/backends/ComicPressBackendAttachment.inc b/classes/backends/ComicPressBackendAttachment.inc index 2a99d73..b8f7b0b 100644 --- a/classes/backends/ComicPressBackendAttachment.inc +++ b/classes/backends/ComicPressBackendAttachment.inc @@ -36,7 +36,6 @@ class ComicPressBackendAttachment extends ComicPressBackend { $this->type = get_post_meta($this->attachment->ID, 'comic_image_type', true); } - // @codeCoverageIgnoreStart function dims($size = 'comic') { $metadata = image_downsize($this->attachment->ID, $size); if (!empty($metadata)) { @@ -57,6 +56,7 @@ class ComicPressBackendAttachment extends ComicPressBackend { return false; } + // @codeCoverageIgnoreStart function embed($size = 'comic') { return $this->_embed_image($size); } diff --git a/test/backends/ComicPressBackendAttachmentTest.php b/test/backends/ComicPressBackendAttachmentTest.php index 641f342..999ac8e 100644 --- a/test/backends/ComicPressBackendAttachmentTest.php +++ b/test/backends/ComicPressBackendAttachmentTest.php @@ -7,6 +7,8 @@ require_once('backends/ComicPressBackendAttachment.inc'); class ComicPressBackendAttachmentTest extends PHPUnit_Framework_TestCase { function setUp() { _reset_wp(); + + $this->ba = new ComicPressBackendAttachment((object)array('ID' => 1)); } function providerTestGenerateFromPost() { @@ -40,4 +42,38 @@ class ComicPressBackendAttachmentTest extends PHPUnit_Framework_TestCase { } } } + + function providerTestDims() { + return array( + array(false, false), + array(true, false), + array(array(), false), + array(array('url', 300, 200, false), array('width' => 300, 'height' => 200)) + ); + } + + /** + * @dataProvider providerTestDims + */ + function testDims($image_downsize_result, $expected_result) { + _set_image_downsize_result(1, 'comic', $image_downsize_result); + $this->assertEquals($expected_result, $this->ba->dims('comic')); + } + + function providerTestUrl() { + return array( + array(false, false), + array(true, false), + array(array(), false), + array(array('url', 300, 200, false), 'url') + ); + } + + /** + * @dataProvider providerTestUrl + */ + function testUrl($image_downsize_result, $expected_result) { + _set_image_downsize_result(1, 'comic', $image_downsize_result); + $this->assertEquals($expected_result, $this->ba->url('comic')); + } } \ No newline at end of file