aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/_test/tests
diff options
context:
space:
mode:
authorPhy <git@phy25.com>2020-03-08 17:50:57 -0400
committerPhy <git@phy25.com>2020-03-08 17:50:57 -0400
commit7a0654bebf4826ea3bae330c78ec73080c48d9e3 (patch)
treec33e211af8bbc55d2f3b7f957c063848b377f93f /_test/tests
parent6d7829a73fc86a540c1a538fa7f5190c9ce6c705 (diff)
downloaddokuwiki-7a0654bebf4826ea3bae330c78ec73080c48d9e3.tar.gz
dokuwiki-7a0654bebf4826ea3bae330c78ec73080c48d9e3.zip
check RemoteException code in unit tests
Diffstat (limited to '_test/tests')
-rw-r--r--_test/tests/inc/remote.test.php52
1 files changed, 32 insertions, 20 deletions
diff --git a/_test/tests/inc/remote.test.php b/_test/tests/inc/remote.test.php
index cef95480f..57bec8762 100644
--- a/_test/tests/inc/remote.test.php
+++ b/_test/tests/inc/remote.test.php
@@ -3,6 +3,7 @@
use dokuwiki\Extension\AuthPlugin;
use dokuwiki\Extension\RemotePlugin;
use dokuwiki\Remote\Api;
+use dokuwiki\Remote\RemoteException;
class remote_test_MockAuthCase extends AuthPlugin {
function isCaseSensitive() { return true; }
@@ -263,13 +264,16 @@ class remote_test extends DokuWikiTest {
$this->assertTrue(true); // avoid being marked as risky for having no assertion
}
- /**
- * @expectedException dokuwiki\Remote\RemoteException
- */
function test_forceAccessFail() {
global $conf;
$conf['remote'] = 0;
- $this->remote->forceAccess();
+
+ try {
+ $this->remote->forceAccess();
+ $this->fail('Expects RemoteException to be raised');
+ } catch (RemoteException $th) {
+ $this->assertEquals(-32604, $th->getCode());
+ }
}
function test_generalCoreFunctionWithoutArguments() {
@@ -290,16 +294,18 @@ class remote_test extends DokuWikiTest {
$this->assertEquals($remoteApi->call('wiki.voidTestMethod'), null);
}
- /**
- * @expectedException dokuwiki\Remote\RemoteException
- */
function test_generalCoreFunctionOnArgumentMismatch() {
global $conf;
$conf['remote'] = 1;
$remoteApi = new Api();
$remoteApi->getCoreMethods(new RemoteAPICoreTest());
- $remoteApi->call('wiki.voidTestMethod', array('something'));
+ try {
+ $remoteApi->call('wiki.voidTestMethod', array('something'));
+ $this->fail('Expects RemoteException to be raised');
+ } catch (RemoteException $th) {
+ $this->assertEquals(-32604, $th->getCode());
+ }
}
function test_generalCoreFunctionWithArguments() {
@@ -318,9 +324,6 @@ class remote_test extends DokuWikiTest {
$this->assertEquals($remoteApi->call('wiki.twoArgWithDefaultArg', array('string', 'another')), array('string', 'another'));
}
- /**
- * @expectedException dokuwiki\Remote\RemoteException
- */
function test_generalCoreFunctionOnArgumentMissing() {
global $conf;
$conf['remote'] = 1;
@@ -328,7 +331,12 @@ class remote_test extends DokuWikiTest {
$remoteApi = new Api();
$remoteApi->getCoreMethods(new RemoteAPICoreTest());
- $remoteApi->call('wiki.twoArgWithDefaultArg', array());
+ try {
+ $remoteApi->call('wiki.twoArgWithDefaultArg', array());
+ $this->fail('Expects RemoteException to be raised');
+ } catch (RemoteException $th) {
+ $this->assertEquals(-32603, $th->getCode());
+ }
}
function test_pluginCallMethods() {
@@ -345,9 +353,6 @@ class remote_test extends DokuWikiTest {
$this->assertEquals($remoteApi->call('plugin.testplugin.methodString'), 'success');
}
- /**
- * @expectedException dokuwiki\Remote\RemoteException
- */
function test_pluginCallMethodsOnArgumentMissing() {
global $conf;
$conf['remote'] = 1;
@@ -355,18 +360,25 @@ class remote_test extends DokuWikiTest {
$remoteApi = new Api();
$remoteApi->getCoreMethods(new RemoteAPICoreTest());
- $remoteApi->call('plugin.testplugin.method2', array());
+ try {
+ $remoteApi->call('plugin.testplugin.method2', array());
+ $this->fail('Expects RemoteException to be raised');
+ } catch (RemoteException $th) {
+ $this->assertEquals(-32603, $th->getCode());
+ }
}
- /**
- * @expectedException dokuwiki\Remote\RemoteException
- */
function test_notExistingCall() {
global $conf;
$conf['remote'] = 1;
$remoteApi = new Api();
- $remoteApi->call('dose not exist');
+ try {
+ $remoteApi->call('dose not exist');
+ $this->fail('Expects RemoteException to be raised');
+ } catch (RemoteException $th) {
+ $this->assertEquals(-32603, $th->getCode());
+ }
}
function test_publicCallCore() {