public function testTestInvalidConfigThrowsException() { try { $config = new FromArray($this->invalidConfigPath); $this->assertEquals(2, count($config->getArrayWhereKeysBeginWith('person.'))); } catch (\Exception $e) { $this->assertContains('Config not found', $e->getMessage()); return; } $this->fail('Expected invalid config.'); }
/** * Load and assign the route files from the packages and * the main /res/routes.php file */ private function loadRoutes() { $cacheName = $this->mode . '_Phavour_Application_routes'; if (false != ($routes = $this->cache->get($cacheName))) { // @codeCoverageIgnoreStart $this->routes = $routes; return; // @codeCoverageIgnoreEnd } $routes = array(); foreach ($this->packagesMetadata as $package) { try { $finder = new FromArray($package['route_path']); $proposedRoutes = $finder->getArray(); if (is_array($proposedRoutes)) { foreach ($proposedRoutes as $key => $routeDetails) { if (!array_key_exists('package', $routeDetails)) { $proposedRoutes[$key]['package'] = $package['package_name']; } $proposedRoutes[$key]['package'] = $package['package_name']; } $routes = array_merge($routes, $proposedRoutes); } } catch (\Exception $e) { // Package doesn't have routes } } try { $finder = new FromArray($this->appDirectory . DIRECTORY_SEPARATOR . 'res' . DIRECTORY_SEPARATOR . 'routes.php'); $appRoutes = $finder->getArray(); if (is_array($appRoutes)) { foreach ($appRoutes as $routeDetails) { // @codeCoverageIgnoreStart if (!array_key_exists('package', $routeDetails)) { throw new RouteMissingPackageNameException(); } // @codeCoverageIgnoreEnd } $routes = array_merge($routes, $appRoutes); } } catch (\Exception $e) { // No route overrides set } $this->routes = $routes; $this->cache->set($cacheName, $this->routes, 86400); }