public function testBootWithTwig() { $this->app->register($this->provider); $this->app->register(new TwigServiceProvider()); $this->app->boot(); $this->assertInstanceOf('CalendR\\Extension\\Twig\\CalendRExtension', $this->app['twig']->getExtension('calendr')); }
public function testWithLoader() { $this->app['env.loader'] = $this->app->protect(function () { return $_SERVER; }); $this->app->register(new EnvironmentProvider()); $this->app->boot(); $this->assertEquals($_SERVER, $this->app['env']->getVars()); }
/** * @return Application */ public function boot() { if ($this->parameters->isAppClassFilled()) { $class = $this->parameters->getAppClass(); $this->application = new $class(['debug' => $this->parameters->isDebugEnabled(), 'env' => $this->parameters->getEnv()]); $this->application->boot(); return $this->application; } $this->application = (require $this->parameters->getApp()); $this->application['debug'] = $this->parameters->isDebugEnabled(); $this->application['env'] = $this->parameters->getEnv(); $this->application['session.test'] = $this->parameters->isTestSessionEnabled(); $this->application->boot(); return $this->application; }
/** * Ensures the service provider registers the correct services. */ public function testRegisteredServices() { $firewall = 'http-auth'; $authenticationListenerServices = ['security.authentication_provider.' . $firewall . '.hmac', 'security.authentication_listener.' . $firewall . '.hmac', 'security.entry_point.' . $firewall . '.hmac', 'pre_auth']; $keyLoader = $this->getMock(KeyLoaderInterface::class); $app = new Application(); $app->register(new SecurityServiceProvider()); $app->register(new HmacSecurityProvider($keyLoader)); $app['security.firewalls'] = [$firewall => ['pattern' => '^.*$', 'hmac' => true]]; $app->boot(); $this->assertArrayHasKey('security.authentication_listener.factory.hmac', $app); $this->assertArrayHasKey('security.hmac.response_listener', $app); $this->assertArrayHasKey('security.authentication_provider.hmac._proto', $app); $this->assertArrayHasKey('security.authentication_listener.hmac._proto', $app); $this->assertArrayHasKey('security.entry_point.hmac._proto', $app); $this->assertInstanceOf(HmacResponseListener::class, $app['security.hmac.response_listener']); $factoryResponse = $app['security.authentication_listener.factory.hmac']($firewall, []); $this->assertEquals($authenticationListenerServices, $factoryResponse); $this->assertArrayHasKey('security.authentication_provider.' . $firewall . '.hmac', $app); $this->assertInstanceOf(HmacAuthenticationProvider::class, $app['security.authentication_provider.' . $firewall . '.hmac']); $this->assertArrayHasKey('security.authentication_listener.' . $firewall . '.hmac', $app); $this->assertInstanceOf(HmacAuthenticationListener::class, $app['security.authentication_listener.' . $firewall . '.hmac']); $this->assertArrayHasKey('security.entry_point.' . $firewall . '.hmac', $app); $this->assertInstanceOf(HmacAuthenticationEntryPoint::class, $app['security.entry_point.' . $firewall . '.hmac']); }
/** * @covers Fudge\SilexComponents\DependencyInjection\DependencyInjectionServiceProvider::register * @covers Fudge\SilexComponents\DependencyInjection\DependencyInjectionServiceProvider::boot */ public function testSettingOfDependencyInjectionControllerResolver() { $app = new Application(); $app->register(new DependencyInjectionServiceProvider()); $app->boot(); $this->assertInstanceOf(__NAMESPACE__ . "\\ControllerResolver", $app['resolver']); }
public function testGaufretteCache() { $app = new Application(); $app->register(new GaufretteServiceProvider(), array('gaufrette.adapter.class' => 'InMemory', 'gaufrette.adapter.cache.class' => 'Local', 'gaufrette.cache.options' => array(__DIR__ . '/cache'))); $app->boot(); $this->assertInstanceOf('\\Gaufrette\\Adapter\\Cache', $app['gaufrette.cache']); }
/** * Returns an initialized Silex application with a registered instance * of PBKDF2ServiceProvider. * * @param Array $providerConfiguration Parameters for the provider configuration. * @return Application */ protected function getApplication(array $providerConfiguration = array()) { $app = new Application(); $app->register(new PBKDF2(), $providerConfiguration); $app->boot(); return $app; }
public function testItAddsRequestTrustedProxiesSubscriberOnBoot() { $app = new Application(); $app['root.path'] = __DIR__ . '/../../../../../..'; $app->register(new ConfigurationServiceProvider()); $app['phraseanet.configuration.config-path'] = __DIR__ . '/fixtures/config-proxies.yml'; $app['phraseanet.configuration.config-compiled-path'] = __DIR__ . '/fixtures/config-proxies.php'; $app->boot(); /** @var EventDispatcherInterface $dispatcher */ $dispatcher = $app['dispatcher']; $listener = null; $method = null; foreach ($dispatcher->getListeners(KernelEvents::REQUEST) as $callable) { // Only look for TrustedProxySubscriber instances if (!is_array($callable)) { continue; } list($listener, $method) = $callable; if ($listener instanceof TrustedProxySubscriber) { break; } } $this->assertInstanceOf('Alchemy\\Phrasea\\Core\\Event\\Subscriber\\TrustedProxySubscriber', $listener, 'TrustedProxySubscriber was not properly registered'); $this->assertEquals('setProxyConf', $method); $this->assertSame([], Request::getTrustedProxies()); $listener->setProxyConf(); $this->assertSame(['127.0.0.1', '66.6.66.6'], Request::getTrustedProxies()); unlink($app['phraseanet.configuration.config-compiled-path']); }
public function __construct(SilexApplication $application, $projectDirectory, $name = 'UNKNOWN', $version = 'UNKNOWN') { parent::__construct($name, $version); $this->silexApplication = $application; $this->projectDirectory = $projectDirectory; $application->boot(); }
/** * @expectedException \InvalidArgumentException */ public function testRegisterServiceProvidersWithRegisterWithValidValueAndParametersWithTypeError() { $app = new Application(); $app['cekurte.manager.providers'] = ['Silex\\Provider\\HttpFragmentServiceProvider' => ['register' => true, 'type' => 'invalid-value']]; $app->register(new ManagerServiceProvider()); $app->boot(); }
public function boot() { $booted = $this->booted; if (!$booted) { foreach ($this->providers as $provider) { // handle pack's options $this->registerOptionnablePack($provider); // handle pack's commands // must be done before the orm provider register() $this->registerConsolablePack($provider); // handle pack's assets for assetic $this->registerAssetablePack($provider); } // find pack's translations $this->registerTranslatablePacks(); // handle pack's entities // must be done before the console boot() $this->registerEntitablePacks(); } parent::boot(); if (!$booted) { foreach ($this->providers as $provider) { // handle twig pack $this->registerTwiggablePack($provider); // add namespace to assetic $this->postBootRegisterAssetablePack($provider); // connect pack $this->registerMountablePack($provider); } // handle twig template override $this->addPackOverridingTemplatePathToTwig(); } }
public function createApplication() { $app = new Application(['env' => 'test']); require __DIR__ . '/../app/AppKernel.php'; $app->boot(); return $app; }
/** * Load configuration and boot the applications * * {@inheritdoc} */ public function boot() { $this->initializeConfig(); foreach ($this->apps as $app) { $app->boot($this); } parent::boot(); }
public function testCoverBoot() { $app = new Application(); $app['monolog.logfile'] = false; $app->register(new MonologServiceProvider()); $app->register(new ExtendedLoggerServiceProvider()); $app->boot(); }
public function testConfiguredApplicationWithTwigExtensionDisabled() { $app = new Application(); $app->register(new TwigServiceProvider()); $app->register(new PuliServiceProvider(), array('puli.enable_twig' => false)); $app->boot(); $this->assertFalse($app['twig']->hasExtension('puli')); $this->assertNotInstanceOf('Puli\\TwigExtension\\PuliTemplateLoader', $app['twig.loader']); }
/** * Boots all service providers and initializes Polymorph. */ public function boot() { if (!$this->booted) { parent::boot(); $this->initCustomServiceProviders(); $this->initBase(); $this->initRoutes(); } }
/** * @test * * @covers Pipedrive\Api\Provider::register */ public function shouldRegisterApiClient() { $this->serviceProvider->method('register')->willReturnCallback(function (Application $app) { $app['api.pipedrive.client'] = $this->getMock(Client::class, [], [], '', false); }); $app = new Application(); $app->register($this->serviceProvider); $app->boot(); $this->assertInstanceOf(Client::class, $app['api.pipedrive.client']); }
public function testContainerItemsNotNull() { $app = new Application(); $app->register(new TwilioServiceProvider(), array('twilio.sid' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'twilio.auth_token' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')); $app->boot(); $this->assertNotNull($app['twilio.twiml']); $this->assertInstanceOf('\\Services_Twilio_Twiml', $app['twilio.twiml']); $this->assertNotNull($app['twilio.api']); $this->assertInstanceOf('\\Services_Twilio', $app['twilio.api']); }
/** * Test if function defined by the provider */ public function testCheckFunction() { $authorizer = $this->getAuthorizerMock(); $controller = $this->getControllerMock(); $app = new Application(); $app->register(new ModuleAuthorizationServiceProvider(), array(ModuleAuthorizationServiceProvider::AUTHORIZER_KEY => $authorizer, ModuleAuthorizationServiceProvider::CONTROLLER_KEY => $controller)); $app->boot(); $fn = $app[ModuleAuthorizationServiceProvider::CHECK_FN_KEY]('Module', 'ActionId'); $result = $fn(null); $this->assertTrue($result); }
public function testRegister() { $app = new Application(); $app->register(new DoctrineServiceProvider()); $app->register(new MigrationsServiceProvider(), array('migration.table' => 'version', 'migration.namespace' => 'Acme\\Migration', 'migration.directory' => 'src/Acme/Migration')); $app->boot(); $this->assertInstanceOf('Doctrine\\DBAL\\Migrations\\Migration', $app['migration']); $this->assertEquals('version', $app['migration.table']); $this->assertEquals('Acme\\Migration', $app['migration.namespace']); $this->assertEquals('src/Acme/Migration', $app['migration.directory']); }
/** * @test * @covers Cocur\Slugify\Bridge\Silex\SlugifyServiceProvider */ public function register() { // it seems like Application is not mockable. $app = new Application(); $app->register(new SlugifyServiceProvider()); $app->boot(); $this->assertArrayHasKey('slugify', $app); $this->assertArrayHasKey('slugify.regex', $app); $this->assertArrayHasKey('slugify.options', $app); $this->assertInstanceOf('Cocur\\Slugify\\Slugify', $app['slugify']); }
public function testServiceManuallyRegistered() { $app = new Application(); $app->register(new AutoServiceProvider(), array('rad.service.directories' => array(__DIR__ . '/../../ManualService' => array('namespace' => 'SilexRad\\Tests\\ManualService')))); $app['ManuallyRegisteredService'] = $app->share(function () { return new \SilexRad\Tests\ManualService\ManuallyRegisteredService('first'); }); $app->boot(); $this->assertInstanceOf('SilexRad\\Tests\\ManualService\\ManuallyRegisteredService', $app['ManuallyRegisteredService']); $this->assertEquals(array('first'), $app['ManuallyRegisteredService']->getConstructorArguments(), 'Service planned for manual registration got wrong constructor parameter'); $this->assertInstanceOf('SilexRad\\Tests\\ManualService\\AutoRegisteredService', $app['AutoRegisteredService']); }
/** * @param Application $application * @return self */ public function __construct(Application $application) { $name = $application['console.name']; $version = $application['console.version']; parent::__construct($name, $version); $this->application = $application; $this->rootDirectory = $application['console.root_directory']; $application->boot(); foreach ($application['console.commands'] as $command) { $this->add(new $command()); } }
public function testRegisterRoutesNull() { file_put_contents('routes.json', json_encode(array('test' => array('pattern' => '/test/{id}', 'defaults' => array('_controller' => 'Herrera\\Wise\\Test\\Controller::action'))))); file_put_contents('routes_test.json', json_encode(array('imports' => array(array('resource' => 'routes.json')), 'test' => null))); $this->app['wise.options']['mode'] = 'test'; WiseServiceProvider::registerRoutes($this->app); $this->app->boot(); $request = Request::create('/test/123'); /** @var Response $response */ $response = $this->app->handle($request); $this->assertRegExp('/could not be found/', $response->getContent()); }
/** * Runs the current application. * * @param InputInterface $input An Input instance * @param OutputInterface $output An Output instance * * @return int 0 if everything went fine, or an error code */ public function doRun(InputInterface $input, OutputInterface $output) { $this->app->boot(); if (!$this->commandsRegistered) { $this->registerCommands(); $this->commandsRegistered = true; } foreach ($this->all() as $command) { if ($command instanceof PimpleAwareInterface) { $command->setContainer($this->app); } } $this->setDispatcher($this->app['dispatcher']); if (true === $input->hasParameterOption(array('--shell', '-s'))) { $shell = new Shell($this); $shell->setProcessIsolation($input->hasParameterOption(array('--process-isolation'))); $shell->run(); return 0; } return parent::doRun($input, $output); }
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); }
public function testRegister() { $app = new Application(); $app['root_dir'] = __DIR__ . '/../../../../..'; $app['cache_dir'] = __DIR__ . '/tmp'; $app['debug'] = true; $app->register(new FakeryGeneratorProvider()); $app->boot(); $this->assertInstanceOf('\\CSanquer\\FakeryGenerator\\Config\\FakerConfig', $app['fakery.faker.config']); $this->assertInstanceOf('\\CSanquer\\FakeryGenerator\\Config\\ConfigSerializer', $app['fakery.config_serializer']); $this->assertInstanceOf('\\CSanquer\\FakeryGenerator\\Dump\\DumpManager', $app['fakery.dumper_manager']); $this->assertInstanceOf('\\CSanquer\\FakeryGenerator\\Dump\\ConsoleDumpManager', $app['fakery.console_dumper_manager']); }
/** * @test */ public function isApiRouteRegistered() { $app = new Application(); $path = '/docs/swagger.json'; $app->register(new SwaggerProvider(), [self::SWAGGER_API_DOC_PATH => $path]); $app->boot(); /** @var ControllerCollection $controllers */ $controllers = $app['controllers']; $routes = $controllers->flush()->all(); self::assertArrayHasKey('GET_docs_swagger.json', $routes); $route = $routes['GET_docs_swagger.json']; self::assertEquals($path, $route->getPath()); }
public function testBoot() { $app = new Application(); $transDirectory = realpath(__DIR__ . '/../Resources/i18n/'); $provider = $this->getMockBuilder('\\Cekurte\\Silex\\Translation\\Provider\\TranslationServiceProvider')->setMethods(['fileIsAllowed'])->getMock(); $provider->expects($this->once())->method('fileIsAllowed')->withAnyParameters()->will($this->returnValue(true)); $app->register(new SilexTranslationServiceProvider()); $app->register($provider, ['translation.directory' => $transDirectory]); $app->boot(); $this->assertInstanceOf('\\Silex\\Translator', $app['translator']); $loaders = $this->invokeMethod($app['translator'], 'getLoaders'); $this->assertInstanceOf('\\Symfony\\Component\\Translation\\Loader\\YamlFileLoader', $loaders['yaml']); $this->assertEquals('Hello', $app['translator']->trans('hello')); }
public function testJWTListenerService() { $this->register(); $this->app->boot(); $jwtListener = $this->app->offsetGet('security.authentication_listener.all.jwt'); $this->assertInstanceOf(JWTListener::class, $jwtListener); }