summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
authorDominik Eckelmann <deckelmann@gmail.com>2011-11-28 19:06:16 +0100
committerDominik Eckelmann <deckelmann@gmail.com>2011-11-28 19:11:07 +0100
commitf61380cb67f8216ae4c75922511ff5a07fd21ca0 (patch)
tree6925835b4b8f4e8455ac6f4994ef4e00e215c67a /_test
parent2d2d9d0f3a410b31d76a2be193fe16b3dbd79096 (diff)
downloadrpg-f61380cb67f8216ae4c75922511ff5a07fd21ca0.tar.gz
rpg-f61380cb67f8216ae4c75922511ff5a07fd21ca0.tar.bz2
introduced first remote test cases
Diffstat (limited to '_test')
-rw-r--r--_test/cases/inc/remote.test.php77
1 files changed, 77 insertions, 0 deletions
diff --git a/_test/cases/inc/remote.test.php b/_test/cases/inc/remote.test.php
new file mode 100644
index 000000000..aa7a8cd1b
--- /dev/null
+++ b/_test/cases/inc/remote.test.php
@@ -0,0 +1,77 @@
+<?php
+
+require_once DOKU_INC . 'inc/init.php';
+
+Mock::generate('Doku_Plugin_Controller');
+
+class remote_plugin_testplugin extends DokuWiki_Remote_Plugin {
+ function _getMethods() {
+ return array(
+ 'method1' => array(
+ 'args' => array(),
+ 'return' => 'void'
+ ),
+ 'method2' => array(
+ 'args' => array('string', 'int', 'bool'),
+ 'return' => array('string'),
+ )
+ );
+ }
+}
+
+
+class remote_test extends UnitTestCase {
+
+ var $originalConf;
+
+ var $remote;
+
+ function setUp() {
+ global $plugin_controller;
+ global $conf;
+ parent::setUp();
+ $pluginManager = new MockDoku_Plugin_Controller();
+ $pluginManager->setReturnValue('getList', array('testplugin'));
+ $pluginManager->setReturnValue('load', new remote_plugin_testplugin());
+ $plugin_controller = $pluginManager;
+
+ $this->originalConf = $conf;
+
+ $this->remote = new RemoteAPI();
+ }
+
+ function tearDown() {
+ global $conf;
+ $conf = $this->originalConf;
+ }
+
+ function test_pluginMethods() {
+ $methods = $this->remote->getPluginMethods();
+ $this->assertEqual(array_keys($methods), array('plugin.testplugin.method1', 'plugin.testplugin.method2'));
+ }
+
+ function test_hasAccessSuccess() {
+ global $conf;
+ $conf['remote'] = 1;
+ $this->assertTrue($this->remote->hasAccess());
+ }
+
+ function test_hasAccessFail() {
+ global $conf;
+ $conf['remote'] = 0;
+ $this->assertFalse($this->remote->hasAccess());
+ }
+
+ function test_forceAccessSuccess() {
+ global $conf;
+ $conf['remote'] = 1;
+ $this->remote->forceAccess(); // no exception should occur
+ }
+
+ function test_forceAccessFail() {
+ global $conf;
+ $conf['remote'] = 0;
+ $this->expectException('RemoteException');
+ $this->remote->forceAccess();
+ }
+}