merged 2.0

This commit is contained in:
Fabien Potencier 2012-08-26 11:32:04 +02:00
commit c29edb5e2e
5 changed files with 121 additions and 15 deletions

View File

@ -47,7 +47,11 @@ class DebugHandler extends TestHandler implements DebugLoggerInterface
public function countErrors()
{
$cnt = 0;
foreach (array(Logger::ERROR, Logger::CRITICAL, Logger::ALERT) as $level) {
$levels = array(Logger::ERROR, Logger::CRITICAL, Logger::ALERT);
if (defined('Monolog\Logger::EMERGENCY')) {
$levels[] = Logger::EMERGENCY;
}
foreach ($levels as $level) {
if (isset($this->recordsByLevel[$level])) {
$cnt += count($this->recordsByLevel[$level]);
}

View File

@ -134,11 +134,15 @@ class ControllerResolverTest extends \PHPUnit_Framework_TestCase
$request->attributes->set('foobar', 'foobar');
$controller = array(new self(), 'controllerMethod3');
try {
$resolver->getArguments($request, $controller);
$this->fail('->getArguments() throws a \RuntimeException exception if it cannot determine the argument value');
} catch (\Exception $e) {
$this->assertInstanceOf('\RuntimeException', $e, '->getArguments() throws a \RuntimeException exception if it cannot determine the argument value');
if (version_compare(PHP_VERSION, '5.3.16', '==')) {
$this->markTestSkipped('PHP 5.3.16 has a major bug in the Reflection sub-system');
} else {
try {
$resolver->getArguments($request, $controller);
$this->fail('->getArguments() throws a \RuntimeException exception if it cannot determine the argument value');
} catch (\Exception $e) {
$this->assertInstanceOf('\RuntimeException', $e, '->getArguments() throws a \RuntimeException exception if it cannot determine the argument value');
}
}
$request = Request::create('/');

View File

@ -293,15 +293,7 @@ EOF;
{
$kernel = new KernelForTest('test', true);
$rootDir = __DIR__.DIRECTORY_SEPARATOR.'Fixtures';
// getRootDir() returns path with slashes
// without conversion test fails on Windows
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
$rootDir = strtr($rootDir, '\\', '/');
}
$this->assertEquals($rootDir, $kernel->getRootDir());
$this->assertEquals(__DIR__.DIRECTORY_SEPARATOR.'Fixtures', realpath($kernel->getRootDir()));
}
public function testGetName()

View File

@ -0,0 +1,45 @@
<?php
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\Exception\InactiveScopeException;
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();
}
}

View File

@ -0,0 +1,61 @@
<?php
/*
* This file is part of the Symfony framework.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Symfony\Tests\Component\Security\Http\Firewall;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Http\Firewall\ContextListener;
class ContextListenerTest extends \PHPUnit_Framework_TestCase
{
/**
* @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')
->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),
);
}
}