Skip to content
Snippets Groups Projects
Commit 7ac1b2cc authored by Andreas Gohr's avatar Andreas Gohr
Browse files

adjusted tests for reflection based method export

parent 67fe7d43
No related branches found
No related tags found
No related merge requests found
......@@ -106,14 +106,32 @@ class remote_plugin_testplugin extends DokuWiki_Remote_Plugin {
function methodString() { return 'success'; }
function method2($str, $int, $bool = false) { return array($str, $int, $bool); }
function publicCall() {return true;}
}
class remote_plugin_testplugin2 extends DokuWiki_Remote_Plugin {
/**
* This is a dummy method
*
* @param string $str some more parameter description
* @param int $int
* @param bool $bool
* @param Object $unknown
* @return array
*/
public function commented($str, $int, $bool, $unknown) { return array($str, $int, $bool); }
private function privateMethod() {return true;}
protected function protectedMethod() {return true;}
public function _underscore() {return true;}
}
class remote_test extends DokuWikiTest {
var $userinfo;
/** @var RemoteAPI */
var $remote;
function setUp() {
......@@ -125,10 +143,18 @@ class remote_test extends DokuWikiTest {
parent::setUp();
// mock plugin controller to return our test plugins
$pluginManager = $this->getMock('Doku_Plugin_Controller');
$pluginManager->expects($this->any())->method('getList')->will($this->returnValue(array('testplugin')));
$pluginManager->expects($this->any())->method('load')->will($this->returnValue(new remote_plugin_testplugin()));
$pluginManager->method('getList')->willReturn(array('testplugin', 'testplugin2'));
$pluginManager->method('load')->willReturnCallback(
function($type, $plugin) {
if($plugin == 'testplugin2') {
return new remote_plugin_testplugin2();
} else {
return new remote_plugin_testplugin();
}
}
);
$plugin_controller = $pluginManager;
$conf['remote'] = 1;
......@@ -151,11 +177,28 @@ class remote_test extends DokuWikiTest {
$methods = $this->remote->getPluginMethods();
$actual = array_keys($methods);
sort($actual);
$expect = array('plugin.testplugin.method1', 'plugin.testplugin.method2', 'plugin.testplugin.methodString', 'plugin.testplugin.method2ext', 'plugin.testplugin.publicCall');
$expect = array(
'plugin.testplugin.method1',
'plugin.testplugin.method2',
'plugin.testplugin.methodString',
'plugin.testplugin.method2ext',
'plugin.testplugin.publicCall',
'plugin.testplugin2.commented'
);
sort($expect);
$this->assertEquals($expect,$actual);
}
function test_pluginDescriptors() {
$methods = $this->remote->getPluginMethods();
$this->assertEquals(array('string','int','bool','string'), $methods['plugin.testplugin2.commented']['args']);
$this->assertEquals('array', $methods['plugin.testplugin2.commented']['return']);
$this->assertEquals(0, $methods['plugin.testplugin2.commented']['public']);
$this->assertContains('This is a dummy method', $methods['plugin.testplugin2.commented']['doc']);
$this->assertContains('string $str some more parameter description', $methods['plugin.testplugin2.commented']['doc']);
}
function test_hasAccessSuccess() {
global $conf;
$conf['remoteuser'] = '';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment