Set the container object
public static setContainer ( Symfony\Component\DependencyInjection\ContainerInterface $container ) | ||
$container | Symfony\Component\DependencyInjection\ContainerInterface | The container object |
/** * Runs the actual tests. */ protected function runTests() { // Environment::get('ip') needs the request stack System::setContainer($this->mockContainerWithContaoScopes()); $agent = Environment::get('agent'); $this->assertEquals('mac', $agent->os); $this->assertEquals('mac chrome webkit ch33', $agent->class); $this->assertEquals('chrome', $agent->browser); $this->assertEquals('ch', $agent->shorty); $this->assertEquals(33, $agent->version); $this->assertEquals('webkit', $agent->engine); $this->assertEquals([33, 0, 1750, 149], $agent->versions); $this->assertFalse($agent->mobile); $this->assertEquals('HTTP/1.1', Environment::get('serverProtocol')); $this->assertEquals($this->getRootDir() . '/core/index.php', Environment::get('scriptFilename')); $this->assertEquals('/core/index.php', Environment::get('scriptName')); $this->assertEquals($this->getRootDir(), Environment::get('documentRoot')); $this->assertEquals('/core/en/academy.html?do=test', Environment::get('requestUri')); $this->assertEquals(['de-DE', 'de', 'en-GB', 'en'], Environment::get('httpAcceptLanguage')); $this->assertEquals(['gzip', 'deflate', 'sdch'], Environment::get('httpAcceptEncoding')); $this->assertEquals('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.149 Safari/537.36', Environment::get('httpUserAgent')); $this->assertEquals('localhost', Environment::get('httpHost')); $this->assertEmpty(Environment::get('httpXForwardedHost')); $this->assertFalse(Environment::get('ssl')); $this->assertEquals('http://localhost', Environment::get('url')); $this->assertEquals('http://localhost/core/en/academy.html?do=test', Environment::get('uri')); $this->assertEquals('123.456.789.0', Environment::get('ip')); $this->assertEquals('127.0.0.1', Environment::get('server')); $this->assertEquals('index.php', Environment::get('script')); $this->assertEquals('en/academy.html?do=test', Environment::get('request')); $this->assertEquals('en/academy.html?do=test', Environment::get('indexFreeRequest')); $this->assertEquals('http://localhost' . Environment::get('path') . '/', Environment::get('base')); $this->assertFalse(Environment::get('isAjaxRequest')); }
/** * {@inheritdoc} */ public function setUp() { System::setContainer($this->mockContainerWithContaoScopes()); require_once __DIR__ . '/../../src/Resources/contao/config/config.php'; $this->connection = $this->getMock('Doctrine\\DBAL\\Connection', ['fetchAll'], [], '', false); $this->eventDispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface'); $this->imageSizes = new ImageSizes($this->connection, $this->eventDispatcher, $this->mockContaoFramework()); }
/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); copy(__DIR__ . '/../Fixtures/images/dummy.jpg', self::$rootDir . '/dummy.jpg'); $GLOBALS['TL_CONFIG']['debugMode'] = false; $GLOBALS['TL_CONFIG']['gdMaxImgWidth'] = 3000; $GLOBALS['TL_CONFIG']['gdMaxImgHeight'] = 3000; $GLOBALS['TL_CONFIG']['validImageTypes'] = 'jpeg,jpg,svg,svgz'; define('TL_ERROR', 'ERROR'); define('TL_ROOT', self::$rootDir); System::setContainer($this->mockContainerWithContaoScopes()); }
/** * Initializes the framework. */ private function initializeFramework() { // Set the error_reporting level error_reporting($this->errorLevel); $this->includeHelpers(); // TODO: use Monolog to log errors $this->iniSet('error_log', $this->rootDir . '/system/logs/error.log'); $this->includeBasicClasses(); // Set the container System::setContainer($this->container); // Preload the configuration (see #5872) $this->config->preload(); // Register the class loader ClassLoader::scanAndRegister(); $this->initializeLegacySessionAccess(); $this->setDefaultLanguage(); // Fully load the configuration $this->config->initialize(); $this->validateInstallation(); Input::initialize(); $this->setTimezone(); // Set the mbstring encoding if (USE_MBSTRING && function_exists('mb_regex_encoding')) { mb_regex_encoding($this->config->get('characterSet')); } $this->triggerInitializeSystemHook(); $this->handleRequestToken(); }
/** * Boots the helper system. */ private function bootHelperSystem() { $contaoDir = $this->getRootDir() . '/../vendor/contao/core-bundle'; require_once $contaoDir . '/src/Resources/contao/config/constants.php'; require_once $contaoDir . '/src/Resources/contao/helper/functions.php'; // Register the class loader $libraryLoader = new LibraryLoader($this->getRootDir()); $libraryLoader->register(); Config::preload(); // Create the container $this->container = ContainerFactory::create($this); System::setContainer($this->container); ClassLoader::scanAndRegister(); }
/** * {@inheritdoc} */ protected function setUp() { System::setContainer($this->mockContainerWithContaoScopes()); }
/** * Tests empty getImage and executeResize hooks. * * @runInSeparateProcess * @preserveGlobalState disabled */ public function testEmptyHooks() { define('TL_ROOT', $this->getRootDir()); $GLOBALS['TL_CONFIG']['validImageTypes'] = 'jpg'; System::setContainer($this->mockContainerWithContaoScopes()); $path = $this->getRootDir() . '/images/dummy.jpg'; $resizer = new LegacyResizer($this->getRootDir() . '/assets/images', new ResizeCalculator()); $imagine = new Imagine(); $framework = $this->getMockBuilder('Contao\\CoreBundle\\Framework\\ContaoFramework')->disableOriginalConstructor()->getMock(); $filesModel = $this->getMock('Contao\\FilesModel'); $filesAdapter = $this->getMockBuilder('Contao\\CoreBundle\\Framework\\Adapter')->disableOriginalConstructor()->getMock(); $filesAdapter->expects($this->any())->method('__call')->willReturn($filesModel); $configAdapter = $this->getMockBuilder('Contao\\CoreBundle\\Framework\\Adapter')->disableOriginalConstructor()->getMock(); $configAdapter->expects($this->any())->method('__call')->willReturn(3000); $framework->expects($this->any())->method('getAdapter')->will($this->returnCallback(function ($key) use($filesAdapter, $configAdapter) { return ['Contao\\FilesModel' => $filesAdapter, 'Contao\\Config' => $configAdapter][$key]; })); $resizer->setFramework($framework); $imageFactory = $this->createImageFactory($resizer, $imagine, $imagine, null, $framework); $GLOBALS['TL_HOOKS'] = ['executeResize' => [[get_class($this), 'emptyHookCallback']]]; $GLOBALS['TL_HOOKS'] = ['getImage' => [[get_class($this), 'emptyHookCallback']]]; $image = $imageFactory->create($path, [100, 100, ResizeConfiguration::MODE_CROP]); $this->assertRegExp('(/images/.*dummy.*.jpg$)', $image->getPath(), 'Empty hook should be ignored'); $this->assertEquals(100, $image->getDimensions()->getSize()->getWidth()); $this->assertEquals(100, $image->getDimensions()->getSize()->getHeight()); unset($GLOBALS['TL_HOOKS']); }
/** * Initializes the framework. */ private function initializeFramework() { // Set the error_reporting level error_reporting($this->errorLevel); $this->includeHelpers(); $this->includeBasicClasses(); // Set the container System::setContainer($this->container); /** @var Config $config */ $config = $this->getAdapter('Contao\\Config'); // Preload the configuration (see #5872) $config->preload(); // Register the class loader ClassLoader::scanAndRegister(); $this->initializeLegacySessionAccess(); $this->setDefaultLanguage(); // Fully load the configuration $config->getInstance(); $this->validateInstallation(); Input::initialize(); $this->setTimezone(); $this->triggerInitializeSystemHook(); $this->handleRequestToken(); }
/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); define('TL_ROOT', self::$rootDir); System::setContainer($this->mockContainerWithContaoScopes()); }
* Copyright (c) 2005-2015 Leo Feyer * * @license LGPL-3.0+ */ use Contao\ClassLoader; use Contao\Config; use Contao\InstallationBundle\ClassLoader\LibraryLoader; use Contao\InstallationBundle\Controller\InstallationController; use Contao\InstallationBundle\DependencyInjection\ContainerFactory; use Contao\System; error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_USER_DEPRECATED); $loader = (require_once __DIR__ . '/../vendor/autoload.php'); require_once __DIR__ . '/../app/AppKernel.php'; require_once __DIR__ . '/../vendor/contao/core-bundle/src/Resources/contao/config/constants.php'; require_once __DIR__ . '/../vendor/contao/core-bundle/src/Resources/contao/helper/functions.php'; $kernel = new AppKernel('prod', false); // Un-normalize the path (see #208) $rootDir = strtr($kernel->getRootDir(), '/', DIRECTORY_SEPARATOR); // Register the class loader $libraryLoader = new LibraryLoader($rootDir); $libraryLoader->register(); Config::preload(); // Create the container $container = ContainerFactory::create($rootDir); System::setContainer($container); ClassLoader::scanAndRegister(); // Run the controller $controller = new InstallationController(); $controller->setContainer($container); $response = $controller->indexAction(); $response->send();