From 6d3d9dba292cf0b589c8531d5b2bb21fb81cbce5 Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Sat, 6 Feb 2021 01:35:34 +0100 Subject: [PATCH] Improve remote_test::test_notExistingCall() There are actually 2 distinct test cases of invalid methods: 1. Not following the definition in Api class's PHPDoc block - core methods begin by a 'dokuwiki' or 'wiki' followed by a . and the method name itself. - plugin methods are formed like 'plugin..' 2. Method "type" does not begin with 'dokuwiki', 'wiki' or 'plugin' A new check was added so both are now covered. Test was modified to make use of PHPUnit expectException() method, instead of relying on a try/catch block. --- _test/tests/inc/remote.test.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/_test/tests/inc/remote.test.php b/_test/tests/inc/remote.test.php index 8d4542c2e..efe18d7ef 100644 --- a/_test/tests/inc/remote.test.php +++ b/_test/tests/inc/remote.test.php @@ -366,13 +366,12 @@ class remote_test extends DokuWikiTest { global $conf; $conf['remote'] = 1; + $this->expectException(RemoteException::class); + $this->expectExceptionCode(-32603); + $remoteApi = new Api(); - try { - $remoteApi->call('does.not exist'); - $this->fail('Expects RemoteException to be raised'); - } catch (RemoteException $th) { - $this->assertEquals(-32603, $th->getCode()); - } + $remoteApi->call('invalid method'); // no '.' + $remoteApi->call('does.not exist'); // unknown method type } function test_publicCallCore() { -- 2.11.4.GIT