Update to drupal-org-drupal 8.0.0-rc2. For more information, see https://www.drupal.org/node/2598668
This commit is contained in:
parent
f32e58e4b1
commit
8e18df8c36
3062 changed files with 15044 additions and 172506 deletions
|
@ -1,168 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Tests\DependencyInjection;
|
||||
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class ContainerAwareHttpKernelTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getProviderTypes
|
||||
*/
|
||||
public function testHandle($type)
|
||||
{
|
||||
$request = new Request();
|
||||
$expected = new Response();
|
||||
$controller = function () use ($expected) {
|
||||
return $expected;
|
||||
};
|
||||
|
||||
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
||||
$this
|
||||
->expectsEnterScopeOnce($container)
|
||||
->expectsLeaveScopeOnce($container)
|
||||
->expectsSetRequestWithAt($container, $request, 3)
|
||||
->expectsSetRequestWithAt($container, null, 4)
|
||||
;
|
||||
|
||||
$dispatcher = new EventDispatcher();
|
||||
$resolver = $this->getResolverMockFor($controller, $request);
|
||||
$stack = new RequestStack();
|
||||
$kernel = new ContainerAwareHttpKernel($dispatcher, $container, $resolver, $stack);
|
||||
|
||||
$actual = $kernel->handle($request, $type);
|
||||
|
||||
$this->assertSame($expected, $actual, '->handle() returns the response');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getProviderTypes
|
||||
*/
|
||||
public function testVerifyRequestStackPushPopDuringHandle($type)
|
||||
{
|
||||
$request = new Request();
|
||||
$expected = new Response();
|
||||
$controller = function () use ($expected) {
|
||||
return $expected;
|
||||
};
|
||||
|
||||
$stack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack', array('push', 'pop'));
|
||||
$stack->expects($this->at(0))->method('push')->with($this->equalTo($request));
|
||||
$stack->expects($this->at(1))->method('pop');
|
||||
|
||||
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
||||
$dispatcher = new EventDispatcher();
|
||||
$resolver = $this->getResolverMockFor($controller, $request);
|
||||
$kernel = new ContainerAwareHttpKernel($dispatcher, $container, $resolver, $stack);
|
||||
|
||||
$kernel->handle($request, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getProviderTypes
|
||||
*/
|
||||
public function testHandleRestoresThePreviousRequestOnException($type)
|
||||
{
|
||||
$request = new Request();
|
||||
$expected = new \Exception();
|
||||
$controller = function () use ($expected) {
|
||||
throw $expected;
|
||||
};
|
||||
|
||||
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
||||
$this
|
||||
->expectsEnterScopeOnce($container)
|
||||
->expectsLeaveScopeOnce($container)
|
||||
->expectsSetRequestWithAt($container, $request, 3)
|
||||
->expectsSetRequestWithAt($container, null, 4)
|
||||
;
|
||||
|
||||
$dispatcher = new EventDispatcher();
|
||||
$resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
|
||||
$resolver = $this->getResolverMockFor($controller, $request);
|
||||
$stack = new RequestStack();
|
||||
$kernel = new ContainerAwareHttpKernel($dispatcher, $container, $resolver, $stack);
|
||||
|
||||
try {
|
||||
$kernel->handle($request, $type);
|
||||
$this->fail('->handle() suppresses the controller exception');
|
||||
} catch (\PHPUnit_Framework_Exception $e) {
|
||||
throw $e;
|
||||
} catch (\Exception $e) {
|
||||
$this->assertSame($expected, $e, '->handle() throws the controller exception');
|
||||
}
|
||||
}
|
||||
|
||||
public function getProviderTypes()
|
||||
{
|
||||
return array(
|
||||
array(HttpKernelInterface::MASTER_REQUEST),
|
||||
array(HttpKernelInterface::SUB_REQUEST),
|
||||
);
|
||||
}
|
||||
|
||||
private function getResolverMockFor($controller, $request)
|
||||
{
|
||||
$resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
|
||||
$resolver->expects($this->once())
|
||||
->method('getController')
|
||||
->with($request)
|
||||
->will($this->returnValue($controller));
|
||||
$resolver->expects($this->once())
|
||||
->method('getArguments')
|
||||
->with($request, $controller)
|
||||
->will($this->returnValue(array()));
|
||||
|
||||
return $resolver;
|
||||
}
|
||||
|
||||
private function expectsSetRequestWithAt($container, $with, $at)
|
||||
{
|
||||
$container
|
||||
->expects($this->at($at))
|
||||
->method('set')
|
||||
->with($this->equalTo('request'), $this->equalTo($with), $this->equalTo('request'))
|
||||
;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function expectsEnterScopeOnce($container)
|
||||
{
|
||||
$container
|
||||
->expects($this->once())
|
||||
->method('enterScope')
|
||||
->with($this->equalTo('request'))
|
||||
;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function expectsLeaveScopeOnce($container)
|
||||
{
|
||||
$container
|
||||
->expects($this->once())
|
||||
->method('leaveScope')
|
||||
->with($this->equalTo('request'))
|
||||
;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
|
@ -1,160 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Tests\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\FragmentRendererPass;
|
||||
use Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface;
|
||||
|
||||
class FragmentRendererPassTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyFragmentRedererWithoutAlias()
|
||||
{
|
||||
// no alias
|
||||
$services = array(
|
||||
'my_content_renderer' => array(array()),
|
||||
);
|
||||
|
||||
$renderer = $this->getMock('Symfony\Component\DependencyInjection\Definition');
|
||||
$renderer
|
||||
->expects($this->once())
|
||||
->method('addMethodCall')
|
||||
->with('addRenderer', array(new Reference('my_content_renderer')))
|
||||
;
|
||||
|
||||
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
|
||||
$definition->expects($this->atLeastOnce())
|
||||
->method('getClass')
|
||||
->will($this->returnValue('Symfony\Component\HttpKernel\Tests\DependencyInjection\RendererService'));
|
||||
$definition
|
||||
->expects($this->once())
|
||||
->method('isPublic')
|
||||
->will($this->returnValue(true))
|
||||
;
|
||||
|
||||
$builder = $this->getMock(
|
||||
'Symfony\Component\DependencyInjection\ContainerBuilder',
|
||||
array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
|
||||
);
|
||||
$builder->expects($this->any())
|
||||
->method('hasDefinition')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
// We don't test kernel.fragment_renderer here
|
||||
$builder->expects($this->atLeastOnce())
|
||||
->method('findTaggedServiceIds')
|
||||
->will($this->returnValue($services));
|
||||
|
||||
$builder->expects($this->atLeastOnce())
|
||||
->method('getDefinition')
|
||||
->will($this->onConsecutiveCalls($renderer, $definition));
|
||||
|
||||
$pass = new FragmentRendererPass();
|
||||
$pass->process($builder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that content rendering not implementing FragmentRendererInterface
|
||||
* trigger an exception.
|
||||
*
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testContentRendererWithoutInterface()
|
||||
{
|
||||
// one service, not implementing any interface
|
||||
$services = array(
|
||||
'my_content_renderer' => array(array('alias' => 'foo')),
|
||||
);
|
||||
|
||||
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
|
||||
|
||||
$builder = $this->getMock(
|
||||
'Symfony\Component\DependencyInjection\ContainerBuilder',
|
||||
array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
|
||||
);
|
||||
$builder->expects($this->any())
|
||||
->method('hasDefinition')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
// We don't test kernel.fragment_renderer here
|
||||
$builder->expects($this->atLeastOnce())
|
||||
->method('findTaggedServiceIds')
|
||||
->will($this->returnValue($services));
|
||||
|
||||
$builder->expects($this->atLeastOnce())
|
||||
->method('getDefinition')
|
||||
->will($this->returnValue($definition));
|
||||
|
||||
$pass = new FragmentRendererPass();
|
||||
$pass->process($builder);
|
||||
}
|
||||
|
||||
public function testValidContentRenderer()
|
||||
{
|
||||
$services = array(
|
||||
'my_content_renderer' => array(array('alias' => 'foo')),
|
||||
);
|
||||
|
||||
$renderer = $this->getMock('Symfony\Component\DependencyInjection\Definition');
|
||||
$renderer
|
||||
->expects($this->once())
|
||||
->method('addMethodCall')
|
||||
->with('addRendererService', array('foo', 'my_content_renderer'))
|
||||
;
|
||||
|
||||
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
|
||||
$definition->expects($this->atLeastOnce())
|
||||
->method('getClass')
|
||||
->will($this->returnValue('Symfony\Component\HttpKernel\Tests\DependencyInjection\RendererService'));
|
||||
$definition
|
||||
->expects($this->once())
|
||||
->method('isPublic')
|
||||
->will($this->returnValue(true))
|
||||
;
|
||||
|
||||
$builder = $this->getMock(
|
||||
'Symfony\Component\DependencyInjection\ContainerBuilder',
|
||||
array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
|
||||
);
|
||||
$builder->expects($this->any())
|
||||
->method('hasDefinition')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
// We don't test kernel.fragment_renderer here
|
||||
$builder->expects($this->atLeastOnce())
|
||||
->method('findTaggedServiceIds')
|
||||
->will($this->returnValue($services));
|
||||
|
||||
$builder->expects($this->atLeastOnce())
|
||||
->method('getDefinition')
|
||||
->will($this->onConsecutiveCalls($renderer, $definition));
|
||||
|
||||
$pass = new FragmentRendererPass();
|
||||
$pass->process($builder);
|
||||
}
|
||||
}
|
||||
|
||||
class RendererService implements FragmentRendererInterface
|
||||
{
|
||||
public function render($uri, Request $request = null, array $options = array())
|
||||
{
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'test';
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Tests\DependencyInjection;
|
||||
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\LazyLoadingFragmentHandler;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class LazyLoadingFragmentHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
$renderer = $this->getMock('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface');
|
||||
$renderer->expects($this->once())->method('getName')->will($this->returnValue('foo'));
|
||||
$renderer->expects($this->any())->method('render')->will($this->returnValue(new Response()));
|
||||
|
||||
$requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack');
|
||||
$requestStack->expects($this->any())->method('getCurrentRequest')->will($this->returnValue(Request::create('/')));
|
||||
|
||||
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
||||
$container->expects($this->once())->method('get')->will($this->returnValue($renderer));
|
||||
|
||||
$handler = new LazyLoadingFragmentHandler($container, false, $requestStack);
|
||||
$handler->addRendererService('foo', 'foo');
|
||||
|
||||
$handler->render('/foo', 'foo');
|
||||
|
||||
// second call should not lazy-load anymore (see once() above on the get() method)
|
||||
$handler->render('/foo', 'foo');
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Tests\DependencyInjection;
|
||||
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass;
|
||||
|
||||
class MergeExtensionConfigurationPassTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testAutoloadMainExtension()
|
||||
{
|
||||
$container = $this->getMock(
|
||||
'Symfony\\Component\\DependencyInjection\\ContainerBuilder',
|
||||
array('getExtensionConfig', 'loadFromExtension', 'getParameterBag')
|
||||
);
|
||||
$params = $this->getMock('Symfony\\Component\\DependencyInjection\\ParameterBag\\ParameterBag');
|
||||
|
||||
$container->expects($this->at(0))
|
||||
->method('getExtensionConfig')
|
||||
->with('loaded')
|
||||
->will($this->returnValue(array(array())));
|
||||
$container->expects($this->at(1))
|
||||
->method('getExtensionConfig')
|
||||
->with('notloaded')
|
||||
->will($this->returnValue(array()));
|
||||
$container->expects($this->once())
|
||||
->method('loadFromExtension')
|
||||
->with('notloaded', array());
|
||||
|
||||
$container->expects($this->any())
|
||||
->method('getParameterBag')
|
||||
->will($this->returnValue($params));
|
||||
$params->expects($this->any())
|
||||
->method('all')
|
||||
->will($this->returnValue(array()));
|
||||
$container->expects($this->any())
|
||||
->method('getDefinitions')
|
||||
->will($this->returnValue(array()));
|
||||
$container->expects($this->any())
|
||||
->method('getAliases')
|
||||
->will($this->returnValue(array()));
|
||||
$container->expects($this->any())
|
||||
->method('getExtensions')
|
||||
->will($this->returnValue(array()));
|
||||
|
||||
$configPass = new MergeExtensionConfigurationPass(array('loaded', 'notloaded'));
|
||||
$configPass->process($container);
|
||||
}
|
||||
}
|
Reference in a new issue