diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2019-11-27 15:27:18 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2019-11-27 15:27:18 +0100 |
commit | 3a7cf40aaa678bea1df143d2982d603b7a334eec (patch) | |
tree | 63c1e3ad7f7f401d14411a4d44c523632906afc9 /tests/lib/Hooks/BasicEmitterTest.php | |
parent | 0568b012672d650c6b5a49e72c4028dde5463c60 (diff) | |
download | nextcloud-server-3a7cf40aaa678bea1df143d2982d603b7a334eec.tar.gz nextcloud-server-3a7cf40aaa678bea1df143d2982d603b7a334eec.zip |
Mode to modern phpunit
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'tests/lib/Hooks/BasicEmitterTest.php')
-rw-r--r-- | tests/lib/Hooks/BasicEmitterTest.php | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/tests/lib/Hooks/BasicEmitterTest.php b/tests/lib/Hooks/BasicEmitterTest.php index 948659faaba..1f88dee1032 100644 --- a/tests/lib/Hooks/BasicEmitterTest.php +++ b/tests/lib/Hooks/BasicEmitterTest.php @@ -50,28 +50,28 @@ class BasicEmitterTest extends \Test\TestCase { throw new EmittedException; } - /** - * @expectedException \Test\Hooks\EmittedException - */ + public function testAnonymousFunction() { + $this->expectException(\Test\Hooks\EmittedException::class); + $this->emitter->listen('Test', 'test', function () { throw new EmittedException; }); $this->emitter->emitEvent('Test', 'test'); } - /** - * @expectedException \Test\Hooks\EmittedException - */ + public function testStaticCallback() { + $this->expectException(\Test\Hooks\EmittedException::class); + $this->emitter->listen('Test', 'test', array('\Test\Hooks\BasicEmitterTest', 'staticCallBack')); $this->emitter->emitEvent('Test', 'test'); } - /** - * @expectedException \Test\Hooks\EmittedException - */ + public function testNonStaticCallback() { + $this->expectException(\Test\Hooks\EmittedException::class); + $this->emitter->listen('Test', 'test', array($this, 'nonStaticCallBack')); $this->emitter->emitEvent('Test', 'test'); } @@ -125,10 +125,10 @@ class BasicEmitterTest extends \Test\TestCase { $this->assertEquals(2, $count, 'Listener called an invalid number of times (' . $count . ') expected 2'); } - /** - * @expectedException \Test\Hooks\EmittedException - */ + public function testArguments() { + $this->expectException(\Test\Hooks\EmittedException::class); + $this->emitter->listen('Test', 'test', function ($foo, $bar) { if ($foo == 'foo' and $bar == 'bar') { throw new EmittedException; @@ -137,10 +137,10 @@ class BasicEmitterTest extends \Test\TestCase { $this->emitter->emitEvent('Test', 'test', array('foo', 'bar')); } - /** - * @expectedException \Test\Hooks\EmittedException - */ + public function testNamedArguments() { + $this->expectException(\Test\Hooks\EmittedException::class); + $this->emitter->listen('Test', 'test', function ($foo, $bar) { if ($foo == 'foo' and $bar == 'bar') { throw new EmittedException; @@ -216,10 +216,10 @@ class BasicEmitterTest extends \Test\TestCase { $this->addToAssertionCount(1); } - /** - * @expectedException \Test\Hooks\EmittedException - */ + public function testRemoveKeepOtherCallback() { + $this->expectException(\Test\Hooks\EmittedException::class); + $listener1 = function () { throw new EmittedException; }; @@ -234,10 +234,10 @@ class BasicEmitterTest extends \Test\TestCase { $this->addToAssertionCount(1); } - /** - * @expectedException \Test\Hooks\EmittedException - */ + public function testRemoveKeepOtherMethod() { + $this->expectException(\Test\Hooks\EmittedException::class); + $listener = function () { throw new EmittedException; }; @@ -249,10 +249,10 @@ class BasicEmitterTest extends \Test\TestCase { $this->addToAssertionCount(1); } - /** - * @expectedException \Test\Hooks\EmittedException - */ + public function testRemoveKeepOtherScope() { + $this->expectException(\Test\Hooks\EmittedException::class); + $listener = function () { throw new EmittedException; }; @@ -264,10 +264,10 @@ class BasicEmitterTest extends \Test\TestCase { $this->addToAssertionCount(1); } - /** - * @expectedException \Test\Hooks\EmittedException - */ + public function testRemoveNonExistingName() { + $this->expectException(\Test\Hooks\EmittedException::class); + $listener = function () { throw new EmittedException; }; |