summaryrefslogtreecommitdiff
path: root/tests/units/Core/Plugin/HookTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/units/Core/Plugin/HookTest.php')
-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);
+ }
}