/** * @param \Symfony\Component\HttpKernel\Event\FilterControllerEvent $event */ public function onController(FilterControllerEvent $event) { if (!isset(static::$accessToken) || !static::$accessToken instanceof TokenInterface) { return; } $this->container->get('security.context')->setToken(static::$accessToken); }
/** * @return null */ public function setUp() { $this->kernel = new \AppKernel('test', true); $this->kernel->boot(); $this->container = $this->kernel->getContainer(); $this->entityManager = $this->container->get('doctrine')->getEntityManager(); $this->generateSchema(); parent::setUp(); }
protected function setUp() { $kernel = static::createKernel(); $kernel->boot(); $this->container = $kernel->getContainer(); $this->sut = $this->container->get('social.abusereport.repository'); $this->coll = $this->container->get('dokudoki.collection'); $this->repo = $this->container->get('dokudoki.repository'); }
public function beforeTestMethod($method) { $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(); $managerRegistry = $this->container->get('doctrine'); $this->collection = $managerRegistry->getRepository('AppBundle:Collection')->findOneBy(['collectioncode' => $this->collectionCode]); $this->genericEntityManager = new \AppBundle\Manager\GenericEntityManager($managerRegistry); }
/** * */ public function setUp() { $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')->getManager(); // Build the schema for sqlite $this->generateSchema(); parent::setUp(); }
/** * Initialize kernel app and some Symfony2 services. * * @see \PHPUnit_Framework_TestCase::setUp() */ protected 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')->getManager(); $this->entityManager->getConnection()->beginTransaction(); parent::setUp(); }
/** * Get all controllers from all bundles. * * @return array Controllers list */ protected function getControllers() { $controllers = array(); $finder = new ControllerFinder(); foreach ($this->container->get('kernel')->getBundles() as $bundle) { $found = $finder->getControllers($bundle); if (!empty($found)) { $controllers[$bundle->getName()] = $found; } } return $controllers; }
public function setUp() { require_once __DIR__ . '/Fixtures/app/AppKernel.php'; // Boot the AppKernel in the test environment and with the debug. $this->kernel = new \Heri\Bundle\JobQueueBundle\Tests\AppKernel('test', true); $this->kernel->boot(); $this->deleteTmpDir(); // Store the container and the entity manager in test case properties $this->container = $this->kernel->getContainer(); $this->em = $this->container->get('doctrine')->getManager(); parent::setUp(); }
public function setUp() { // Boot the AppKernel in the test environment and with the debug. $this->myKernel = new \AppKernel('test', true); $this->myKernel->boot(); // Store the container and the entity manager in test case properties $this->container = $this->myKernel->getContainer(); $this->entityManager = $this->container->get('doctrine')->getManager(); $this->tagRepository = $this->container->get('doctrine')->getRepository("AutomationBundle:Tag"); // Build the schema for sqlite //$this->generateSchema(); parent::setUp(); }
/** * {@inheritDoc} * * @throws \LogicException When the container is not present yet. * * @throws IOException When the directory is not writable. */ public function getLogDir() { if (!$this->container) { throw new \LogicException('The container has not been set yet.'); } $logDir = $this->container->get('tenside.home')->homeDir() . '/tenside/logs'; if (!is_dir($logDir)) { $fileSystem = new Filesystem(); $fileSystem->mkdir($logDir); } if (!is_writable($logDir)) { throw new IOException(sprintf('The directory "%s" is not writable.', $logDir), 0, null, $logDir); } return $this->container->get('tenside.home')->homeDir() . '/tenside/logs'; }
/** * Return the controller class name. * * @param $action */ private function getControllerClass($action) { list($bundleName, $controllerName) = explode('_', $action); $bundleName .= 'Bundle'; $bundle = $this->container->get('kernel')->getBundle($bundleName); $namespace = $bundle->getNamespace() . '\\Controller'; $class = $namespace . '\\' . $controllerName . 'Controller'; return $class; }
/** * Resolve the called controller from action. * * @param string $action * @return <type> */ private function resolveController($action) { list($bundleName, $controllerName) = explode('_', $action); $bundleName .= "Bundle"; $bundle = $this->container->get('kernel')->getBundle($bundleName); $namespace = $bundle->getNamespace() . "\\Controller"; $class = $namespace . "\\" . $controllerName . "Controller"; try { $controller = new $class(); if ($controller instanceof ContainerAware) { $controller->setContainer($this->container); } return $controller; } catch (Exception $e) { // todo: handle exception } }
public function beforeTestMethod($method) { $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(); $managerRegistry = $this->container->get('doctrine'); $this->exportManager = new \AppBundle\Manager\ExportManager($managerRegistry, $this->container->get('session'), $this->container->get('genericentitymanager'), $this->container->getParameter('maxitemperpage')[1], $this->container->get('diff.computer'), $this->container->getParameter('user_group')); $user = new User('tpateffoz', $this->container->getParameter('api_recolnat_base_uri'), $this->container->getParameter('api_recolnat_user_path'), $this->container->getParameter('user_group')); $user->setExportPath($this->container->getParameter('export_path')); $collection = $this->container->get('utility')->getCollection('MHNAIX', 'AIX'); $this->exportManager->init($user)->setCollection($collection); }
/** * createModuleData. */ public function createModuleData() { $aFields = $this->getFields(); $aContent = array(); foreach ($aFields as $field) { $aContent[$field['identifier']] = $field['testData']; } $oModule = new Module(); $oModule->setName('Test Module'); $oModule->setDescription('test'); $sequence = 0; foreach ($aFields as $field) { $oField = new Field(); $oField->setName($field['name']); $oField->setFormType($field['form']); $oField->setIdentifier($field['identifier']); $this->em->persist($oField); $oModuleHasField = new ModuleHasField(); $oModuleHasField->setField($oField); $oModuleHasField->setModule($oModule); $oModuleHasField->setSequence($sequence); $this->em->persist($oModuleHasField); ++$sequence; } $this->em->flush(); for ($i = 0; $i < $this->rows; ++$i) { $container = new Container(); $container->setModule($oModule); $container->setSequence(999); $this->em->persist($container); $this->em->flush(); $this->container->enterScope('request'); $this->container->set('request', new Request(), 'request'); $object = $this->container->get('eav.module.manager'); $object->setModule($oModule); $object->save($container, $aContent); } $this->em->clear(); }
public function get($serviceId) { return self::$container->get($serviceId); }