Inheritance: extends Yulois\Kernel
 public function setUp()
 {
     $kernel = new \AppKernel('test', true);
     $kernel->boot();
     $this->container = $kernel->getContainer();
     $this->service = $this->container->get('dugun_upload.service.upload_service');
 }
 public function __construct()
 {
     $kernel = new AppKernel('test', true);
     $kernel->boot();
     $this->em = $kernel->getContainer()->get('doctrine.orm.entity_manager');
     $this->kernel = $kernel;
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $environments = explode(',', $input->getArgument('environments'));
     $table = (new Table($output))->setHeaders(['env', 'key', 'value']);
     foreach ($environments as $key => $environment) {
         if ($key > 0) {
             $table->addRow(new TableSeparator());
         }
         $environmentKernel = new \AppKernel($environment, false);
         $environmentKernel->initializeWithoutCaching();
         foreach ($environmentKernel->getContainer()->getParameterBag()->all() as $parameter => $value) {
             if ($input->getOption('filter') !== null) {
                 $pattern = sprintf('~%s~', $input->getOption('filter'));
                 if (!preg_match($pattern, $parameter)) {
                     continue;
                 }
             }
             if (is_array($value)) {
                 $value = json_encode($value);
             }
             $table->addRow([$environment, $parameter, $value]);
         }
     }
     $table->render();
 }
 protected function setUp()
 {
     $kernel = new \AppKernel('test', true);
     $kernel->boot();
     $this->container = $kernel->getContainer();
     $this->youtube = $this->container->get('awy.google.youtube');
 }
Beispiel #5
0
 /**
  * @param AppKernel $kernel
  * @param \Zero\Component\Kernel\Container $app_container
  * @throws \Exception
  */
 public static function process(AppKernel $kernel, $app_container)
 {
     global $argv;
     if (!isset($argv[1])) {
         throw new \Exception("命令行第一个参数应该是需要调用的方法");
     }
     $controller = $argv[1];
     if (strpos($controller, ':') === false) {
         throw new \Exception("第一个参数错误,格式应该为<module_name>:<command_name>:<action_name>");
     }
     $arguments = array_splice($argv, 2);
     try {
         list($module_name, $command_name, $action_name) = explode(':', $controller);
         $module = $kernel->getModule($module_name);
         $command = $module->getCommand($command_name, $action_name);
         if (method_exists($command, '__invoke')) {
             /** @var \Symfony\Component\HttpFoundation\Response $response */
             call_user_func_array($command, $arguments);
         } else {
             throw new \Exception('Command must has the __invoke public function!');
         }
     } catch (\Exception $e) {
         throw $e;
     }
 }
Beispiel #6
0
 public function tearDown()
 {
     if (null !== $this->kernel) {
         $this->kernel->shutdown();
     }
     parent::tearDown();
 }
