get view testing
This commit is contained in:
parent
05de80e821
commit
ad6008470f
@ -135,9 +135,12 @@ class PluginWonderful {
|
|||||||
return dirname(__FILE__) . "/../{$source}/{$name}.php";
|
return dirname(__FILE__) . "/../{$source}/{$name}.php";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _include($target) { include($target); }
|
||||||
|
function _file_exists($target) { return @file_exists($target); }
|
||||||
|
|
||||||
function get_view($function_name) {
|
function get_view($function_name) {
|
||||||
$target = $this->_create_target(str_replace('plugin_wonderful_', '', $function_name), "views");
|
$target = $this->_create_target(str_replace('plugin_wonderful_', '', $function_name), "views");
|
||||||
if (file_exists($target)) {
|
if ($this->_file_exists($target)) {
|
||||||
$info = get_plugin_data(realpath(__FILE__));
|
$info = get_plugin_data(realpath(__FILE__));
|
||||||
|
|
||||||
echo '<div class="wrap">';
|
echo '<div class="wrap">';
|
||||||
@ -146,7 +149,7 @@ class PluginWonderful {
|
|||||||
|
|
||||||
$this->show_messages();
|
$this->show_messages();
|
||||||
|
|
||||||
include($target);
|
$this->_include($target);
|
||||||
|
|
||||||
echo '<div style="margin-top: 20px; border-top: solid #E3E3E3 1px; overflow: hidden">';
|
echo '<div style="margin-top: 20px; border-top: solid #E3E3E3 1px; overflow: hidden">';
|
||||||
echo '<form style="float: right; display: inline" action="https://www.paypal.com/cgi-bin/webscr" method="post"><input type="hidden" name="cmd" value="_s-xclick"><input type="hidden" name="hosted_button_id" value="3215507"><input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_SM.gif" border="0" name="submit" alt=""><img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"></form>';
|
echo '<form style="float: right; display: inline" action="https://www.paypal.com/cgi-bin/webscr" method="post"><input type="hidden" name="cmd" value="_s-xclick"><input type="hidden" name="hosted_button_id" value="3215507"><input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_SM.gif" border="0" name="submit" alt=""><img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"></form>';
|
||||||
@ -156,7 +159,7 @@ class PluginWonderful {
|
|||||||
echo '</div>';
|
echo '</div>';
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
} else {
|
} else {
|
||||||
die(__("View not found: ", 'plugin-wonderful') . str_replace('plugin-wonderful_', '', $function_name));
|
echo __("View not found: ", 'plugin-wonderful') . str_replace('plugin_wonderful_', '', $function_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,8 +240,39 @@ class PluginWonderfulTest extends PHPUnit_Framework_TestCase {
|
|||||||
$this->assertEquals($expected_body, $this->pw->inject_ads_into_body_copy("body"));
|
$this->assertEquals($expected_body, $this->pw->inject_ads_into_body_copy("body"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function testGetView() {
|
function providerTestGetView() {
|
||||||
$this->markTestIncomplete();
|
return array(
|
||||||
|
array("**bad**", false),
|
||||||
|
array("**good**", true),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider providerTestGetView
|
||||||
|
*/
|
||||||
|
function testGetView($function_extension, $file_exists) {
|
||||||
|
global $wp_test_expectations;
|
||||||
|
$wp_test_expectations['plugin_data'][realpath(dirname(__FILE__) . '/../classes/PluginWonderful.php')] = array(
|
||||||
|
'Title' => '**title**',
|
||||||
|
'Version' => '**version**',
|
||||||
|
'Author' => '**author**'
|
||||||
|
);
|
||||||
|
|
||||||
|
$pw = $this->getMock('PluginWonderful', array('_create_target', '_include', '_file_exists'));
|
||||||
|
|
||||||
|
$pw->expects($this->once())->method("_file_exists")->will($this->returnValue($file_exists));
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
$pw->get_view("plugin_wonderful_" . $function_extension);
|
||||||
|
$source = ob_get_clean();
|
||||||
|
|
||||||
|
$this->assertEquals($file_exists, strpos($source, $function_extension) === false);
|
||||||
|
|
||||||
|
if ($file_exists) {
|
||||||
|
foreach (array("title", "version", "author") as $name) {
|
||||||
|
$this->assertTrue(strpos($source, "**${name}**") !== false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function testHandleAction() {
|
function testHandleAction() {
|
||||||
|
Loading…
Reference in New Issue
Block a user