summaryrefslogtreecommitdiff
path: root/tests/units/Core
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-09-20 18:24:15 -0400
committerFrederic Guillot <fred@kanboard.net>2015-09-20 18:24:15 -0400
commite6f547abcfe684658a7498391db72d13b6aa7d9a (patch)
tree75b709c12fb03e11d7cb85558558f89f19abb284 /tests/units/Core
parent2021dccc5a444f60c5ba1673d94b39999912cd26 (diff)
Move timetable to a plugin
Plugin repository: https://github.com/kanboard/plugin-timetable
Diffstat (limited to 'tests/units/Core')
-rw-r--r--tests/units/Core/Plugin/HookTest.php34
1 files changed, 34 insertions, 0 deletions
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);
+ }
}