code coverage
This commit is contained in:
parent
1bb7edfd04
commit
4590eed89a
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
?>
|
||||
<div class="buythis"><form method="post" action="<?php echo $buy_print_url; ?>">
|
||||
<input type="hidden" name="comic" value="<?php echo get_the_ID(); ?>" />
|
||||
<button class="buythisbutton" type="submit" value="submit" name="submit"></button></form></div>
|
||||
<div class="clear"></div>
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
function update($new_instance, $old_instance = array()) {
|
||||
|
|
Loading…
Reference in New Issue