/** * @expectedException RuntimeException * @expectedExceptionMessageRegExp /Server/i */ public function testListenInvalidResponse() { $dispatcher = new SimpleDispatcher(); $dispatcher->mount('test', function () { }); $server = new Server(); $server->setDispatcher($dispatcher); $server->listen(); }
/** * @dataProvider flowProvider */ public function testDispatchFlow($flow, $return, $expected) { $dispatcher = new SimpleDispatcher(); $dispatcher->mount('foo', function () { $this->flow(); }); $dispatcher->mount('bar', function () use($flow, $return) { $flow and $this->flow(); return $return ? 'bar' : null; }); $dispatcher->mount('xyz', function () { return 1.33; }); $result = $dispatcher->dispatch(new Request()); $this->assertEquals($expected, $result); }