Beispiel #7
0
 private function loadSf2()
 {
     global $kernel;
     //@settings_fields('wp_symfony_settings');
     //@do_settings_fields('wp_symfony_settings');
     $path = get_option('symfony2_path');
     $env = get_option('symfony2_env');
     $url = get_option('symfony2_url');
     if (!$this->isValidSymfonyPath($path)) {
         add_action('admin_footer', array($this, 'symfony2_warning'));
         return;
     }
     if ($kernel == null) {
         $loader = (require_once $path . 'app/bootstrap.php.cache');
         require_once $path . 'app/AppKernel.php';
         $kernel = new AppKernel($env, true);
         $kernel->loadClassCache();
         $kernel->boot();
         $this->kernel = $kernel;
         $this->container = $kernel->getContainer();
         if ($this->container->get('session')->isStarted() == false) {
             $this->container->get('session')->start();
         }
         if ($url != null) {
             $this->overloadUrlContext($url);
         }
     } else {
         $this->kernel = $kernel;
         $this->container = $kernel->getContainer();
     }
     $wp_loader = $this->container->get('wordpress.loader');
     $wp_loader->load();
 }
 public function __construct()
 {
     $kernel = new \AppKernel("test", true);
     $kernel->boot();
     $this->container = $kernel->getContainer();
     parent::__construct();
 }
 protected static function bootstrapApplication()
 {
     $kernel = new \AppKernel(static::$environment, static::$debug);
     $kernel->boot();
     static::$application = new Application($kernel);
     static::$application->setAutoExit(false);
 }
 /**
  * @param ContainerBuilder $container
  *
  * @return void
  */
 public function prepend(ContainerBuilder $container)
 {
     // Build fos_elastica config for each widget
     $elasticaConfig = [];
     $kernel = new \AppKernel('prod', false);
     $yamlParser = new Yaml();
     foreach ($kernel->registerBundles() as $bundle) {
         /* @var Bundle $bundle */
         $path = $bundle->getPath();
         //If bundle is a widget
         if (0 === strpos($bundle->getNamespace(), 'Victoire\\Widget\\')) {
             //find for a fos_elastica.yml config file
             $widgetConfig = $yamlParser->parse($path . '/Resources/config/config.yml');
             if (is_array($widgetConfig)) {
                 foreach ($widgetConfig['victoire_core']['widgets'] as $_widgetConfig) {
                     if (array_key_exists('fos_elastica', $widgetConfig)) {
                         $_config = ['indexes' => ['widgets' => ['types' => [$_widgetConfig['name'] => ['serializer' => ['groups' => ['search']], 'mappings' => [], 'persistence' => ['driver' => 'orm', 'model' => $_widgetConfig['class'], 'provider' => [], 'listener' => [], 'finder' => []]]]]]];
                         $_config = array_merge_recursive($widgetConfig['fos_elastica'], $_config);
                         $elasticaConfig = array_merge_recursive($elasticaConfig, $_config);
                     }
                 }
             }
         }
     }
     foreach ($container->getExtensions() as $name => $extension) {
         switch ($name) {
             case 'fos_elastica':
                 $container->prependExtensionConfig($name, $elasticaConfig);
                 break;
         }
     }
 }
 public function __construct()
 {
     $kernel = new \AppKernel("test", true);
     $kernel->boot();
     $this->_container = $kernel->getContainer();
     $this->searchEngine = $this->get('beecms.search.service');
 }
 public static function setUpBeforeClass()
 {
     @unlink(__DIR__ . '/../Fixtures/Test/TestBundle/Resources/config/routing.rest.yml');
     @unlink(__DIR__ . '/../Fixtures/Test/TestBundle/Controller/CarController.php');
     @unlink(__DIR__ . '/../Fixtures/Test/TestBundle/Controller/OrderController.php');
     $kernel = new \AppKernel('test', true);
     $app = new Application($kernel);
     $app->addCommands(array(new GenerateRestControllerCommand()));
     $kernel->boot();
     $command = $app->find('generate:rest:controller');
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName(), '--controller' => 'TestTestBundle:Order', '--entity' => 'TestTestBundle:Order', '--mongo' => true), array('interactive' => false));
     $kernel->shutdown();
     $kernel = new \AppKernel('test', true);
     $app = new Application($kernel);
     $app->addCommands(array(new GenerateRestControllerCommand()));
     $kernel->boot();
     $command = $app->find('generate:rest:controller');
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName(), '--controller' => 'TestTestBundle:Car', '--entity' => 'TestTestBundle:Car'), array('interactive' => false));
     $kernel->shutdown();
     @unlink(__DIR__ . '/../app/cache/test/appTestUrlGenerator.php.meta');
     @unlink(__DIR__ . '/../app/cache/test/appTestUrlGenerator.php');
     @unlink(__DIR__ . '/../app/cache/test/appTestUrlMatcher.php.meta');
     @unlink(__DIR__ . '/../app/cache/test/appTestUrlMatcher.php');
 }
 /**
  * @param mixed $resource
  * @param null $type
  * @return \Symfony\Component\Routing\RouteCollection
  * @throws \RuntimeException
  */
 public function load($resource, $type = null)
 {
     $routes = new RouteCollection();
     /*
      * For each core bunle then for each module
      */
     // CoreBundle
     $loader = $this->resolver->resolve('@EtuCoreBundle/Api/Resource/', 'annotation');
     if ($loader) {
         $routes->addCollection($loader->load('@EtuCoreBundle/Api/Resource/', 'annotation'));
     }
     // UserBundle
     $loader = $this->resolver->resolve('@EtuUserBundle/Api/Resource/', 'annotation');
     if ($loader) {
         $routes->addCollection($loader->load('@EtuUserBundle/Api/Resource/', 'annotation'));
     }
     /** @var $module Module */
     foreach ($this->kernel->getModulesDefinitions() as $module) {
         $routing = $module->getApiRouting();
         $loader = $this->resolver->resolve($routing['resource'], $routing['type']);
         if ($loader) {
             $routes->addCollection($loader->load($routing['resource'], $routing['type']));
         }
     }
     return $routes;
 }
 /**
  * {@inheritdoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $configuration = new Configuration();
     $config = $this->processConfiguration($configuration, $configs);
     $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('services.yml');
     $loader->load('forms.yml');
     // We instanciate a new kernel and iterate on all it's bundles to load the victoire_core configs
     $kernel = new \AppKernel('prod', false);
     foreach ($kernel->registerBundles() as $bundle) {
         $path = $bundle->getPath();
         $yamlParser = new Yaml($container, $path . '/Resources/config/config.yml');
         $victoireConfig = $yamlParser->parse($path . '/Resources/config/config.yml');
         if (is_array($victoireConfig) && array_key_exists('victoire_core', $victoireConfig)) {
             $config['widgets'] = array_merge($config['widgets'], $victoireConfig['victoire_core']['widgets'] ?: []);
         }
     }
     $container->setParameter('victoire_core.cache_dir', $config['cache_dir']);
     $container->setParameter('victoire_core.business_entity_debug', $config['business_entity_debug']);
     if (array_key_exists('templates', $config)) {
         $container->setParameter('victoire_core.templates', $config['templates']);
     } else {
         $container->setParameter('victoire_core.templates', '');
     }
     $container->setParameter('victoire_core.widgets', $config['widgets']);
     $container->setParameter('victoire_core.layouts', $config['layouts']);
     $container->setParameter('victoire_core.slots', $config['slots']);
     $container->setParameter('victoire_core.user_class', $config['user_class']);
     $container->setParameter('victoire_core.base_paths', $config['base_paths']);
     $container->setParameter('victoire_core.base_paths', $config['base_paths']);
     $container->setParameter('victoire_core.businessTemplates', $config['businessTemplates']);
 }
Beispiel #15
0
 private function buildKernel()
 {
     require_once __DIR__ . "/../../../../../app/AppKernel.php";
     $kernel = new \AppKernel("test", true);
     $kernel->boot();
     return $kernel;
 }
Beispiel #16
0
 protected function setUp()
 {
     $kernel = new \AppKernel('test', false);
     $kernel->boot();
     $this->articleRepository = $kernel->getContainer()->get('app.article_repository');
     $this->queryBus = $kernel->getContainer()->get('gnugat_query_bus.query_bus');
 }
 public static function setUpBeforeClass()
 {
     require_once "{$_SERVER['KERNEL_DIR']}/AppKernel.php";
     $kernel = new \AppKernel('test', true);
     $kernel->boot();
     self::$validator = $kernel->getContainer()->get('validator');
 }
Beispiel #18
0
 public function testSearchFocusSkill_FF()
 {
     $kernel = new \AppKernel('test_FF', true);
     $kernel->boot();
     $crawler = $this->client->request('GET', '/search');
     $this->assertTrue($crawler->filter('html:contains("Focus")')->count() == 0);
     $this->assertTrue($crawler->filter('html:contains("Skill")')->count() == 0);
 }
 protected function setUp()
 {
     $kernel = new \AppKernel('test', false);
     $kernel->boot();
     $application = new Application($kernel);
     $application->setAutoExit(false);
     $this->applicationTester = new ApplicationTester($application);
 }
 /**
  * Да да, тот самый контейнер, про который вы подумали
  *
  * @return mixed
  */
 protected function getContainer()
 {
     if (!$this->container) {
         $kernel = new \AppKernel('prod', false);
         $kernel->boot();
         $this->container = $kernel->getContainer();
     }
     return $this->container;
 }
 /**
  * {@inheritDoc}
  */
 protected function setUp()
 {
     $this->logger = $this->getMock('Symfony\\Bridge\\Monolog\\Logger', ['log'], ['name' => 'console.chain']);
     $kernel = new \AppKernel('test', false);
     $this->application = new Application($kernel);
     $this->application->setAutoExit(false);
     $kernel->boot();
     $kernel->getContainer()->set('chain_command.logger', $this->logger);
 }
