set up widget rendering tests
This commit is contained in:
parent
03bc11fb74
commit
bf057fdc9d
@ -93,7 +93,7 @@ class PluginWonderful {
|
|||||||
if (!empty($result)) { echo $result; }
|
if (!empty($result)) { echo $result; }
|
||||||
}
|
}
|
||||||
|
|
||||||
function render_widget($options, $adboxid) {
|
function render_widget($adboxid) {
|
||||||
if ($this->publisher_info !== false) {
|
if ($this->publisher_info !== false) {
|
||||||
foreach ($this->publisher_info->adboxes as $adbox) {
|
foreach ($this->publisher_info->adboxes as $adbox) {
|
||||||
if (($adbox->adboxid == $adboxid) || ($adbox->template_tag_id == $adboxid)) {
|
if (($adbox->adboxid == $adboxid) || ($adbox->template_tag_id == $adboxid)) {
|
||||||
|
@ -15,9 +15,9 @@ class PluginWonderfulWidget extends WP_Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function widget($args, $instance) {
|
function widget($args, $instance) {
|
||||||
extract($args);
|
global $plugin_wonderful;
|
||||||
|
|
||||||
|
|
||||||
|
$plugin_wonderful->render_widget($instance['adboxid']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,6 +179,44 @@ class PluginWonderfulTest extends PHPUnit_Framework_TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function providerTestRenderWidget() {
|
||||||
|
return array(
|
||||||
|
array(false, null, null, null, ""),
|
||||||
|
array(true, null, null, null, ""),
|
||||||
|
array(true, "123", 0, null, "advanced"),
|
||||||
|
array(true, "123", 1, null, "standard"),
|
||||||
|
array(true, "abc", 1, null, "standard"),
|
||||||
|
array(true, "abc", 1, 1, "<center>standard</center>")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider providerTestRenderWidget
|
||||||
|
*/
|
||||||
|
function testRenderWidget($has_publisher_info, $requested_adboxid, $use_standardcode, $center_widget, $expected_result) {
|
||||||
|
$test_ad = (object)array(
|
||||||
|
'adboxid' => '123',
|
||||||
|
'template_tag_id' => 'abc',
|
||||||
|
'standardcode' => 'standard',
|
||||||
|
'advancedcode' => 'advanced',
|
||||||
|
'center_widget' => $center_widget
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($has_publisher_info) {
|
||||||
|
$this->pw->publisher_info = (object)array(
|
||||||
|
'adboxes' => array($test_ad)
|
||||||
|
);
|
||||||
|
|
||||||
|
update_option("plugin-wonderful-use-standardcode", $use_standardcode);
|
||||||
|
} else {
|
||||||
|
$this->pw->publisher_info = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
$this->pw->render_widget($requested_adboxid);
|
||||||
|
$this->assertEquals($expected_result, ob_get_clean());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Reference in New Issue
Block a user