merged 2.0
This commit is contained in:
parent
268b618bfe
commit
31536c36ec
|
@ -72,7 +72,7 @@ abstract class FileLoader extends Loader
|
|||
}
|
||||
self::$loading[$resource] = true;
|
||||
|
||||
$ret = $loader->load($resource);
|
||||
$ret = $loader->load($resource, $type);
|
||||
|
||||
unset(self::$loading[$resource]);
|
||||
|
||||
|
|
|
@ -694,7 +694,13 @@ EOF;
|
|||
*/
|
||||
public function __construct()
|
||||
{
|
||||
\$this->parameters = \$this->getDefaultParameters();
|
||||
EOF;
|
||||
|
||||
if ($this->container->getParameterBag()->all()) {
|
||||
$code .= "\n \$this->parameters = \$this->getDefaultParameters();\n";
|
||||
}
|
||||
|
||||
$code .= <<<EOF
|
||||
|
||||
\$this->services =
|
||||
\$this->scopedServices =
|
||||
|
|
|
@ -44,6 +44,20 @@ class PhpDumperTest extends \PHPUnit_Framework_TestCase
|
|||
new PhpDumper($container);
|
||||
}
|
||||
|
||||
public function testDumpFrozenContainerWithNoParameter()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('foo', 'stdClass');
|
||||
|
||||
$container->compile();
|
||||
|
||||
$dumper = new PhpDumper($container);
|
||||
|
||||
$dumpedString = $dumper->dump();
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services11.php', $dumpedString, '->dump() does not add getDefaultParameters() method call if container have no parameters.');
|
||||
$this->assertNotRegexp("/function getDefaultParameters\(/", $dumpedString, '->dump() does not add getDefaultParameters() method definition.');
|
||||
}
|
||||
|
||||
public function testDumpOptimizationString()
|
||||
{
|
||||
$definition = new Definition();
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\DependencyInjection\Exception\InactiveScopeException;
|
||||
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\DependencyInjection\Exception\LogicException;
|
||||
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\DependencyInjection\Parameter;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
|
||||
|
||||
/**
|
||||
* ProjectServiceContainer
|
||||
*
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Dependency Injection Component.
|
||||
*/
|
||||
class ProjectServiceContainer extends Container
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->services =
|
||||
$this->scopedServices =
|
||||
$this->scopeStacks = array();
|
||||
|
||||
$this->set('service_container', $this);
|
||||
|
||||
$this->scopes = array();
|
||||
$this->scopeChildren = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the 'foo' service.
|
||||
*
|
||||
* This service is shared.
|
||||
* This method always returns the same instance of the service.
|
||||
*
|
||||
* @return stdClass A stdClass instance.
|
||||
*/
|
||||
protected function getFooService()
|
||||
{
|
||||
return $this->services['foo'] = new \stdClass();
|
||||
}
|
||||
}
|
|
@ -75,19 +75,26 @@ class ContextListener implements ListenerInterface
|
|||
|
||||
if (null === $session || null === $token = $session->get('_security_'.$this->contextKey)) {
|
||||
$this->context->setToken(null);
|
||||
} else {
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug('Read SecurityContext from the session');
|
||||
}
|
||||
|
||||
$token = unserialize($token);
|
||||
|
||||
if (null !== $token) {
|
||||
$token = $this->refreshUser($token);
|
||||
}
|
||||
|
||||
$this->context->setToken($token);
|
||||
return;
|
||||
}
|
||||
|
||||
$token = unserialize($token);
|
||||
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug('Read SecurityContext from the session');
|
||||
}
|
||||
|
||||
if ($token instanceof TokenInterface) {
|
||||
$token = $this->refreshUser($token);
|
||||
} elseif (null !== $token) {
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->warn(sprintf('Session includes a "%s" where a security token is expected', is_object($value) ? get_class($value) : gettype($value)));
|
||||
}
|
||||
|
||||
$token = null;
|
||||
}
|
||||
|
||||
$this->context->setToken($token);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -125,4 +125,47 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$this->assertFalse($request->hasSession());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideInvalidToken
|
||||
*/
|
||||
public function testInvalidTokenInSession($token)
|
||||
{
|
||||
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$request = $this->getMock('Symfony\Component\HttpFoundation\Request');
|
||||
$session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$event->expects($this->any())
|
||||
->method('getRequest')
|
||||
->will($this->returnValue($request));
|
||||
$request->expects($this->any())
|
||||
->method('hasPreviousSession')
|
||||
->will($this->returnValue(true));
|
||||
$request->expects($this->any())
|
||||
->method('getSession')
|
||||
->will($this->returnValue($session));
|
||||
$session->expects($this->any())
|
||||
->method('get')
|
||||
->with('_security_key123')
|
||||
->will($this->returnValue(serialize($token)));
|
||||
$context->expects($this->once())
|
||||
->method('setToken')
|
||||
->with(null);
|
||||
|
||||
$listener = new ContextListener($context, array(), 'key123');
|
||||
$listener->handle($event);
|
||||
}
|
||||
|
||||
public function provideInvalidToken()
|
||||
{
|
||||
return array(
|
||||
array(new \__PHP_Incomplete_Class()),
|
||||
array(null),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Reference in New Issue