public function testItCanBeRegisteredAndBooted() { $restProvider = new RestProvider(); $app = new Application(); $defaultServices = $app->keys(); $app->register($restProvider); $app->boot(); $definedByProvider = array_values(array_diff($app->keys(), $defaultServices)); $expectedServices = ['alchemy_rest.debug', 'alchemy_rest.fractal_manager', 'alchemy_rest.transformers_registry', 'alchemy_rest.array_transformer', 'alchemy_rest.exception_transformer', 'alchemy_rest.exception_listener', 'alchemy_rest.date_parser.timezone', 'alchemy_rest.date_parser.format', 'alchemy_rest.date_parser', 'alchemy_rest.date_request_listener', 'alchemy_rest.paginate_options.offset_parameter', 'alchemy_rest.paginate_options.limit_parameter', 'alchemy_rest.paginate_options_factory', 'alchemy_rest.paginate_request_listener', 'alchemy_rest.sort_options.sort_parameter', 'alchemy_rest.sort_options.direction_parameter', 'alchemy_rest.sort_options.multi_sort_parameter', 'alchemy_rest.sort_options_factory', 'alchemy_rest.sort_request_listener', 'alchemy_rest.transform_response_listener']; $undefinedServices = array_diff($expectedServices, $definedByProvider); $this->assertEquals([], $undefinedServices); }
/** * Returns routes to connect to the given application. * * @param Application $app An Application instance * * @return ControllerCollection A ControllerCollection instance */ public function connect(Application $app) { /** @var ControllerCollection $controllers */ $controllers = $app['controllers_factory']; $controllers->get('/', function () use($app) { $keys = $app->keys(); sort($keys); $doc = array(); foreach ($keys as $key) { try { $val = $app[$key]; if (is_scalar($val)) { $doc[$key] = array('Scalar', var_export($val, true)); } elseif (is_array($val)) { $doc[$key] = array('Array', count($val)); } elseif (is_object($val)) { $doc[$key] = array('Object', get_class($val)); } else { } } catch (\Exception $e) { $doc[$key] = array('Exception', $e->getMessage()); } } ob_start(); require __DIR__ . "/../../../templates/containerdoc.html"; return ob_get_clean(); }); return $controllers; }
/** * @param Application $app * * @throws \RuntimeException * * @return void */ protected function assertRequiredKeysExist(Application $app) { $required = ['path.base']; $missingKeys = array_diff($required, $app->keys()); if (false === empty($missingKeys)) { $message = 'Missing required config parameters (' . implode(', ', $missingKeys) . ')'; throw new \RuntimeException($message); } }
public function canResolve($name) { return in_array($name, $this->app->keys()); }