From e6f547abcfe684658a7498391db72d13b6aa7d9a Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 20 Sep 2015 18:24:15 -0400 Subject: Move timetable to a plugin Plugin repository: https://github.com/kanboard/plugin-timetable --- tests/units/Core/Plugin/HookTest.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'tests/units/Core') diff --git a/tests/units/Core/Plugin/HookTest.php b/tests/units/Core/Plugin/HookTest.php index 95434ce4..f8646cbf 100644 --- a/tests/units/Core/Plugin/HookTest.php +++ b/tests/units/Core/Plugin/HookTest.php @@ -17,6 +17,16 @@ class HookTest extends Base $this->assertEquals(array('A', 'B'), $h->getListeners('myhook')); } + public function testExists() + { + $h = new Hook; + $this->assertFalse($h->exists('myhook')); + + $h->on('myhook', 'A'); + + $this->assertTrue($h->exists('myhook')); + } + public function testMergeWithNoBinding() { $h = new Hook; @@ -59,4 +69,28 @@ class HookTest extends Base $this->assertEquals($expected, $result); $this->assertEquals($expected, $values); } + + public function testFirstWithNoBinding() + { + $h = new Hook; + + $result = $h->first('myhook', array('p' => 2)); + $this->assertEquals(null, $result); + } + + public function testFirstWithMultipleBindings() + { + $h = new Hook; + + $h->on('myhook', function($p) { + return $p + 1; + }); + + $h->on('myhook', function($p) { + return $p; + }); + + $result = $h->first('myhook', array('p' => 3)); + $this->assertEquals(4, $result); + } } -- cgit v1.2.3