diff options
author | Morris Jobke <hey@morrisjobke.de> | 2020-10-28 22:23:39 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2020-10-28 22:23:39 +0100 |
commit | 6e35457fcc0f98af43c2ece19f00060e966348dc (patch) | |
tree | 4c0ac536a850286f193ea72ff2cbf183b9a26e0e /tests | |
parent | ef382f541c42f719b8dd30a4e0e248ef1bc39c84 (diff) | |
download | nextcloud-server-6e35457fcc0f98af43c2ece19f00060e966348dc.tar.gz nextcloud-server-6e35457fcc0f98af43c2ece19f00060e966348dc.zip |
Remove unused private ForwardEmitter and LegacyEmitter
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Hooks/ForwardingEmitterTest.php | 75 | ||||
-rw-r--r-- | tests/lib/Hooks/LegacyEmitterTest.php | 58 |
2 files changed, 0 insertions, 133 deletions
diff --git a/tests/lib/Hooks/ForwardingEmitterTest.php b/tests/lib/Hooks/ForwardingEmitterTest.php deleted file mode 100644 index 0c073b95573..00000000000 --- a/tests/lib/Hooks/ForwardingEmitterTest.php +++ /dev/null @@ -1,75 +0,0 @@ -<?php -/** - * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -namespace Test\Hooks; - -use OC\Hooks\PublicEmitter; - -class DummyForwardingEmitter extends \OC\Hooks\ForwardingEmitter { - public function emitEvent($scope, $method, $arguments = []) { - $this->emit($scope, $method, $arguments); - } - - /** - * @param \OC\Hooks\Emitter $emitter - */ - public function forward(\OC\Hooks\Emitter $emitter) { - parent::forward($emitter); - } -} - -/** - * Class ForwardingEmitter - * - * allows forwarding all listen calls to other emitters - * - * @package OC\Hooks - */ -class ForwardingEmitterTest extends BasicEmitterTest { - public function testSingleForward() { - $baseEmitter = new PublicEmitter(); - $forwardingEmitter = new DummyForwardingEmitter(); - $forwardingEmitter->forward($baseEmitter); - $hookCalled = false; - $forwardingEmitter->listen('Test', 'test', function () use (&$hookCalled) { - $hookCalled = true; - }); - $baseEmitter->emit('Test', 'test'); - $this->assertTrue($hookCalled); - } - - public function testMultipleForwards() { - $baseEmitter1 = new PublicEmitter(); - $baseEmitter2 = new PublicEmitter(); - $forwardingEmitter = new DummyForwardingEmitter(); - $forwardingEmitter->forward($baseEmitter1); - $forwardingEmitter->forward($baseEmitter2); - $hookCalled = 0; - $forwardingEmitter->listen('Test', 'test1', function () use (&$hookCalled) { - $hookCalled++; - }); - $forwardingEmitter->listen('Test', 'test2', function () use (&$hookCalled) { - $hookCalled++; - }); - $baseEmitter1->emit('Test', 'test1'); - $baseEmitter1->emit('Test', 'test2'); - $this->assertEquals(2, $hookCalled); - } - - public function testForwardExistingHooks() { - $baseEmitter = new PublicEmitter(); - $forwardingEmitter = new DummyForwardingEmitter(); - $hookCalled = false; - $forwardingEmitter->listen('Test', 'test', function () use (&$hookCalled) { - $hookCalled = true; - }); - $forwardingEmitter->forward($baseEmitter); - $baseEmitter->emit('Test', 'test'); - $this->assertTrue($hookCalled); - } -} diff --git a/tests/lib/Hooks/LegacyEmitterTest.php b/tests/lib/Hooks/LegacyEmitterTest.php deleted file mode 100644 index e6b751c1f74..00000000000 --- a/tests/lib/Hooks/LegacyEmitterTest.php +++ /dev/null @@ -1,58 +0,0 @@ -<?php -/** - * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -namespace Test\Hooks; - -/** - * Class DummyLegacyEmitter - * - * class to make LegacyEmitter::emit publicly available - * - * @package Test\Hooks - */ -class DummyLegacyEmitter extends \OC\Hooks\LegacyEmitter { - public function emitEvent($scope, $method, $arguments = []) { - $this->emit($scope, $method, $arguments); - } -} - -class LegacyEmitterTest extends BasicEmitterTest { - - //we can't use exceptions here since OC_Hooks catches all exceptions - private static $emitted = false; - - protected function setUp(): void { - parent::setUp(); - - $this->emitter = new DummyLegacyEmitter(); - self::$emitted = false; - \OC_Hook::clear('Test','test'); - } - - public static function staticLegacyCallBack() { - self::$emitted = true; - } - - public static function staticLegacyArgumentsCallBack($arguments) { - if ($arguments['foo'] == 'foo' and $arguments['bar'] == 'bar') { - self::$emitted = true; - } - } - - public function testLegacyHook() { - \OC_Hook::connect('Test', 'test', '\Test\Hooks\LegacyEmitterTest', 'staticLegacyCallBack'); - $this->emitter->emitEvent('Test', 'test'); - $this->assertEquals(true, self::$emitted); - } - - public function testLegacyArguments() { - \OC_Hook::connect('Test', 'test', '\Test\Hooks\LegacyEmitterTest', 'staticLegacyArgumentsCallBack'); - $this->emitter->emitEvent('Test', 'test', ['foo' => 'foo', 'bar' => 'bar']); - $this->assertEquals(true, self::$emitted); - } -} |