public function testRoutesAreLoadedInCorrectly() { $app = App::getInstance($this->config); $app->loadControllers()->configureServices()->configureRoutes(); // Now see if the routes are loaded $fakeReq = Request::create('/'); $r1 = $app->handle($fakeReq); $this->assertEquals('hello', $r1->getContent()); }
public static function app() { return App::getInstance(); }
public function testSharedServiceWithArgLoadedCorrectly() { \Flint\App::getInstance(['options' => ['debug' => true], 'core' => ['configDir' => __DIR__ . '/../data']]); $serviceConfig = ['Fake' => ['class' => 'SharedServiceWithArgs', 'arguments' => ['Josh'], 'share' => true]]; // Stub out the loadServices method so we isolate the parsing $stub = $this->getMockBuilder('Flint\\ServiceParser')->setConstructorArgs(['fakefile.php'])->setMethods(['loadServices'])->getMock(); $stub->expects($this->any())->method('loadServices')->will($this->returnValue($stub)); SingletonMock::inject($stub, 'Flint\\ServiceParser'); $stub->loadServices()->setServices($serviceConfig); $result = $stub->parse(); $this->assertArrayHasKey('Fake', $result); $time = $result['Fake']->getTime(); $this->assertEquals('Josh', $result['Fake']->getName()); $this->assertEquals($time, $result['Fake']->getTime()); SingletonMock::cleanUp('Flint\\ServiceParser'); }
public function tearDown() { App::destroyInstance(); }
private function registerRoute($route, $http, $method, $name = null, $converter = null, $assert = null) { $app = App::getInstance(); switch (strtolower($http)) { case 'get': $r = $app->get($route, $method); break; case 'post': $r = $app->post($route, $method); break; case 'put': $r = $app->put($route, $method); break; case 'delete': $r = $app->delete($route, $method); break; default: throw new InvalidRouteException('Incorrect HTTP method for route `' . $route . '`: ' . $http); break; } if ($name !== null) { $r->bind($name); } if ($converter !== null) { $r->convert($converter[0], $converter[1]); } if ($assert !== null && is_array($assert)) { if (isAssociative($assert)) { foreach ($assert as $param => $regex) { $r->assert($param, $regex); } } elseif (count($assert) === 2) { $r->assert($assert[0], $assert[1]); } } }
private function parseArgument($value) { if (is_string($value)) { if (strpos($value, '@') === 0) { $app = \Flint\App::getInstance(); $value = $app[substr($value, 1)]; } } return $value; }