diff options
author | Andreas Gohr <andi@splitbrain.org> | 2019-05-19 11:09:54 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2019-05-19 11:09:54 +0200 |
commit | 820934dc5dde4982117063a0296c135334fdc7a3 (patch) | |
tree | 2800e0debfee31704b5e52c33e3d56e05270bf61 /_test | |
parent | b8c09b6854c4210a9c9fef089a48f5320420d469 (diff) | |
parent | c47e666521a91dba7c802073af36cad88c8d9244 (diff) | |
download | dokuwiki-820934dc5dde4982117063a0296c135334fdc7a3.tar.gz dokuwiki-820934dc5dde4982117063a0296c135334fdc7a3.zip |
Merge branch 'psr2-pluginredux' into psr2
* psr2-pluginredux:
Minor optimizations in PluginController
Snake to Camel case fixes inn PluginController
Fix snake->camel case, doc blocks
minor code simplification
snake to camel case fixes in EventHandler
Move list of plugin types to plugin controller constant
Avoid accessing the evet system before it's intialized
Avoid processing events before the Event System is intiialized
isEnabled instead of isDisabled
removed get_directory() method from PluginController
fix type hints
moved plugin controller to Extension namespace
removed deleted file from autoloader
deprecated trigger_event() in favor of a static method on Event
First go at moving the plugin classes into their own namespace
Diffstat (limited to '_test')
-rw-r--r-- | _test/core/DokuWikiTest.php | 11 | ||||
-rw-r--r-- | _test/mock/AuthPlugin.php | 10 | ||||
-rw-r--r-- | _test/mock/DokuWiki_Auth_Plugin.php | 10 | ||||
-rw-r--r-- | _test/tests/inc/PageUtilsIsHiddenPage.test.php | 8 | ||||
-rw-r--r-- | _test/tests/inc/auth_aclcheck.test.php | 4 | ||||
-rw-r--r-- | _test/tests/inc/auth_aclcheck_caseinsensitive.test.php | 4 | ||||
-rw-r--r-- | _test/tests/inc/auth_admincheck.test.php | 6 | ||||
-rw-r--r-- | _test/tests/inc/auth_deleteprofile.test.php | 13 | ||||
-rw-r--r-- | _test/tests/inc/common_saveWikiText.test.php | 2 | ||||
-rw-r--r-- | _test/tests/inc/events_nested.test.php | 6 | ||||
-rw-r--r-- | _test/tests/inc/pageutils_findnearest.test.php | 4 | ||||
-rw-r--r-- | _test/tests/inc/remote.test.php | 10 | ||||
-rw-r--r-- | _test/tests/inc/remoteapicore.test.php | 6 |
13 files changed, 53 insertions, 41 deletions
diff --git a/_test/core/DokuWikiTest.php b/_test/core/DokuWikiTest.php index c9a598af4..6e8049450 100644 --- a/_test/core/DokuWikiTest.php +++ b/_test/core/DokuWikiTest.php @@ -1,4 +1,9 @@ <?php + +use dokuwiki\Extension\PluginController; +use dokuwiki\Extension\Event; +use dokuwiki\Extension\EventHandler; + if(!class_exists('PHPUnit_Framework_TestCase')) { /** * phpunit 5/6 compatibility @@ -103,7 +108,7 @@ abstract class DokuWikiTest extends PHPUnit_Framework_TestCase { // reset loaded plugins global $plugin_controller_class, $plugin_controller; - /** @var Doku_Plugin_Controller $plugin_controller */ + /** @var PluginController $plugin_controller */ $plugin_controller = new $plugin_controller_class(); // disable all non-default plugins @@ -133,11 +138,11 @@ abstract class DokuWikiTest extends PHPUnit_Framework_TestCase { // reset event handler global $EVENT_HANDLER; - $EVENT_HANDLER = new Doku_Event_Handler(); + $EVENT_HANDLER = new EventHandler(); // reload language $local = $conf['lang']; - trigger_event('INIT_LANG_LOAD', $local, 'init_lang', true); + Event::createAndTrigger('INIT_LANG_LOAD', $local, 'init_lang', true); global $INPUT; $INPUT = new \dokuwiki\Input\Input(); diff --git a/_test/mock/AuthPlugin.php b/_test/mock/AuthPlugin.php new file mode 100644 index 000000000..53edb2fe1 --- /dev/null +++ b/_test/mock/AuthPlugin.php @@ -0,0 +1,10 @@ +<?php + +namespace dokuwiki\test\mock; + +/** + * Class dokuwiki\Plugin\DokuWiki_Auth_Plugin + */ +class AuthPlugin extends \dokuwiki\Extension\AuthPlugin { + +} diff --git a/_test/mock/DokuWiki_Auth_Plugin.php b/_test/mock/DokuWiki_Auth_Plugin.php deleted file mode 100644 index 9014b020f..000000000 --- a/_test/mock/DokuWiki_Auth_Plugin.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php - -namespace dokuwiki\test\mock; - -/** - * Class DokuWiki_Auth_Plugin - */ -class DokuWiki_Auth_Plugin extends \DokuWiki_Auth_Plugin { - -} diff --git a/_test/tests/inc/PageUtilsIsHiddenPage.test.php b/_test/tests/inc/PageUtilsIsHiddenPage.test.php index a7077862e..09ab78e1b 100644 --- a/_test/tests/inc/PageUtilsIsHiddenPage.test.php +++ b/_test/tests/inc/PageUtilsIsHiddenPage.test.php @@ -41,7 +41,7 @@ class PageUtilsIsHiddenPageTest extends DokuWikiTest { $this->assertTrue(isHiddenPage('another')); } - function alwaysHide(Doku_Event &$event, $params) { + function alwaysHide(Doku_Event $event, $params) { $event->data['hidden'] = true; } @@ -53,7 +53,7 @@ class PageUtilsIsHiddenPageTest extends DokuWikiTest { $this->assertFalse(isHiddenPage('test')); } - function showBefore(Doku_Event &$event, $params) { + function showBefore(Doku_Event $event, $params) { $event->data['hidden'] = false; $event->preventDefault(); $event->stopPropagation(); @@ -75,7 +75,7 @@ class PageUtilsIsHiddenPageTest extends DokuWikiTest { $this->assertTrue(isHiddenPage('another')); } - function hideBeforeWithoutPrevent(Doku_Event &$event, $params) { + function hideBeforeWithoutPrevent(Doku_Event $event, $params) { $event->data['hidden'] = true; } @@ -87,7 +87,7 @@ class PageUtilsIsHiddenPageTest extends DokuWikiTest { $this->assertFalse(isHiddenPage('test')); } - function showAfter(Doku_Event &$event, $params) { + function showAfter(Doku_Event $event, $params) { $event->data['hidden'] = false; } diff --git a/_test/tests/inc/auth_aclcheck.test.php b/_test/tests/inc/auth_aclcheck.test.php index 4f1103ff2..2b5342e43 100644 --- a/_test/tests/inc/auth_aclcheck.test.php +++ b/_test/tests/inc/auth_aclcheck.test.php @@ -1,6 +1,6 @@ <?php -use dokuwiki\test\mock\DokuWiki_Auth_Plugin; +use dokuwiki\test\mock\AuthPlugin; class auth_acl_test extends DokuWikiTest { @@ -11,7 +11,7 @@ class auth_acl_test extends DokuWikiTest { global $AUTH_ACL; global $auth; $this->oldAuthAcl = $AUTH_ACL; - $auth = new DokuWiki_Auth_Plugin(); + $auth = new AuthPlugin(); } function tearDown() { diff --git a/_test/tests/inc/auth_aclcheck_caseinsensitive.test.php b/_test/tests/inc/auth_aclcheck_caseinsensitive.test.php index 21b2cfdb0..644675de4 100644 --- a/_test/tests/inc/auth_aclcheck_caseinsensitive.test.php +++ b/_test/tests/inc/auth_aclcheck_caseinsensitive.test.php @@ -1,6 +1,8 @@ <?php -class auth_acl_caseinsensitive_auth extends DokuWiki_Auth_Plugin { +use dokuwiki\Extension\AuthPlugin; + +class auth_acl_caseinsensitive_auth extends AuthPlugin { function isCaseSensitive() { return false; } diff --git a/_test/tests/inc/auth_admincheck.test.php b/_test/tests/inc/auth_admincheck.test.php index c4aa78ce5..82ddafcff 100644 --- a/_test/tests/inc/auth_admincheck.test.php +++ b/_test/tests/inc/auth_admincheck.test.php @@ -1,8 +1,8 @@ <?php -use dokuwiki\test\mock\DokuWiki_Auth_Plugin; +use dokuwiki\test\mock\AuthPlugin; -class auth_admin_test_AuthInSensitive extends DokuWiki_Auth_Plugin { +class auth_admin_test_AuthInSensitive extends AuthPlugin { function isCaseSensitive(){ return false; } @@ -20,7 +20,7 @@ class auth_admin_test extends DokuWikiTest { function setSensitive() { global $auth; - $auth = new DokuWiki_Auth_Plugin(); + $auth = new AuthPlugin(); } function setInSensitive() { diff --git a/_test/tests/inc/auth_deleteprofile.test.php b/_test/tests/inc/auth_deleteprofile.test.php index e9f679d5c..2195ee97d 100644 --- a/_test/tests/inc/auth_deleteprofile.test.php +++ b/_test/tests/inc/auth_deleteprofile.test.php @@ -1,13 +1,14 @@ <?php use dokuwiki\Input\Input; +use dokuwiki\Extension\AuthPlugin; -class Mock_Auth_Plugin extends DokuWiki_Auth_Plugin { +class Mock_Auth_Plugin extends AuthPlugin { - public $loggedOff = false; + public $loggedOff = false; public function __construct($canDeleteUser = true) { - $this->cando['delUser'] = $canDeleteUser; + $this->cando['delUser'] = $canDeleteUser; } public function checkPass($user, $pass) { @@ -15,11 +16,11 @@ class Mock_Auth_Plugin extends DokuWiki_Auth_Plugin { } public function deleteUsers($users) { - return in_array($_SERVER['REMOTE_USER'], $users); + return in_array($_SERVER['REMOTE_USER'], $users); } public function logoff() { - $this->loggedOff = true; + $this->loggedOff = true; } } @@ -29,7 +30,7 @@ class auth_deleteprofile_test extends DokuWikiTest { /* * Tests: * - * 1. It works and the user is logged off + * 1. It works and the user is logged off * 2. Password matches when config requires it * 3,4. Auth plugin can prevent & wiki config can prevent * 5. Any of invalid security token, missing/not set 'delete' flag, missing/unchecked 'confirm_delete' diff --git a/_test/tests/inc/common_saveWikiText.test.php b/_test/tests/inc/common_saveWikiText.test.php index d363fbf0e..7ae12ca27 100644 --- a/_test/tests/inc/common_saveWikiText.test.php +++ b/_test/tests/inc/common_saveWikiText.test.php @@ -168,7 +168,7 @@ class common_saveWikiText_test extends DokuWikiTest { function test_savesequencedeleteexternalrevision() { // add an additional delay when saving files to make sure // nobody relies on the saving happening in the same second - /** @var $EVENT_HANDLER Doku_Event_Handler */ + /** @var $EVENT_HANDLER \dokuwiki\Extension\EventHandler */ global $EVENT_HANDLER; $EVENT_HANDLER->register_hook('IO_WIKIPAGE_WRITE', 'BEFORE', $this, 'handle_write'); diff --git a/_test/tests/inc/events_nested.test.php b/_test/tests/inc/events_nested.test.php index fe5e395bb..3ed2fcf34 100644 --- a/_test/tests/inc/events_nested.test.php +++ b/_test/tests/inc/events_nested.test.php @@ -1,5 +1,7 @@ <?php +use dokuwiki\Extension\Event; + /** * This tests if event handlers can trigger the same event again. * This is used by plugins that modify cache handling and use metadata @@ -16,7 +18,7 @@ class events_nested_test extends DokuWikiTest { $firstcount++; if ($firstcount == 1) { $param = array(); - trigger_event('NESTED_EVENT', $param); + Event::createAndTrigger('NESTED_EVENT', $param); } } ); @@ -28,7 +30,7 @@ class events_nested_test extends DokuWikiTest { ); $param = array(); - trigger_event('NESTED_EVENT', $param); + Event::createAndTrigger('NESTED_EVENT', $param); $this->assertEquals(2, $firstcount); $this->assertEquals(2, $secondcount); diff --git a/_test/tests/inc/pageutils_findnearest.test.php b/_test/tests/inc/pageutils_findnearest.test.php index 545e0980b..55db44afa 100644 --- a/_test/tests/inc/pageutils_findnearest.test.php +++ b/_test/tests/inc/pageutils_findnearest.test.php @@ -1,6 +1,6 @@ <?php -use dokuwiki\test\mock\DokuWiki_Auth_Plugin; +use dokuwiki\test\mock\AuthPlugin; class pageutils_findnearest_test extends DokuWikiTest { @@ -15,7 +15,7 @@ class pageutils_findnearest_test extends DokuWikiTest { $conf['useacl'] = 1; $this->oldAuthAcl = $AUTH_ACL; - $auth = new DokuWiki_Auth_Plugin(); + $auth = new AuthPlugin(); $AUTH_ACL = array( '* @ALL 1', diff --git a/_test/tests/inc/remote.test.php b/_test/tests/inc/remote.test.php index acc9e7cc8..6a9686b07 100644 --- a/_test/tests/inc/remote.test.php +++ b/_test/tests/inc/remote.test.php @@ -1,8 +1,10 @@ <?php +use dokuwiki\Extension\AuthPlugin; +use dokuwiki\Extension\RemotePlugin; use dokuwiki\Remote\Api; -class MockAuth extends DokuWiki_Auth_Plugin { +class MockAuth extends AuthPlugin { function isCaseSensitive() { return true; } } @@ -77,7 +79,7 @@ class RemoteAPICoreTest { } -class remote_plugin_testplugin extends DokuWiki_Remote_Plugin { +class remote_plugin_testplugin extends RemotePlugin { function _getMethods() { return array( 'method1' => array( @@ -110,7 +112,7 @@ class remote_plugin_testplugin extends DokuWiki_Remote_Plugin { function publicCall() {return true;} } -class remote_plugin_testplugin2 extends DokuWiki_Remote_Plugin { +class remote_plugin_testplugin2 extends RemotePlugin { /** * This is a dummy method * @@ -146,7 +148,7 @@ class remote_test extends DokuWikiTest { parent::setUp(); // mock plugin controller to return our test plugins - $pluginManager = $this->createMock('Doku_Plugin_Controller'); + $pluginManager = $this->createMock('dokuwiki\Extension\PluginController'); $pluginManager->method('getList')->willReturn(array('testplugin', 'testplugin2')); $pluginManager->method('load')->willReturnCallback( function($type, $plugin) { diff --git a/_test/tests/inc/remoteapicore.test.php b/_test/tests/inc/remoteapicore.test.php index 712f3924b..70b7710e8 100644 --- a/_test/tests/inc/remoteapicore.test.php +++ b/_test/tests/inc/remoteapicore.test.php @@ -2,7 +2,7 @@ use dokuwiki\Remote\Api; use dokuwiki\Remote\ApiCore; -use dokuwiki\test\mock\DokuWiki_Auth_Plugin; +use dokuwiki\test\mock\AuthPlugin; /** * Class remoteapicore_test @@ -25,7 +25,7 @@ class remoteapicore_test extends DokuWikiTest { global $auth; $this->oldAuthAcl = $AUTH_ACL; $this->userinfo = $USERINFO; - $auth = new DokuWiki_Auth_Plugin(); + $auth = new AuthPlugin(); $conf['remote'] = 1; $conf['remoteuser'] = '@user'; @@ -393,7 +393,7 @@ You can use up to five different levels of', } public function test_getPageVersions() { - /** @var $EVENT_HANDLER Doku_Event_Handler */ + /** @var $EVENT_HANDLER \dokuwiki\Extension\EventHandler */ global $EVENT_HANDLER; $EVENT_HANDLER->register_hook('IO_WIKIPAGE_WRITE', 'BEFORE', $this, 'handle_write'); global $conf; |