app = new class extends ApplicationAbstract {}; $this->app->router = new Router(); $this->app->dispatcher = new Dispatcher($this->app); } public function testAttributes() { self::assertObjectHasAttribute('controllers', $this->app->dispatcher); } public function testClosure() { $l11nManager = new L11nManager(); $localization = new Localization($l11nManager); self::assertTrue( !empty( $this->app->dispatcher->dispatch( function($req, $resp, $data = null) { return true; }, new Request(new Http(''), $localization), new Response($localization) ) ) ); } public function testPathMethod() { $l11nManager = new L11nManager(); $localization = new Localization($l11nManager); self::assertTrue( !empty( $this->app->dispatcher->dispatch( 'phpOMS\tests\Dispatcher\TestController:testFunction', new Request(new Http(''), $localization), new Response($localization) ) ) ); } public function testPathStatic() { $l11nManager = new L11nManager(); $localization = new Localization($l11nManager); self::assertTrue( !empty( $this->app->dispatcher->dispatch( 'phpOMS\tests\Dispatcher\TestController::testFunctionStatic', new Request(new Http(''), $localization), new Response($localization) ) ) ); } public function testArray() { $l11nManager = new L11nManager(); $localization = new Localization($l11nManager); self::assertTrue( !empty( $this->app->dispatcher->dispatch( [ function($req, $resp, $data = null) { return true; }, 'phpOMS\tests\Dispatcher\TestController:testFunction', 'phpOMS\tests\Dispatcher\TestController::testFunctionStatic', ], new Request(new Http(''), $localization), new Response($localization) ) ) ); } /** * @expectedException \UnexpectedValueException */ public function testInvalidDestination() { $this->app->dispatcher->dispatch(true); } /** * @expectedException \phpOMS\System\File\PathException */ public function testInvalidControllerPath() { $this->app->dispatcher->dispatch('phpOMS\tests\Dispatcher\TestControllers::testFunctionStatic'); } /** * @expectedException \UnexpectedValueException */ public function testInvalidControllerString() { $this->app->dispatcher->dispatch('phpOMS\tests\Dispatcher\TestController::testFunctionStatic:failure'); } }