function testBeforeAndAfter() { $this->dispatcher->set('hello', function ($name) { return "Hello, {$name}!"; }); $this->dispatcher->hook('hello', 'before', function (&$params, &$output) { // Manipulate the parameter $params[0] = 'Fred'; }); $this->dispatcher->hook('hello', 'after', function (&$params, &$output) { // Manipulate the output $output .= " Have a nice day!"; }); $result = $this->dispatcher->run('hello', array('Bob')); $this->assertEquals('Hello, Fred! Have a nice day!', $result); }