/** * Set up test */ public function setUp() { static::$kernel = static::createKernel(); static::$kernel->boot(); static::$application = new Application(static::$kernel); static::$application->setAutoExit(false); }
public function setUp() { static::$kernel = static::createKernel(); static::$kernel->boot(); $this->dm = static::$kernel->getContainer()->get('doctrine.odm.mongodb.document_manager'); parent::setUp(); }
/** * @return RouterInterface */ private function getRouter() { if (null === $this->router) { $this->kernel->boot(); $this->router = $this->kernel->getContainer()->get('router'); } return $this->router; }
private static function initKernel() { static::$kernel = static::createKernel(); static::$kernel->boot(); static::$container = static::$kernel->getContainer(); static::$doctrine = static::$container->get('doctrine'); static::$om = static::$doctrine->getManager(); }
/** * {@inheritdoc} */ public function setKernel(KernelInterface $kernel) { $this->kernel = $kernel; if (null === self::$sharedKernel) { self::$sharedKernel = clone $kernel; self::$sharedKernel->boot(); } }
/** * @return ContainerInterface */ private function getContainer() { if ($this->kernel === null) { $this->kernel = $this->createKernel(); $this->kernel->boot(); } return $this->kernel->getContainer(); }
/** * Returns an iterator that provides Twig template paths. * * @return \Traversable */ public function getIterator() { $this->kernel->boot(); $viewDirectories = $this->getPossibleViewDirectories(); $viewDirectories = $this->removeNotExistingDirectories($viewDirectories); $templates = $this->getTwigTemplatesIn($viewDirectories); return new \ArrayIterator($templates); }
/** * @return ContainerInterface */ protected function getContainer() { if ($this->kernel === NULL) { $this->kernel = $this->createKernel(); $this->kernel->boot(); } return $this->kernel->getContainer(); }
/** * Build client * * @return $this Self object */ public function buildClient() { $this->kernel = new \AppKernel('test', false); $this->kernel->boot(); $this->session->clear(); $this->client = $this->kernel->getContainer()->get('test.client'); $this->environmentBuilder->setUp($this->kernel); }
public function setUp() { static::$kernel = static::createKernel(); static::$kernel->boot(); $this->client = static::createClient([], ['HTTP_HOST' => static::$httpHost]); $this->dm = static::$kernel->getContainer()->get('doctrine.odm.mongodb.document_manager'); $this->um = static::$kernel->getContainer()->get('backend.user.manager'); $this->locales = explode("|", static::$kernel->getContainer()->getParameter('locales')); $this->api = array('frontend' => static::$kernel->getContainer()->getParameter('frontend_api'), 'backend' => static::$kernel->getContainer()->getParameter('backend_api')); parent::setUp(); }
/** * Creates a Client. * * @param array $options An array of options to pass to the createKernel class * @param array $server An array of server parameters * * @return Client A Client instance */ protected static function createClient(array $options = array(), array $server = array()) { if (null !== static::$kernel) { static::$kernel->shutdown(); } static::$kernel = static::createKernel($options); static::$kernel->boot(); $client = static::$kernel->getContainer()->get('test.client'); $client->setServerParameters($server); return $client; }
public function setUp() { // Boot the AppKernel in the test environment and with the debug. $this->kernel = new \AppKernel('test', true); $this->kernel->boot(); // Store the container and the entity manager in test case properties $this->container = $this->kernel->getContainer(); $this->entityManager = $this->container->get('doctrine')->getEntityManager(); // Build the schema for sqlite $this->generateSchema(); parent::setUp(); }
protected function setUp() { if (!isset($this->serviceName)) { throw new Exception("Service name has to be set"); } $this->_kernel = $this->createKernel(); $this->_kernel->boot(); try { $this->manager = $this->_kernel->getContainer()->get($this->serviceName); } catch (ServiceNotFoundException $notFoundException) { throw new Exception("The service " . $this->serviceName . " has to be registered."); } }
/** * Set up before class. * * @throws RuntimeException unable to start the application */ public static function setUpBeforeClass() { try { static::$kernel = static::createKernel(); static::$kernel->boot(); static::$application = new Application(static::$kernel); static::$application->setAutoExit(false); static::$container = static::$kernel->getContainer(); } catch (Exception $e) { throw new RuntimeException(sprintf('Unable to start the application: %s', $e->getMessage()), $e->getCode(), $e); } static::createSchema(); }
/** * {@inheritdoc} */ protected function doRequest($request) { if ($this->hasPerformedRequest) { $this->kernel->shutdown(); $this->kernel->boot(); } else { $this->hasPerformedRequest = true; } $this->refreshDoctrineConnection(); $response = $this->kernel->handle($request); if ($this->kernel instanceof TerminableInterface) { $this->kernel->terminate($request, $response); } return $response; }
public static function setUpBeforeClass() { //require_once __DIR__ . '/../../../../../../app/AppKernel.php'; $path = '/../app/AppKernel.php'; for ($i = 0; $i < 15; $i++) { $file = __DIR__ . $path; if (is_file($file)) { require_once $file; break; } $path = '/..' . $path; } self::$kernel = new \AppKernel('test', true); self::$kernel->boot(); self::$container = self::$kernel->getContainer(); }
/** * @return ContainerInterface */ protected function getContainer() { if ($this->kernel === null) { $this->kernel = $this->createKernel(); // We can't load the class cache because Symfony2 uses // Psr Logger which php-resque does too. Symfony2 will load all classes // without checking causing conflicts. if (method_exists($this->kernel, 'loadClassCache')) { $refObject = new \ReflectionObject($this->kernel); $refProperty = $refObject->getProperty('loadClassCache'); $refProperty->setAccessible(true); $refProperty->setValue($this->kernel, null); } $this->kernel->boot(); } return $this->kernel->getContainer(); }
public function setUp() { static::$kernel = static::createKernel(); static::$kernel->boot(); $this->client = static::createClient([], ['HTTP_HOST' => static::$httpHost]); $this->em = static::$kernel->getContainer()->get('doctrine.orm.entity_manager'); $this->um = static::$kernel->getContainer()->get('backend.user.manager'); $this->locales = explode("|", static::$kernel->getContainer()->getParameter('locales')); $this->api = array('frontend' => static::$kernel->getContainer()->getParameter('frontend_api'), 'backend' => static::$kernel->getContainer()->getParameter('backend_api')); $this->validator = static::$kernel->getContainer()->get('validator'); $this->faker = Faker\Factory::create(); parent::setUp(); }
/** * {@inheritdoc} */ public function doRun(InputInterface $input, OutputInterface $output) { $this->kernel->boot(); $container = $this->kernel->getContainer(); $bundles = $this->kernel->getBundles(); foreach ($bundles as $bundle) { if ($bundle instanceof Bundle) { $bundle->registerCommands($this); } } $commands = $this->all(); foreach ($commands as $command) { if ($command instanceof ContainerAwareInterface) { $command->setContainer($container); } } if (true === $container->hasParameter('console.command.ids')) { foreach ($container->getParameter('console.command.ids') as $id) { $this->add($container->get($id)); } } $this->setDispatcher($container->get('event_dispatcher')); return parent::doRun($input, $output); }
/** * {@inheritDoc} */ public function doRun(InputInterface $input, OutputInterface $output) { $this->kernel->boot(); if (!$this->commandsRegistered) { $this->registerCommands($output); $this->commandsRegistered = true; } $container = $this->kernel->getContainer(); foreach ($this->all() as $command) { if ($command instanceof ContainerAwareInterface) { $command->setContainer($container); } } $this->setDispatcher($container->get('event_dispatcher')); RuntimeHelper::setupHome($container->get('tenside.home')->homeDir()); $this->inputOutput = new ConsoleIO($input, $output, $this->getHelperSet()); $this->isUpdateNeeded($input, $output); return parent::doRun($input, $output); }
/** * Creates a pre-configured container builder. * * The builder contains all extensions and its configurations. * * @return ContainerBuilder */ protected function createContainerBuilder() { $builder = new ContainerBuilder(); $this->kernel->boot(); foreach ($this->kernel->getBundles() as $bundle) { // Register all extensions, otherwise there might be config parts that cannot be processed. $extension = $bundle->getContainerExtension(); if ($extension !== null) { $builder->registerExtension($extension); } } // Load the application configuration, which might affect the loaded services. /* @var $locator FileLocatorInterface */ $locator = $this->kernel->getContainer()->get('file_locator'); $loaders = array(new XmlFileLoader($builder, $locator), new YamlFileLoader($builder, $locator), new IniFileLoader($builder, $locator), new PhpFileLoader($builder, $locator), class_exists(DirectoryLoader::class) ? new DirectoryLoader($builder, $locator) : null, new ClosureLoader($builder)); $loaders = array_filter($loaders); $resolver = new LoaderResolver($loaders); $loader = new DelegatingLoader($resolver); $this->kernel->registerContainerConfiguration($loader); return $builder; }
/** * Boots the Kernel for this test. * * @param array $options */ protected static function bootKernel(array $options = array()) { static::ensureKernelShutdown(); static::$kernel = static::createKernel($options); static::$kernel->boot(); }
/** * {@inheritdoc} */ public function boot() { $this->kernel->boot(); }
/** * Creates a reader that retrieves the bundles from the given kernel. * * @param KernelInterface $kernel */ public function __construct(KernelInterface $kernel) { $kernel->boot(); parent::__construct(new \ArrayIterator($kernel->getBundles())); }
/** * @inheritdoc */ public function setUp() { static::$kernel->boot(); $this->nonIsolatedLoader = $this->loader = new NonIsolatedSymfonyLoader(static::$kernel->getContainer()); }
/** * Get kernel * * @return KernelInterface */ private function getKernel() { if (!$this->kernel) { if (!self::$bootstrapped) { // Avoid Drupal attempt to return a cached page while we are // actually unit testing it drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION); $GLOBALS['conf']['cache'] = 0; drupal_page_is_cacheable(false); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); self::$bootstrapped = true; } $this->kernel = $this->createKernelInstance(uniqid('test_')); $this->kernel->boot(); $this->kernel->getContainer()->get('request_stack')->push(\MakinaCorpus\Drupal\Sf\Http\Request::createFromGlobals()); \Drupal::_setKernel($this->kernel); } return $this->kernel; }
public function setKernel(KernelInterface $kernel) { $this->kernel = $kernel; $this->kernel->boot(); $this->client = $this->kernel->getContainer()->get('test.client'); }
protected function bootKernel(KernelInterface $kernel, array $job) { $kernel->boot(); }