コード例 #1
0
ファイル: KernelAwareTest.php プロジェクト: Codixis/CSBill
 public function setUp()
 {
     $this->kernel = new \AppKernel('test', true);
     $this->kernel->boot();
     $this->container = $this->kernel->getContainer();
     parent::setUp();
 }
コード例 #2
0
ファイル: sf2plugin.php プロジェクト: cmoncy/WordpressBundle
 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();
 }
コード例 #3
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');
 }
コード例 #4
0
ファイル: CodeCoverage.php プロジェクト: Trismegiste/thatch
 public function __construct(PHP_CodeCoverage_Driver $driver = NULL, PHP_CodeCoverage_Filter $filter = NULL)
 {
     require $_SERVER['KERNEL_DIR'] . '/AppKernel.php';
     $this->appKernel = new \AppKernel('test', true);
     $this->appKernel->boot();
     $this->twig = $this->appKernel->getContainer()->get('twig');
     $this->twigCacheRegex = '#^' . $this->twig->getCache() . '/././([0-9a-f]+)\\.php$#';
     $filter->addDirectoryToWhitelist($this->twig->getCache());
     parent::__construct($driver, $filter);
 }
コード例 #5
0
 /**
  * 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');
 }
 public function testCacheCompilerPass()
 {
     static::assertTrue(self::$kernel->getContainer()->has('s.teavee_object_cache.registrar'));
     $registrar = self::$kernel->getContainer()->get('s.teavee_object_cache.registrar');
     static::assertInstanceOf('Scribe\\Teavee\\ObjectCacheBundle\\DependencyInjection\\Compiler\\Registrar\\CacheCompilerRegistrar', $registrar);
     static::assertCount(3, $registrar->getAttendantCollection());
     static::assertTrue(self::$kernel->getContainer()->has('s.teavee_object_cache.key_generator'));
     $g = self::$kernel->getContainer()->get('s.teavee_object_cache.key_generator');
     foreach ($registrar->getAttendantCollection() as $attendant) {
         static::assertEquals($g, $attendant->getKeyGenerator());
     }
 }
コード例 #7
0
ファイル: Malice.php プロジェクト: alsbury/malice
 public function _initialize()
 {
     /** @var CodeceptionModule\Symfony2 $module */
     $module = $this->getModule('Symfony2');
     /** @var \AppKernel $kernel */
     $this->kernel = $module->kernel;
     $this->container = $this->kernel->getContainer();
     $this->entityManager = $this->container->get('doctrine.orm.entity_manager');
     $this->fixturesFinder = $this->container->get('hautelook_alice.doctrine.orm.fixtures_finder');
     $this->fixturesLoader = $this->container->get('hautelook_alice.fixtures.loader');
     $this->fixturesExecutor = $this->container->get('hautelook_alice.doctrine.executor.fixtures_executor');
     $this->bundleResolver = $this->container->get('hautelook_alice.bundle_resolver');
     $this->schemaTool = new SchemaTool($this->entityManager);
 }
コード例 #8
0
ファイル: BaseTestCase.php プロジェクト: styling/LeesPharm
 /**
  * 每个testXXX执行之前,都会执行此函数,净化数据库。
  * 
  * NOTE: 如果数据库已创建,那么执行清表操作,不重建。
  */
 private function setServiceKernel()
 {
     $kernel = new \AppKernel('test', false);
     $kernel->loadClassCache();
     $kernel->boot();
     Request::enableHttpMethodParameterOverride();
     $request = Request::createFromGlobals();
     $serviceKernel = ServiceKernel::create($kernel->getEnvironment(), $kernel->isDebug());
     $serviceKernel->setParameterBag($kernel->getContainer()->getParameterBag());
     $serviceKernel->setConnection($kernel->getContainer()->get('database_connection'));
     $currentUser = new CurrentUser();
     $currentUser->fromArray(array('id' => 1, 'nickname' => 'admin', 'email' => '*****@*****.**', 'password' => 'admin', 'currentIp' => '127.0.0.1', 'roles' => array('ROLE_USER', 'ROLE_ADMIN', 'ROLE_SUPER_ADMIN', 'ROLE_TEACHER')));
     $serviceKernel->setCurrentUser($currentUser);
     $this->serviceKernel = $serviceKernel;
 }
コード例 #9
0
 public function __construct()
 {
     $kernel = new \AppKernel("test", true);
     $kernel->boot();
     $this->_container = $kernel->getContainer();
     $this->searchEngine = $this->get('beecms.search.service');
 }
コード例 #10
0
 protected function setUp()
 {
     $kernel = new \AppKernel('test', true);
     $kernel->boot();
     $this->container = $kernel->getContainer();
     $this->youtube = $this->container->get('awy.google.youtube');
 }
コード例 #11
0
 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();
 }
コード例 #12
0
 public function __construct()
 {
     $kernel = new AppKernel('test', true);
     $kernel->boot();
     $this->em = $kernel->getContainer()->get('doctrine.orm.entity_manager');
     $this->kernel = $kernel;
 }
コード例 #13
0
 public function __construct()
 {
     $kernel = new \AppKernel("test", true);
     $kernel->boot();
     $this->container = $kernel->getContainer();
     parent::__construct();
 }
コード例 #14
0
 public function setUp()
 {
     $kernel = new \AppKernel('test', true);
     $kernel->boot();
     $this->container = $kernel->getContainer();
     $this->service = $this->container->get('dugun_upload.service.upload_service');
 }
コード例 #15
0
 public static function setUpBeforeClass()
 {
     require_once "{$_SERVER['KERNEL_DIR']}/AppKernel.php";
     $kernel = new \AppKernel('test', true);
     $kernel->boot();
     self::$validator = $kernel->getContainer()->get('validator');
 }
コード例 #16
0
 public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     $kernel = new \AppKernel('phpunit', true);
     $kernel->boot();
     // drop/create database schema
     $em = $kernel->getContainer()->get('doctrine.orm.default_entity_manager');
     $meta = $em->getMetadataFactory()->getAllMetadata();
     $tool = new \Doctrine\ORM\Tools\SchemaTool($em);
     $tool->dropSchema($meta);
     $tool->createSchema($meta);
     // insert fixtures
     $fixtures = array('src/Kunstmaan/TranslatorBundle/Tests/files/fixtures.yml');
     $em = $kernel->getContainer()->get('doctrine.orm.default_entity_manager');
     $objects = \Nelmio\Alice\Fixtures::load($fixtures, $em);
     $persister = new \Nelmio\Alice\ORM\Doctrine($em);
     $persister->persist($objects);
 }
コード例 #17
0
 /**
  * Да да, тот самый контейнер, про который вы подумали
  *
  * @return mixed
  */
 protected function getContainer()
 {
     if (!$this->container) {
         $kernel = new \AppKernel('prod', false);
         $kernel->boot();
         $this->container = $kernel->getContainer();
     }
     return $this->container;
 }