Beispiel #22
0
 public function setUp()
 {
     $kernel = new \AppKernel("test", true);
     $kernel->boot();
     $this->_application = new \Symfony\Bundle\FrameworkBundle\Console\Application($kernel);
     $this->_application->setAutoExit(false);
     $this->runConsole("doctrine:schema:drop", array("--force" => true));
     $this->runConsole("doctrine:schema:create");
 }
Beispiel #23
0
 /**
  * Create a Symfony application
  */
 public function getApplication()
 {
     if (file_exists('./app/AppKernel.php')) {
         require_once './app/AppKernel.php';
     }
     $this->includeAutoload();
     $app = new \AppKernel($this->appenv, false);
     $app->loadClassCache();
     return $app;
 }
 /**
  * Construct a test case.
  */
 public function __construct()
 {
     parent::__construct();
     self::$kernel = new \AppKernel('test', true);
     self::$kernel->boot();
     self::$application = new Application(self::$kernel);
     self::$application->setAutoExit(false);
     self::$container = self::$kernel->getContainer();
     self::$doctrine = $this->get('doctrine');
 }
Beispiel #25
0
 public static function bootKernel()
 {
     $loader = (require_once __DIR__ . '/../../../../app/bootstrap.php.cache');
     Debug::enable();
     require_once __DIR__ . '/../../../../app/AppKernel.php';
     $kernel = new \AppKernel('dev', true);
     $kernel->loadClassCache();
     $kernel->boot();
     return $kernel;
 }
 public function up(Schema $schema)
 {
     // this up() migration is autogenerated, please modify it to your needs
     $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql");
     $kernel = new \AppKernel('prod', false);
     $application = new Application($kernel);
     $application->setAutoExit(false);
     $application->run(new ArgvInput(array('', 'sns-migrate')));
     $kernel->shutdown();
 }
