Contao\CoreBundle\Test\TestCase::mockContainerWithContaoScopes PHP Method

mockContainerWithContaoScopes() protected method

Mocks a container with scopes.
protected mockContainerWithContaoScopes ( string | null $scope = null ) : PHPUnit_Framework_MockObject_MockObject | Symfony\Component\DependencyInjection\Container
$scope string | null
return PHPUnit_Framework_MockObject_MockObject | Symfony\Component\DependencyInjection\Container
    protected function mockContainerWithContaoScopes($scope = null)
    {
        $container = new Container();
        $container->setParameter('kernel.root_dir', $this->getRootDir());
        $container->setParameter('kernel.cache_dir', $this->getCacheDir());
        $container->setParameter('kernel.debug', false);
        $container->setParameter('contao.image.bypass_cache', false);
        $container->setParameter('contao.image.target_path', 'assets/images');
        $container->setParameter('contao.image.valid_extensions', ['jpg', 'svg', 'svgz']);
        $container->setParameter('contao.image.imagine_options', ['jpeg_quality' => 80, 'interlace' => ImageInterface::INTERLACE_PLANE]);
        $container->set('contao.resource_finder', new ResourceFinder($this->getRootDir() . '/vendor/contao/test-bundle/Resources/contao'));
        $container->set('contao.resource_locator', new FileLocator($this->getRootDir() . '/vendor/contao/test-bundle/Resources/contao'));
        $request = new Request();
        $request->server->set('REMOTE_ADDR', '123.456.789.0');
        $request->server->set('SCRIPT_NAME', '/core/index.php');
        if (null !== $scope) {
            $request->attributes->set('_scope', $scope);
        }
        $requestStack = new RequestStack();
        $requestStack->push($request);
        $container->set('request_stack', $requestStack);
        $container->set('session', $this->mockSession());
        $container->set('monolog.logger.contao', new NullLogger());
        return $container;
    }