コード例 #18
0
 /**
  * {@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);
 }
コード例 #19
0
    public function test()
    {
        $kernel = new AppKernel('test', true);
        $kernel->boot();
        $formFactory = $kernel->getContainer()->get('form.factory');
        $serializer = $kernel->getContainer()->get('serializer');
        $formView = $formFactory->createBuilder('form', null, array('action' => '/target', 'method' => 'PUT'))->add('name', 'text')->add('description', 'textarea')->getForm()->createView();
        $xml = $serializer->serialize($formView, 'xml');
        $json = $serializer->serialize($formView, 'json');
        $this->assertEquals(<<<XML
<?xml version="1.0" encoding="UTF-8"?>
<form method="PUT" action="/target">
  <input type="text" name="form[name]" required="required"/>
  <textarea name="form[description]" required="required"><![CDATA[]]></textarea>
</form>

XML
, $xml);
        $this->assertEquals('null', $json);
    }
コード例 #20
0
 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);
 }
コード例 #21
0
 private function client()
 {
     $kernel = new AppKernel('test', false);
     $kernel->boot();
     $client = $kernel->getContainer()->get('test.client');
     $crawler = $client->request('GET', '/login');
     $form = $crawler->filter('form')->form(array('_username' => $this->username, '_password' => $this->password));
     $client->submit($form);
     $client->followRedirect();
     return $client;
 }
コード例 #22
0
ファイル: OrmPurgeTrait.php プロジェクト: A5sys/MinkContext
 /**
  * Purge the complete database
  *
  * @param string $environment
  * @return Kernel $kernel
  */
 public static function purgeDatabase($environment = 'test')
 {
     $kernel = new \AppKernel($environment, true);
     $kernel->boot();
     $container = $kernel->getContainer();
     $doctrine = $container->get('doctrine');
     $em = $doctrine->getManager();
     $loader = new Loader();
     $purger = new ORMPurger();
     $executor = new ORMExecutor($em, $purger);
     $executor->execute($loader->getFixtures());
     return $kernel;
 }
コード例 #23
0
 public function __construct()
 {
     require_once __DIR__ . '/../../app/bootstrap.php.cache';
     require_once __DIR__ . '/../../app/AppKernel.php';
     $kernel = new \AppKernel('test', true);
     $kernel->boot();
     register_shutdown_function(function () {
         if ($error = error_get_last()) {
             var_dump(array_merge($error, ['class' => get_called_class()]));
         }
     });
     $this->container = $kernel->getContainer();
 }
コード例 #24
0
ファイル: SiwappBaseTest.php プロジェクト: rvdavid/siwapp-sf2
 public function setUp()
 {
     $kernel = new \AppKernel("test", true);
     $kernel->boot();
     $this->em = $kernel->getContainer()->get('doctrine.orm.entity_manager');
     $this->_application = new Application($kernel);
     $this->_application->setAutoExit(false);
     $this->runConsole("doctrine:schema:create");
     $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"));
     $this->runConsole("doctrine:fixtures:load");
 }
 /**
  * This method is run before each public test method
  */
 protected function setUp()
 {
     require_once __DIR__ . '/../../AppKernel.php';
     $kernel = new \AppKernel('test', true);
     $kernel->boot();
     $this->container = $kernel->getContainer();
     $this->laRoute = $this->container->get('ordermind.logical_authorization_bundle.service.logical_authorization_route');
     $this->laModel = $this->container->get('ordermind.logical_authorization_bundle.service.logical_authorization_model');
     $this->testEntityRepositoryManager = $this->container->get('repository_manager.test_entity');
     $this->testUserRepositoryManager = $this->container->get('repository_manager.test_user');
     $this->testEntityOperations = $this->container->get('test_entity_operations');
     $this->deleteAll($this->testEntityRepositoryManager);
     $this->addUsers();
     $this->client = static::createClient();
 }
コード例 #26
0
 /**
  * This tests only purpose is to check if the service container configuration works properly
  */
 public function testSend()
 {
     $kernel = new \AppKernel('test', true);
     $kernel->boot();
     $container = $kernel->getContainer();
     $request = $this->prophesize(Request::class);
     $request->getLocale()->willReturn('de');
     $requestStack = $this->prophesize(RequestStack::class);
     $requestStack->getMasterRequest()->willReturn($request->reveal());
     $container->set('request_stack', $requestStack->reveal());
     try {
         $container->get('system_mailer')->send('HautziSystemMail:test');
         $this->fail('fetching a mail that does nox exist should throw an exception.');
     } catch (\InvalidArgumentException $e) {
         $this->assertContains('@HautziSystemMailBundle/Resources/emails/test.xml.twig', $e->getMessage());
     }
 }
