From 4590eed89a9082cbac2e407df0cad3065e20b3f4 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Tue, 1 Dec 2009 07:20:33 -0500 Subject: [PATCH] code coverage --- test/widgets/BuyThisPrintWidgetTest.php | 22 ++++++++++++++++++++++ widgets/BuyThisPrintWidget.inc | 7 ++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/test/widgets/BuyThisPrintWidgetTest.php b/test/widgets/BuyThisPrintWidgetTest.php index 4da9c11..7eb99f1 100644 --- a/test/widgets/BuyThisPrintWidgetTest.php +++ b/test/widgets/BuyThisPrintWidgetTest.php @@ -33,4 +33,26 @@ class BuyThisPrintWidgetTest extends PHPUnit_Framework_TestCase { function testUpdate($input, $expected_output) { $this->assertEquals($expected_output, $this->w->update($input)); } + + function testBuyThisPrintStructure() { + global $post, $buy_print_url; + + $buy_print_url = 'buy print url'; + $post = (object)array('ID' => 10); + + $result = $this->w->buy_print_structure(); + + $this->assertTag(array( + 'tag' => 'form', + 'attributes' => array('action' => $buy_print_url) + ), $result); + + $this->assertTag(array( + 'tag' => 'input', + 'attributes' => array( + 'name' => 'comic', + 'value' => 10 + ) + ), $result); + } } diff --git a/widgets/BuyThisPrintWidget.inc b/widgets/BuyThisPrintWidget.inc index 39906a7..c8b91d5 100644 --- a/widgets/BuyThisPrintWidget.inc +++ b/widgets/BuyThisPrintWidget.inc @@ -15,9 +15,11 @@ class BuyThisPrintWidget extends WP_Widget { $this->WP_Widget('comicpress_buyprint', __('Buy This Print','comicpress'), $widget_ops); } + // @codeCoverageIgnoreStart function init() { add_filter('comicpress_buy_print_structure', array(&$this, 'buy_print_structure')); } + // @codeCoverageIgnoreEnd function widget($args, $instance) { extract($args, EXTR_SKIP); @@ -34,12 +36,15 @@ class BuyThisPrintWidget extends WP_Widget { } function buy_print_structure($content = '') { - global $buy_print_url; ?> + global $buy_print_url; + ob_start(); + ?>