assertEquals($res, $hook->call($page, $args)); } public static function dispatchProvider() { return array( array('blih-', 'test', 'test'), array('blih-', 'test', 'test/'), array('blih-machin', 'test', 'test/machin'), array('blih-machin-truc', 'test', 'test/machin/truc'), array('blih-hiboo', 'test', 'test/hiboo'), array('foo', 'test/coucou', 'test/coucou'), array('foo-', 'test/coucou', 'test/coucou/'), array('foo-blah', 'test/coucou', 'test/coucou/blah'), array('foo-blah', 'test/coucou', 'test/coucou/blah/truc') ); } /** * @dataProvider dispatchProvider */ public function testDispatch($res, $expmatched, $path) { $tree = new PlHookTree(); $tree->addChildren(array( 'test' => new PlStdHook(array('EngineTest', 'blihCallback')), 'test1' => new PlStdHook(array('EngineTest', 'blahCallback')), 'tes' => new PlStdHook(array('EngineTest', 'blahCallback')), 'test/coucou' => new PlStdHook(array('EngineTest', 'fooCallback')), 'test/hook' => new PlStdHook(array('EngineTest', 'barCallback')) )); $page = new TestPage(); $p = explode('/', $path); list($hook, $matched, $remain, $aliased) = $tree->findChild($p); $matched = join('/', $matched); $this->assertEquals($expmatched, $matched); array_unshift($remain, $matched); $this->assertEquals($res, $hook->call($page, $remain)); } } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8: ?>