コード例 #27
0
 public static function Bootstrap(\AppKernel $kernel, \Symfony\Component\HttpFoundation\Request $request = null)
 {
     if (null !== self::$_container) {
         throw new \Exception();
     }
     $kernel->boot();
     self::$_container = $kernel->getContainer();
     if (self::$_container->getParameter('sf.bbs.plugin.enabled')) {
         self::$_container->get('sf.bbs.plugin_manager')->setup();
     }
     if ($request) {
         self::$_in_symfony_firewall = true;
     } else {
         self::$_in_symfony_firewall = false;
         $request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
     }
     self::setCacheValue('request', $request);
     return $kernel;
 }
コード例 #28
0
 /**
  * AuthBridge constructor.
  * @param $symfonyRootPath
  * @param $symfonyUrl
  */
 function __construct($symfonyRootPath, $symfonyUrl, $groupManager = null)
 {
     global $wgHooks;
     $this->symfonyRootPath = $symfonyRootPath;
     $this->symfonyUrl = $symfonyUrl;
     // Set some MediaWiki Values
     // This requires a user be logged into the wiki to make changes.
     $GLOBALS['wgGroupPermissions']['*']['edit'] = false;
     // Specify who may create new accounts:
     $GLOBALS['wgGroupPermissions']['*']['createaccount'] = false;
     if (is_dir($this->symfonyRootPath)) {
         // Load Hooks
         $wgHooks['UserLoginForm'][] = array($this, 'onUserLoginForm', false);
         $wgHooks['UserLoginComplete'][] = $this;
         $wgHooks['UserLogout'][] = $this;
         $wgHooks['UserLoadFromSession'][] = array($this, 'AutoAuthenticateOverSymfony');
         $wgHooks['UserLogout'][] = array($this, 'logoutForm');
         $wgHooks['UserLoginForm'][] = array($this, 'loginForm');
         $loader = (require $this->symfonyRootPath . '/app/autoload.php');
         require_once $this->symfonyRootPath . '/var/bootstrap.php.cache';
         if (false) {
             Debug::enable();
             $kernel = new \AppKernel('dev', true);
         } else {
             $kernel = new \AppKernel('prod', false);
         }
         //Request::enableHttpMethodParameterOverride();
         $request = Request::createFromGlobals();
         $kernel->handle($request);
         $this->symfonyConatiner = $kernel->getContainer();
         if ($groupManager && $this->symfonyConatiner->has($groupManager)) {
             $groupBridge = new GroupBridge($this, $groupManager);
             $groupBridge->initGroups();
             $groupBridge->setUpGroupNamespaces();
         }
     } else {
         trigger_error("Symfony System not found! Login is not possible!", E_USER_NOTICE);
     }
 }
 public function setUp()
 {
     $kernel = new \AppKernel('test', true);
     $kernel->boot();
     static::$container = $kernel->getContainer();
 }
コード例 #30
0
ファイル: index.php プロジェクト: forkcms/forkcms
$request = Request::createFromGlobals();
if (!file_exists($parametersFile)) {
    $env = 'install';
    if (strpos($request->getRequestUri(), '/install') !== 0) {
        // check .htaccess
        if (!$request->query->has('skiphtaccess') && !file_exists('.htaccess')) {
            echo 'Your install is missing the .htaccess file. Make sure you show
                 hidden files while uploading Fork CMS. Read the article about
                 <a href="http://www.fork-cms.com/community/documentation/detail/installation/webservers">webservers</a>
                 for further information. <a href="?skiphtaccess">Skip .htaccess
                 check</a>';
            return;
        }
        header('Location: /install');
        return;
    }
}
require_once __DIR__ . '/app/AppKernel.php';
if (extension_loaded('newrelic')) {
    newrelic_name_transaction(strtok($request->getRequestUri(), '?'));
}
if ($debug) {
    Debug::enable();
}
$kernel = new AppKernel($env, $debug);
$response = $kernel->handle($request);
if ($response->getCharset() === null && $kernel->getContainer() instanceof ContainerInterface) {
    $response->setCharset($kernel->getContainer()->getParameter('kernel.charset'));
}
$response->send();
$kernel->terminate($request, $response);