Beispiel #27
0
 protected function buildKernel()
 {
     $this->kernel = new \AppKernel($this->environment->getType(), $this->environment->isDebug());
     if ($this->loadClassCache) {
         $this->kernel->loadClassCache();
     }
     if (true === (bool) $this->request->server->get('APP_CACHE', false)) {
         $this->kernel = new \AppCache($this->kernel);
     }
 }
function passDataToApplication($url)
{
    $_SERVER['REQUEST_URI'] = modifyUrl($url);
    $_GET['loggedAt'] = getLoggedAt();
    require_once __DIR__ . '/../app/bootstrap.php.cache';
    require_once __DIR__ . '/../app/AppKernel.php';
    $kernel = new AppKernel('prod', false);
    $kernel->loadClassCache();
    $request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
    $kernel->handle($request);
}
 public function testGenerator()
 {
     $filesystem = new Filesystem();
     $path = sys_get_temp_dir() . '/' . uniqid();
     $filesystem->remove($path);
     $bundle = $this->getBundle($path);
     $kernel = new \AppKernel('phpunit', true);
     $kernel->boot();
     $generator = new DefaultSiteGenerator($filesystem, $this->getRegistry(), '/defaultsite', $this->getAssistant(), $kernel->getContainer());
     $generator->generate($bundle, '', __DIR__ . '/../data', false);
 }
 public function setUp()
 {
     $kernel = new \AppKernel('test', true);
     $kernel->boot();
     $this->_application = new \Symfony\Bundle\FrameworkBundle\Console\Application($kernel);
     $this->_application->setAutoExit(false);
     $this->runConsole("doctrine:schema:drop", array("--force" => true));
     $this->runConsole("doctrine:schema:create");
     $this->runConsole("cache:warmup");
     //$this->runConsole("doctrine:fixtures:load", array("--fixtures" => __DIR__ . "/../DataFixtures"));
 }