fixed various inconsistencies

This commit is contained in:
Fabien Potencier 2014-02-11 08:51:18 +01:00
parent f964cc8474
commit eb3f6c6efb
59 changed files with 143 additions and 145 deletions

View File

@ -92,7 +92,8 @@ class EntityUserProvider implements UserProviderInterface
);
}
if (null === $refreshedUser = $this->repository->find($id)) {
$refreshedUser = $this->repository->find($id);
if (null === $refreshedUser) {
throw new UsernameNotFoundException(sprintf('User with id %s not found', json_encode($id)));
}
}

View File

@ -11,7 +11,7 @@
namespace Symfony\Bridge\Doctrine\Tests\Fixtures;
use Doctrine\ORM\Mapping AS ORM;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity

View File

@ -22,7 +22,7 @@ class CompilerDebugDumpPass implements CompilerPassInterface
{
$filesystem = new Filesystem();
$filesystem->dumpFile(
$this->getCompilerLogFilename($container),
self::getCompilerLogFilename($container),
implode("\n", $container->getCompiler()->getLog()),
0666 & ~umask()
);

View File

@ -37,7 +37,7 @@ class TemplateFinderTest extends TestCase
->will($this->returnValue(array('BaseBundle' => new BaseBundle())))
;
$parser = new TemplateFilenameParser($kernel);
$parser = new TemplateFilenameParser();
$finder = new TemplateFinder($kernel, $parser, __DIR__.'/../Fixtures/Resources');

View File

@ -33,7 +33,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
public function testValidTrustedProxies($trustedProxies, $processedProxies)
{
$processor = new Processor();
$configuration = new Configuration(array());
$configuration = new Configuration();
$config = $processor->processConfiguration($configuration, array(array(
'secret' => 's3cr3t',
'trusted_proxies' => $trustedProxies
@ -62,7 +62,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
public function testInvalidTypeTrustedProxies()
{
$processor = new Processor();
$configuration = new Configuration(array());
$configuration = new Configuration();
$processor->processConfiguration($configuration, array(
array(
'secret' => 's3cr3t',
@ -77,7 +77,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
public function testInvalidValueTrustedProxies()
{
$processor = new Processor();
$configuration = new Configuration(array());
$configuration = new Configuration();
$processor->processConfiguration($configuration, array(
array(
'secret' => 's3cr3t',

View File

@ -46,7 +46,7 @@ class WebTestCase extends BaseWebTestCase
{
require_once __DIR__.'/app/AppKernel.php';
return 'Symfony\Bundle\FrameworkBundle\Tests\Functional\AppKernel';
return 'Symfony\Bundle\FrameworkBundle\Tests\Functional\app\AppKernel';
}
protected static function createKernel(array $options = array())

View File

@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\app;
// get the autoload file
$dir = __DIR__;

View File

@ -46,7 +46,7 @@ class WebTestCase extends BaseWebTestCase
{
require_once __DIR__.'/app/AppKernel.php';
return 'Symfony\Bundle\SecurityBundle\Tests\Functional\AppKernel';
return 'Symfony\Bundle\SecurityBundle\Tests\Functional\app\AppKernel';
}
protected static function createKernel(array $options = array())

View File

@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\SecurityBundle\Tests\Functional;
namespace Symfony\Bundle\SecurityBundle\Tests\Functional\app;
// get the autoload file
$dir = __DIR__;

View File

@ -22,7 +22,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
public function testConfigTree($options, $results)
{
$processor = new Processor();
$configuration = new Configuration(array());
$configuration = new Configuration();
$config = $processor->processConfiguration($configuration, array($options));
$this->assertEquals($results, $config);

View File

@ -116,7 +116,8 @@ class XcacheClassLoader
if (xcache_isset($this->prefix.$class)) {
$file = xcache_get($this->prefix.$class);
} else {
xcache_set($this->prefix.$class, $file = $this->classFinder->findFile($class));
$file = $this->classFinder->findFile($class);
xcache_set($this->prefix.$class, $file);
}
return $file;

View File

@ -352,7 +352,7 @@ class ProgressHelper extends Helper
$vars = array();
$percent = 0;
if ($this->max > 0) {
$percent = (double) $this->current / $this->max;
$percent = (float) $this->current / $this->max;
}
if (isset($this->formatVars['bar'])) {

View File

@ -417,7 +417,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
public function testAsText()
{
$application = new Application();
$application->add(new \FooCommand);
$application->add(new \FooCommand());
$this->ensureStaticCommandHelp($application);
$this->assertStringEqualsFile(self::$fixturesPath.'/application_astext1.txt', $this->normalizeLineBreaks($application->asText()), '->asText() returns a text representation of the application');
$this->assertStringEqualsFile(self::$fixturesPath.'/application_astext2.txt', $this->normalizeLineBreaks($application->asText('foo')), '->asText() returns a text representation of the application');
@ -426,7 +426,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
public function testAsXml()
{
$application = new Application();
$application->add(new \FooCommand);
$application->add(new \FooCommand());
$this->ensureStaticCommandHelp($application);
$this->assertXmlStringEqualsXmlFile(self::$fixturesPath.'/application_asxml1.txt', $application->asXml(), '->asXml() returns an XML representation of the application');
$this->assertXmlStringEqualsXmlFile(self::$fixturesPath.'/application_asxml2.txt', $application->asXml('foo'), '->asXml() returns an XML representation of the application');
@ -450,7 +450,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
$tester->run(array('command' => 'list', '--foo' => true), array('decorated' => false));
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception2.txt', $tester->getDisplay(true), '->renderException() renders the command synopsis when an exception occurs in the context of a command');
$application->add(new \Foo3Command);
$application->add(new \Foo3Command());
$tester = new ApplicationTester($application);
$tester->run(array('command' => 'foo3:bar'), array('decorated' => false));
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions');
@ -797,7 +797,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
protected function getDispatcher()
{
$dispatcher = new EventDispatcher;
$dispatcher = new EventDispatcher();
$dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) {
$event->getOutput()->write('before.');
});

View File

@ -14,7 +14,6 @@ namespace Symfony\Component\CssSelector\Tests\Parser\Handler;
use Symfony\Component\CssSelector\Parser\Handler\NumberHandler;
use Symfony\Component\CssSelector\Parser\Token;
use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns;
use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping;
class NumberHandlerTest extends AbstractHandlerTest
{
@ -46,6 +45,6 @@ class NumberHandlerTest extends AbstractHandlerTest
{
$patterns = new TokenizerPatterns();
return new NumberHandler($patterns, new TokenizerEscaping($patterns));
return new NumberHandler($patterns);
}
}

View File

@ -64,6 +64,6 @@ class ExceptionHandlerTest extends \PHPUnit_Framework_TestCase
public function testNestedExceptions()
{
$handler = new ExceptionHandler(true);
$response = $handler->createResponse(new \RuntimeException('Foo', null, new \RuntimeException('Bar')));
$response = $handler->createResponse(new \RuntimeException('Foo', 0, new \RuntimeException('Bar')));
}
}

View File

@ -66,7 +66,7 @@ class PhpDumper extends Dumper
{
parent::__construct($container);
$this->inlinedDefinitions = new \SplObjectStorage;
$this->inlinedDefinitions = new \SplObjectStorage();
}
/**

View File

@ -238,6 +238,7 @@ class EventDispatcherTest extends \PHPUnit_Framework_TestCase
public function testEventReceivesTheDispatcherInstance()
{
$test = $this;
$dispatcher = null;
$this->dispatcher->addListener('test', function ($event) use (&$dispatcher) {
$dispatcher = $event->getDispatcher();
});

View File

@ -35,7 +35,7 @@ class EventTest extends \PHPUnit_Framework_TestCase
*/
protected function setUp()
{
$this->event = new Event;
$this->event = new Event();
$this->dispatcher = new EventDispatcher();
}

View File

@ -19,14 +19,11 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
class DependencyInjectionExtension implements FormExtensionInterface
{
private $container;
private $typeServiceIds;
private $guesserServiceIds;
private $guesser;
private $guesserLoaded = false;
private $typeExtensionServiceIds;
public function __construct(ContainerInterface $container,
array $typeServiceIds, array $typeExtensionServiceIds,

View File

@ -55,7 +55,7 @@ abstract class FormPerformanceTestCase extends FormIntegrationTestCase
if (is_integer($maxRunningTime) && $maxRunningTime >= 0) {
$this->maxRunningTime = $maxRunningTime;
} else {
throw new \InvalidArgumentException;
throw new \InvalidArgumentException();
}
}

View File

@ -27,12 +27,12 @@ class FormFactoryBuilderTest extends \PHPUnit_Framework_TestCase
$this->registry->setAccessible(true);
$this->guesser = $this->getMock('Symfony\Component\Form\FormTypeGuesserInterface');
$this->type = new FooType;
$this->type = new FooType();
}
public function testAddType()
{
$factoryBuilder = new FormFactoryBuilder;
$factoryBuilder = new FormFactoryBuilder();
$factoryBuilder->addType($this->type);
$factory = $factoryBuilder->getFormFactory();
@ -46,7 +46,7 @@ class FormFactoryBuilderTest extends \PHPUnit_Framework_TestCase
public function testAddTypeGuesser()
{
$factoryBuilder = new FormFactoryBuilder;
$factoryBuilder = new FormFactoryBuilder();
$factoryBuilder->addTypeGuesser($this->guesser);
$factory = $factoryBuilder->getFormFactory();

View File

@ -82,18 +82,15 @@ class ExtensionGuesser implements ExtensionGuesserInterface
* value.
*
* @param string $mimeType The mime type
*
* @return string The guessed extension or NULL, if none could be guessed
*/
public function guess($mimeType)
{
foreach ($this->guessers as $guesser) {
$extension = $guesser->guess($mimeType);
if (null !== $extension) {
break;
if (null !== $extension = $guesser->guess($mimeType)) {
return $extension;
}
}
return $extension;
}
}

View File

@ -881,14 +881,14 @@ class RequestTest extends \PHPUnit_Framework_TestCase
public function testGetContentWorksTwiceInDefaultMode()
{
$req = new Request;
$req = new Request();
$this->assertEquals('', $req->getContent());
$this->assertEquals('', $req->getContent());
}
public function testGetContentReturnsResource()
{
$req = new Request;
$req = new Request();
$retval = $req->getContent(true);
$this->assertInternalType('resource', $retval);
$this->assertEquals("", fread($retval, 1));
@ -901,7 +901,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
*/
public function testGetContentCantBeCalledTwiceWithResources($first, $second)
{
$req = new Request;
$req = new Request();
$req->getContent($first);
$req->getContent($second);
}
@ -1339,7 +1339,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
*/
public function testUrlencodedStringPrefix($string, $prefix, $expect)
{
$request = new Request;
$request = new Request();
$me = new \ReflectionMethod($request, 'getUrlencodedPrefix');
$me->setAccessible(true);

View File

@ -652,7 +652,7 @@ class ResponseTest extends ResponseTestCase
'setCharset' => 'UTF-8',
'setPublic' => null,
'setPrivate' => null,
'setDate' => new \DateTime,
'setDate' => new \DateTime(),
'expire' => null,
'setMaxAge' => 1,
'setSharedMaxAge' => 1,

View File

@ -59,7 +59,7 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase
protected function getStorage(array $options = array())
{
$storage = new NativeSessionStorage($options);
$storage->registerBag(new AttributeBag);
$storage->registerBag(new AttributeBag());
return $storage;
}
@ -158,7 +158,7 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase
public function testSetSaveHandlerException()
{
$storage = $this->getStorage();
$storage->setSaveHandler(new \stdClass);
$storage->setSaveHandler(new \stdClass());
}
public function testSetSaveHandler53()

View File

@ -53,7 +53,7 @@ class PhpBridgeSessionStorageTest extends \PHPUnit_Framework_TestCase
protected function getStorage()
{
$storage = new PhpBridgeSessionStorage();
$storage->registerBag(new AttributeBag);
$storage->registerBag(new AttributeBag());
return $storage;
}

View File

@ -70,7 +70,7 @@ class ControllerResolver implements ControllerResolverInterface
if (false === strpos($controller, ':')) {
if (method_exists($controller, '__invoke')) {
return new $controller;
return new $controller();
} elseif (function_exists($controller)) {
return $controller;
}

View File

@ -42,7 +42,7 @@ class MemcacheProfilerStorage extends BaseMemcacheProfilerStorage
$host = $matches[1] ?: $matches[2];
$port = $matches[3];
$memcache = new Memcache;
$memcache = new Memcache();
$memcache->addServer($host, $port);
$this->memcache = $memcache;

View File

@ -42,7 +42,7 @@ class MemcachedProfilerStorage extends BaseMemcacheProfilerStorage
$host = $matches[1] ?: $matches[2];
$port = $matches[3];
$memcached = new Memcached;
$memcached = new Memcached();
//disable compression to allow appending
$memcached->setOption(Memcached::OPT_COMPRESSION, false);

View File

@ -214,7 +214,7 @@ class RedisProfilerStorage implements ProfilerStorageInterface
throw new \RuntimeException('RedisProfilerStorage requires that the redis extension is loaded.');
}
$redis = new \Redis;
$redis = new \Redis();
$redis->connect($data['host'], $data['port']);
if (isset($data['path'])) {

View File

@ -121,6 +121,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
new UploadedFile($source, 'original', 'mime/original', 123, UPLOAD_ERR_OK, true),
);
$file = null;
foreach ($files as $file) {
$client->request('POST', '/', array(), array('foo' => $file));

View File

@ -26,7 +26,7 @@ class TimeDataCollectorTest extends \PHPUnit_Framework_TestCase
public function testCollect()
{
$c = new TimeDataCollector;
$c = new TimeDataCollector();
$request = new Request();
$request->server->set('REQUEST_TIME', 1);
@ -42,7 +42,7 @@ class TimeDataCollectorTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(2000, $c->getStartTime());
$request = new Request();
$c->collect($request, new Response);
$c->collect($request, new Response());
$this->assertEquals(0, $c->getStartTime());
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');

View File

@ -347,6 +347,7 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
{
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$attributeRet = null;
if (null !== $fractionDigits) {
$attributeRet = $formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, $fractionDigits);
}
@ -355,7 +356,7 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
$this->assertSame($expected, $formattedValue);
$this->assertSame($expectedFractionDigits, $formatter->getAttribute(NumberFormatter::FRACTION_DIGITS));
if (isset($attributeRet)) {
if (null !== $attributeRet) {
$this->assertTrue($attributeRet);
}
}
@ -379,6 +380,7 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
{
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$attributeRet = null;
if (null !== $groupingUsed) {
$attributeRet = $formatter->setAttribute(NumberFormatter::GROUPING_USED, $groupingUsed);
}
@ -387,7 +389,7 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
$this->assertSame($expected, $formattedValue);
$this->assertSame($expectedGroupingUsed, $formatter->getAttribute(NumberFormatter::GROUPING_USED));
if (isset($attributeRet)) {
if (null !== $attributeRet) {
$this->assertTrue($attributeRet);
}
}

View File

@ -25,7 +25,7 @@ function handleSignal($signal)
echo "received signal $name\n";
}
declare(ticks=1);
declare(ticks = 1);
pcntl_signal(SIGTERM, 'handleSignal');
pcntl_signal(SIGINT, 'handleSignal');

View File

@ -31,17 +31,16 @@ class AnnotationFileLoader extends FileLoader
*
* @param FileLocatorInterface $locator A FileLocator instance
* @param AnnotationClassLoader $loader An AnnotationClassLoader instance
* @param string|array $paths A path or an array of paths where to look for resources
*
* @throws \RuntimeException
*/
public function __construct(FileLocatorInterface $locator, AnnotationClassLoader $loader, $paths = array())
public function __construct(FileLocatorInterface $locator, AnnotationClassLoader $loader)
{
if (!function_exists('token_get_all')) {
throw new \RuntimeException('The Tokenizer extension is required for the routing annotation loaders.');
}
parent::__construct($locator, $paths);
parent::__construct($locator);
$this->loader = $loader;
}

View File

@ -20,7 +20,7 @@ class DumperPrefixCollectionTest extends \PHPUnit_Framework_TestCase
{
public function testAddPrefixRoute()
{
$coll = new DumperPrefixCollection;
$coll = new DumperPrefixCollection();
$coll->setPrefix('');
$route = new DumperRoute('bar', new Route('/foo/bar'));
@ -66,7 +66,7 @@ EOF;
public function testMergeSlashNodes()
{
$coll = new DumperPrefixCollection;
$coll = new DumperPrefixCollection();
$coll->setPrefix('');
$route = new DumperRoute('bar', new Route('/foo/bar'));

View File

@ -76,7 +76,7 @@ class MaskBuilderTest extends \PHPUnit_Framework_TestCase
public function testGetPattern()
{
$builder = new MaskBuilder;
$builder = new MaskBuilder();
$this->assertEquals(MaskBuilder::ALL_OFF, $builder->getPattern());
$builder->add('view');

View File

@ -115,7 +115,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
->method('isPasswordValid')
;
$provider = $this->getProvider(false, false, $encoder);
$provider = $this->getProvider(null, null, $encoder);
$method = new \ReflectionMethod($provider, 'checkAuthentication');
$method->setAccessible(true);
@ -142,7 +142,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue(true))
;
$provider = $this->getProvider(false, false, $encoder);
$provider = $this->getProvider(null, null, $encoder);
$method = new \ReflectionMethod($provider, 'checkAuthentication');
$method->setAccessible(true);
@ -171,7 +171,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue(false))
;
$provider = $this->getProvider(false, false, $encoder);
$provider = $this->getProvider(null, null, $encoder);
$method = new \ReflectionMethod($provider, 'checkAuthentication');
$method->setAccessible(true);
@ -206,7 +206,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue('newFoo'))
;
$provider = $this->getProvider(false, false, null);
$provider = $this->getProvider();
$reflection = new \ReflectionMethod($provider, 'checkAuthentication');
$reflection->setAccessible(true);
$reflection->invoke($provider, $dbUser, $token);
@ -231,7 +231,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue('foo'))
;
$provider = $this->getProvider(false, false, null);
$provider = $this->getProvider();
$reflection = new \ReflectionMethod($provider, 'checkAuthentication');
$reflection->setAccessible(true);
$reflection->invoke($provider, $dbUser, $token);
@ -245,7 +245,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue(true))
;
$provider = $this->getProvider(false, false, $encoder);
$provider = $this->getProvider(null, null, $encoder);
$method = new \ReflectionMethod($provider, 'checkAuthentication');
$method->setAccessible(true);
@ -270,17 +270,17 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
return $mock;
}
protected function getProvider($user = false, $userChecker = false, $passwordEncoder = null)
protected function getProvider($user = null, $userChecker = null, $passwordEncoder = null)
{
$userProvider = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface');
if (false !== $user) {
if (null !== $user) {
$userProvider->expects($this->once())
->method('loadUserByUsername')
->will($this->returnValue($user))
;
}
if (false === $userChecker) {
if (null === $userChecker) {
$userChecker = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface');
}

View File

@ -114,17 +114,17 @@ class PreAuthenticatedAuthenticationProviderTest extends \PHPUnit_Framework_Test
return $token;
}
protected function getProvider($user = false, $userChecker = false)
protected function getProvider($user = null, $userChecker = null)
{
$userProvider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface');
if (false !== $user) {
if (null !== $user) {
$userProvider->expects($this->once())
->method('loadUserByUsername')
->will($this->returnValue($user))
;
}
if (false === $userChecker) {
if (null === $userChecker) {
$userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
}

View File

@ -111,8 +111,8 @@ class SecureRandomTest extends \PHPUnit_Framework_TestCase
{
$b = $this->getBitSequence($secureRandom, 20000);
$longestRun = 0;
$currentRun = $lastBit = null;
$longestRun = $currentRun = 0;
$lastBit = null;
for ($i = 0; $i < 20000; $i++) {
if ($lastBit === $b[$i]) {
$currentRun += 1;

View File

@ -50,7 +50,7 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase
public function testAutoLoginThrowsExceptionWhenImplementationDoesNotReturnUserInterface()
{
$service = $this->getService(null, array('name' => 'foo', 'path' => null, 'domain' => null));
$request = new Request;
$request = new Request();
$request->cookies->set('foo', 'foo');
$service
@ -113,8 +113,8 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase
public function testLoginSuccessIsNotProcessedWhenTokenDoesNotContainUserInterfaceImplementation()
{
$service = $this->getService(null, array('name' => 'foo', 'always_remember_me' => true, 'path' => null, 'domain' => null));
$request = new Request;
$response = new Response;
$request = new Request();
$response = new Response();
$account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
$token
@ -136,8 +136,8 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase
public function testLoginSuccessIsNotProcessedWhenRememberMeIsNotRequested()
{
$service = $this->getService(null, array('name' => 'foo', 'always_remember_me' => false, 'remember_me_parameter' => 'foo', 'path' => null, 'domain' => null));
$request = new Request;
$response = new Response;
$request = new Request();
$response = new Response();
$account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
$token
@ -160,8 +160,8 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase
public function testLoginSuccessWhenRememberMeAlwaysIsTrue()
{
$service = $this->getService(null, array('name' => 'foo', 'always_remember_me' => true, 'path' => null, 'domain' => null));
$request = new Request;
$response = new Response;
$request = new Request();
$response = new Response();
$account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
$token
@ -186,9 +186,9 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase
{
$service = $this->getService(null, array('name' => 'foo', 'always_remember_me' => false, 'remember_me_parameter' => 'foo[bar]', 'path' => null, 'domain' => null));
$request = new Request;
$request = new Request();
$request->request->set('foo', array('bar' => $value));
$response = new Response;
$response = new Response();
$account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
$token
@ -213,9 +213,9 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase
{
$service = $this->getService(null, array('name' => 'foo', 'always_remember_me' => false, 'remember_me_parameter' => 'foo', 'path' => null, 'domain' => null));
$request = new Request;
$request = new Request();
$request->request->set('foo', $value);
$response = new Response;
$response = new Response();
$account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
$token

View File

@ -43,7 +43,7 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test
public function testAutoLoginThrowsExceptionOnInvalidCookie()
{
$service = $this->getService(null, array('name' => 'foo', 'path' => null, 'domain' => null, 'always_remember_me' => false, 'remember_me_parameter' => 'foo'));
$request = new Request;
$request = new Request();
$request->request->set('foo', 'true');
$request->cookies->set('foo', 'foo');
@ -54,7 +54,7 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test
public function testAutoLoginThrowsExceptionOnNonExistentToken()
{
$service = $this->getService(null, array('name' => 'foo', 'path' => null, 'domain' => null, 'always_remember_me' => false, 'remember_me_parameter' => 'foo'));
$request = new Request;
$request = new Request();
$request->request->set('foo', 'true');
$request->cookies->set('foo', $this->encodeCookie(array(
$series = 'fooseries',
@ -77,7 +77,7 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test
{
$userProvider = $this->getProvider();
$service = $this->getService($userProvider, array('name' => 'foo', 'path' => null, 'domain' => null, 'always_remember_me' => true, 'lifetime' => 3600, 'secure' => false, 'httponly' => false));
$request = new Request;
$request = new Request();
$request->cookies->set('foo', $this->encodeCookie(array('fooseries', 'foovalue')));
$tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface');
@ -102,7 +102,7 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test
{
$userProvider = $this->getProvider();
$service = $this->getService($userProvider, array('name' => 'foo', 'path' => null, 'domain' => null, 'always_remember_me' => true));
$request = new Request;
$request = new Request();
$request->cookies->set('foo', $this->encodeCookie(array('fooseries', 'foovalue')));
$tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface');
@ -132,7 +132,7 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test
public function testAutoLoginDoesNotAcceptAnExpiredCookie()
{
$service = $this->getService(null, array('name' => 'foo', 'path' => null, 'domain' => null, 'always_remember_me' => true, 'lifetime' => 3600));
$request = new Request;
$request = new Request();
$request->cookies->set('foo', $this->encodeCookie(array('fooseries', 'foovalue')));
$tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface');
@ -166,7 +166,7 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test
;
$service = $this->getService($userProvider, array('name' => 'foo', 'path' => null, 'domain' => null, 'secure' => false, 'httponly' => false, 'always_remember_me' => true, 'lifetime' => 3600));
$request = new Request;
$request = new Request();
$request->cookies->set('foo', $this->encodeCookie(array('fooseries', 'foovalue')));
$tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface');
@ -214,8 +214,8 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test
public function testLogoutSimplyIgnoresNonSetRequestCookie()
{
$service = $this->getService(null, array('name' => 'foo', 'path' => null, 'domain' => null));
$request = new Request;
$response = new Response;
$request = new Request();
$response = new Response();
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
$tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface');
@ -236,9 +236,9 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test
public function testLogoutSimplyIgnoresInvalidCookie()
{
$service = $this->getService(null, array('name' => 'foo', 'path' => null, 'domain' => null));
$request = new Request;
$request = new Request();
$request->cookies->set('foo', 'somefoovalue');
$response = new Response;
$response = new Response();
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
$tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface');
@ -266,8 +266,8 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test
public function testLoginSuccessSetsCookieWhenLoggedInWithNonRememberMeTokenInterfaceImplementation()
{
$service = $this->getService(null, array('name' => 'foo', 'domain' => 'myfoodomain.foo', 'path' => '/foo/path', 'secure' => true, 'httponly' => true, 'lifetime' => 3600, 'always_remember_me' => true));
$request = new Request;
$response = new Response;
$request = new Request();
$response = new Response();
$account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
$account

View File

@ -56,7 +56,7 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
{
$listener = new ResponseListener();
$this->assertSame(array(KernelEvents::RESPONSE => 'onKernelResponse'), $listener->getSubscribedEvents());
$this->assertSame(array(KernelEvents::RESPONSE => 'onKernelResponse'), ResponseListener::getSubscribedEvents());
}
private function getRequest(array $attributes = array())

View File

@ -39,7 +39,7 @@ class TokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase
public function testAutoLoginThrowsExceptionOnInvalidCookie()
{
$service = $this->getService(null, array('name' => 'foo', 'path' => null, 'domain' => null, 'always_remember_me' => false, 'remember_me_parameter' => 'foo'));
$request = new Request;
$request = new Request();
$request->request->set('foo', 'true');
$request->cookies->set('foo', 'foo');
@ -51,7 +51,7 @@ class TokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase
{
$userProvider = $this->getProvider();
$service = $this->getService($userProvider, array('name' => 'foo', 'path' => null, 'domain' => null, 'always_remember_me' => true, 'lifetime' => 3600));
$request = new Request;
$request = new Request();
$request->cookies->set('foo', $this->getCookie('fooclass', 'foouser', time()+3600, 'foopass'));
$userProvider
@ -68,7 +68,7 @@ class TokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase
{
$userProvider = $this->getProvider();
$service = $this->getService($userProvider, array('name' => 'foo', 'path' => null, 'domain' => null, 'always_remember_me' => true, 'lifetime' => 3600));
$request = new Request;
$request = new Request();
$request->cookies->set('foo', base64_encode('class:'.base64_encode('foouser').':123456789:fooHash'));
$user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
@ -93,7 +93,7 @@ class TokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase
{
$userProvider = $this->getProvider();
$service = $this->getService($userProvider, array('name' => 'foo', 'path' => null, 'domain' => null, 'always_remember_me' => true, 'lifetime' => 3600));
$request = new Request;
$request = new Request();
$request->cookies->set('foo', $this->getCookie('fooclass', 'foouser', time() - 1, 'foopass'));
$user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
@ -137,7 +137,7 @@ class TokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase
;
$service = $this->getService($userProvider, array('name' => 'foo', 'always_remember_me' => true, 'lifetime' => 3600));
$request = new Request;
$request = new Request();
$request->cookies->set('foo', $this->getCookie('fooclass', 'foouser', time()+3600, 'foopass'));
$returnedToken = $service->autoLogin($request);
@ -179,8 +179,8 @@ class TokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase
public function testLoginSuccessIgnoresTokensWhichDoNotContainAnUserInterfaceImplementation()
{
$service = $this->getService(null, array('name' => 'foo', 'always_remember_me' => true, 'path' => null, 'domain' => null));
$request = new Request;
$response = new Response;
$request = new Request();
$response = new Response();
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
$token
->expects($this->once())
@ -200,8 +200,8 @@ class TokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase
public function testLoginSuccess()
{
$service = $this->getService(null, array('name' => 'foo', 'domain' => 'myfoodomain.foo', 'path' => '/foo/path', 'secure' => true, 'httponly' => true, 'lifetime' => 3600, 'always_remember_me' => true));
$request = new Request;
$response = new Response;
$request = new Request();
$response = new Response();
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
$user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');

View File

@ -29,7 +29,7 @@ class CustomNormalizer extends SerializerAwareNormalizer implements NormalizerIn
*/
public function denormalize($data, $class, $format = null, array $context = array())
{
$object = new $class;
$object = new $class();
$object->denormalize($this->serializer, $data, $format, $context);
return $object;

View File

@ -19,13 +19,13 @@ class JsonEncoderTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
$this->encoder = new JsonEncoder;
$this->encoder = new JsonEncoder();
$this->serializer = new Serializer(array(new CustomNormalizer()), array('json' => new JsonEncoder()));
}
public function testEncodeScalar()
{
$obj = new \stdClass;
$obj = new \stdClass();
$obj->foo = "foo";
$expected = '{"foo":"foo"}';
@ -68,7 +68,7 @@ class JsonEncoderTest extends \PHPUnit_Framework_TestCase
protected function getObject()
{
$obj = new \stdClass;
$obj = new \stdClass();
$obj->foo = 'foo';
$obj->bar = array('a', 'b');
$obj->baz = array('key' => 'val', 'key2' => 'val', 'A B' => 'bar', 'item' => array(array('title' => 'title1'), array('title' => 'title2')), 'Barry' => array('FooBar' => array('Baz' => 'Ed', '@id' => 1)));

View File

@ -24,14 +24,14 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->encoder = new XmlEncoder;
$this->encoder = new XmlEncoder();
$serializer = new Serializer(array(new CustomNormalizer()), array('xml' => new XmlEncoder()));
$this->encoder->setSerializer($serializer);
}
public function testEncodeScalar()
{
$obj = new ScalarDummy;
$obj = new ScalarDummy();
$obj->xmlFoo = "foo";
$expected = '<?xml version="1.0"?>'."\n".
@ -42,7 +42,7 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase
public function testSetRootNodeName()
{
$obj = new ScalarDummy;
$obj = new ScalarDummy();
$obj->xmlFoo = "foo";
$this->encoder->setRootNodeName('test');
@ -63,7 +63,7 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase
public function testAttributes()
{
$obj = new ScalarDummy;
$obj = new ScalarDummy();
$obj->xmlFoo = array(
'foo-bar' => array(
'@id' => 1,
@ -92,7 +92,7 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase
public function testElementNameValid()
{
$obj = new ScalarDummy;
$obj = new ScalarDummy();
$obj->xmlFoo = array(
'foo-bar' => 'a',
'foo_bar' => 'a',
@ -345,7 +345,7 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase
protected function getObject()
{
$obj = new Dummy;
$obj = new Dummy();
$obj->foo = 'foo';
$obj->bar = array('a', 'b');
$obj->baz = array('key' => 'val', 'key2' => 'val', 'A B' => 'bar', 'item' => array(array('title' => 'title1'), array('title' => 'title2')), 'Barry' => array('FooBar' => array('Baz' => 'Ed', '@id' => 1)));

View File

@ -19,13 +19,13 @@ class CustomNormalizerTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
$this->normalizer = new CustomNormalizer;
$this->normalizer->setSerializer(new Serializer);
$this->normalizer = new CustomNormalizer();
$this->normalizer->setSerializer(new Serializer());
}
public function testSerialize()
{
$obj = new ScalarDummy;
$obj = new ScalarDummy();
$obj->foo = 'foo';
$obj->xmlFoo = 'xml';
$this->assertEquals('foo', $this->normalizer->normalize($obj, 'json'));
@ -34,19 +34,19 @@ class CustomNormalizerTest extends \PHPUnit_Framework_TestCase
public function testDeserialize()
{
$obj = $this->normalizer->denormalize('foo', get_class(new ScalarDummy), 'xml');
$obj = $this->normalizer->denormalize('foo', get_class(new ScalarDummy()), 'xml');
$this->assertEquals('foo', $obj->xmlFoo);
$this->assertNull($obj->foo);
$obj = $this->normalizer->denormalize('foo', get_class(new ScalarDummy), 'json');
$obj = $this->normalizer->denormalize('foo', get_class(new ScalarDummy()), 'json');
$this->assertEquals('foo', $obj->foo);
$this->assertNull($obj->xmlFoo);
}
public function testSupportsNormalization()
{
$this->assertTrue($this->normalizer->supportsNormalization(new ScalarDummy));
$this->assertFalse($this->normalizer->supportsNormalization(new \stdClass));
$this->assertTrue($this->normalizer->supportsNormalization(new ScalarDummy()));
$this->assertFalse($this->normalizer->supportsNormalization(new \stdClass()));
}
public function testSupportsDenormalization()

View File

@ -17,13 +17,13 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
$this->normalizer = new GetSetMethodNormalizer;
$this->normalizer = new GetSetMethodNormalizer();
$this->normalizer->setSerializer($this->getMock('Symfony\Component\Serializer\Serializer'));
}
public function testNormalize()
{
$obj = new GetSetDummy;
$obj = new GetSetDummy();
$obj->setFoo('foo');
$obj->setBar('bar');
$obj->setCamelCase('camelcase');
@ -118,7 +118,7 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase
{
$this->normalizer->setIgnoredAttributes(array('foo', 'bar', 'camelCase'));
$obj = new GetSetDummy;
$obj = new GetSetDummy();
$obj->setFoo('foo');
$obj->setBar('bar');

View File

@ -28,20 +28,20 @@ class SerializerTest extends \PHPUnit_Framework_TestCase
public function testNormalizeNoMatch()
{
$this->serializer = new Serializer(array($this->getMock('Symfony\Component\Serializer\Normalizer\CustomNormalizer')));
$this->serializer->normalize(new \stdClass, 'xml');
$this->serializer->normalize(new \stdClass(), 'xml');
}
public function testNormalizeTraversable()
{
$this->serializer = new Serializer(array(), array('json' => new JsonEncoder()));
$result = $this->serializer->serialize(new TraversableDummy, 'json');
$result = $this->serializer->serialize(new TraversableDummy(), 'json');
$this->assertEquals('{"foo":"foo","bar":"bar"}', $result);
}
public function testNormalizeGivesPriorityToInterfaceOverTraversable()
{
$this->serializer = new Serializer(array(new CustomNormalizer), array('json' => new JsonEncoder()));
$result = $this->serializer->serialize(new NormalizableTraversableDummy, 'json');
$this->serializer = new Serializer(array(new CustomNormalizer()), array('json' => new JsonEncoder()));
$result = $this->serializer->serialize(new NormalizableTraversableDummy(), 'json');
$this->assertEquals('{"foo":"normalizedFoo","bar":"normalizedBar"}', $result);
}
@ -51,7 +51,7 @@ class SerializerTest extends \PHPUnit_Framework_TestCase
public function testNormalizeOnDenormalizer()
{
$this->serializer = new Serializer(array(new TestDenormalizer()), array());
$this->assertTrue($this->serializer->normalize(new \stdClass, 'json'));
$this->assertTrue($this->serializer->normalize(new \stdClass(), 'json'));
}
/**

View File

@ -163,7 +163,9 @@ class StopwatchEvent
*/
public function getEndTime()
{
return ($count = count($this->periods)) ? $this->periods[$count - 1]->getEndTime() : 0;
$count = count($this->periods);
return $count ? $this->periods[$count - 1]->getEndTime() : 0;
}
/**

View File

@ -27,7 +27,7 @@ class Package implements PackageInterface
* @param string $version The package version
* @param string $format The format used to apply the version
*/
public function __construct($version = null, $format = null)
public function __construct($version = null, $format = '')
{
$this->version = $version;
$this->format = $format ?: '%s?%s';

View File

@ -14,7 +14,6 @@ namespace Symfony\Component\Templating\Tests\Loader;
use Symfony\Component\Templating\Loader\Loader;
use Symfony\Component\Templating\Loader\CacheLoader;
use Symfony\Component\Templating\Storage\StringStorage;
use Symfony\Component\Templating\TemplateNameParser;
use Symfony\Component\Templating\TemplateReferenceInterface;
use Symfony\Component\Templating\TemplateReference;
@ -22,7 +21,7 @@ class CacheLoaderTest extends \PHPUnit_Framework_TestCase
{
public function testConstructor()
{
$loader = new ProjectTemplateLoader($varLoader = new ProjectTemplateLoaderVar(new TemplateNameParser()), sys_get_temp_dir());
$loader = new ProjectTemplateLoader($varLoader = new ProjectTemplateLoaderVar(), sys_get_temp_dir());
$this->assertTrue($loader->getLoader() === $varLoader, '__construct() takes a template loader as its first argument');
$this->assertEquals(sys_get_temp_dir(), $loader->getDir(), '__construct() takes a directory where to store the cache as its second argument');
}
@ -31,7 +30,7 @@ class CacheLoaderTest extends \PHPUnit_Framework_TestCase
{
$dir = sys_get_temp_dir().DIRECTORY_SEPARATOR.rand(111111, 999999);
mkdir($dir, 0777, true);
$loader = new ProjectTemplateLoader($varLoader = new ProjectTemplateLoaderVar(new TemplateNameParser()), $dir);
$loader = new ProjectTemplateLoader($varLoader = new ProjectTemplateLoaderVar(), $dir);
$loader->setDebugger($debugger = new \Symfony\Component\Templating\Tests\Fixtures\ProjectTemplateDebugger());
$this->assertFalse($loader->load(new TemplateReference('foo', 'php')), '->load() returns false if the embed loader is not able to load the template');
$loader->load(new TemplateReference('index'));

View File

@ -12,14 +12,13 @@
namespace Symfony\Component\Templating\Tests\Loader;
use Symfony\Component\Templating\Loader\Loader;
use Symfony\Component\Templating\TemplateNameParser;
use Symfony\Component\Templating\TemplateReferenceInterface;
class LoaderTest extends \PHPUnit_Framework_TestCase
{
public function testGetSetDebugger()
{
$loader = new ProjectTemplateLoader4(new TemplateNameParser());
$loader = new ProjectTemplateLoader4();
$loader->setDebugger($debugger = new \Symfony\Component\Templating\Tests\Fixtures\ProjectTemplateDebugger());
$this->assertTrue($loader->getDebugger() === $debugger, '->setDebugger() sets the debugger instance');
}

View File

@ -29,7 +29,7 @@ abstract class AbstractComparison extends Constraint
*/
public function __construct($options = null)
{
if (!isset($options['value'])) {
if (is_array($options) && !isset($options['value'])) {
throw new ConstraintDefinitionException(sprintf(
'The %s constraint requires the "value" option to be set.',
get_class($this)

View File

@ -30,7 +30,7 @@ abstract class AbstractComparisonValidator extends ConstraintValidator
return;
}
if (!$this->compareValues($value, $constraint->value, $constraint)) {
if (!$this->compareValues($value, $constraint->value)) {
$this->context->addViolation($constraint->message, array(
'{{ value }}' => $this->valueToString($constraint->value),
'{{ compared_value }}' => $this->valueToString($constraint->value),

View File

@ -117,14 +117,14 @@ class ConstraintTest extends \PHPUnit_Framework_TestCase
public function testGetTargetsCanBeString()
{
$constraint = new ClassConstraint;
$constraint = new ClassConstraint();
$this->assertEquals('class', $constraint->getTargets());
}
public function testGetTargetsCanBeArray()
{
$constraint = new ConstraintA;
$constraint = new ConstraintA();
$this->assertEquals(array('property', 'class'), $constraint->getTargets());
}

View File

@ -21,7 +21,7 @@ class ElementMetadataTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->metadata = new TestElementMetadata('Symfony\Component\Validator\Tests\Fixtures\Entity');
$this->metadata = new TestElementMetadata();
}
protected function tearDown()

View File

@ -108,7 +108,7 @@ class Validator implements ValidatorInterface
? '"'.$containingValue.'"'
: 'the value of type '.gettype($containingValue);
throw new ValidatorException(sprintf('The metadata for '.$valueAsString.' does not support properties.'));
throw new ValidatorException(sprintf('The metadata for %s does not support properties.', $valueAsString));
}
foreach ($this->resolveGroups($groups) as $group) {