Merge branch '2.4'
* 2.4: fixed various inconsistencies reduced recursion when building DumperPrefixCollection renamed variables - making next change more readable removing dead code. [ExpressionLanguage] added some tests for the built-in constant() function [ExpressionLanguage] added some documentation about functions [DomCrawler] Fixed filterXPath() chaining [DomCrawler] Fixed incorrect handling of image inputs
This commit is contained in:
commit
f828aee7f7
@ -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)));
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\Tests\Fixtures;
|
||||
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
|
@ -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()
|
||||
);
|
||||
|
@ -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');
|
||||
|
||||
|
@ -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',
|
||||
|
@ -37,7 +37,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())
|
||||
|
@ -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__;
|
||||
|
@ -37,7 +37,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())
|
||||
|
@ -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__;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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'])) {
|
||||
|
@ -471,7 +471,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');
|
||||
@ -480,7 +480,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');
|
||||
@ -504,7 +504,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');
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,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')));
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ class PhpDumper extends Dumper
|
||||
{
|
||||
parent::__construct($container);
|
||||
|
||||
$this->inlinedDefinitions = new \SplObjectStorage;
|
||||
$this->inlinedDefinitions = new \SplObjectStorage();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -454,7 +454,7 @@ class Crawler extends \SplObjectStorage
|
||||
$nodes = array();
|
||||
|
||||
while ($node = $node->parentNode) {
|
||||
if (1 === $node->nodeType && '_root' !== $node->nodeName) {
|
||||
if (1 === $node->nodeType) {
|
||||
$nodes[] = $node;
|
||||
}
|
||||
}
|
||||
@ -599,16 +599,14 @@ class Crawler extends \SplObjectStorage
|
||||
*/
|
||||
public function filterXPath($xpath)
|
||||
{
|
||||
$document = new \DOMDocument('1.0', 'UTF-8');
|
||||
$root = $document->appendChild($document->createElement('_root'));
|
||||
$crawler = new static(null, $this->uri);
|
||||
$prefixes = $this->findNamespacePrefixes($xpath);
|
||||
foreach ($this as $node) {
|
||||
$root->appendChild($document->importNode($node, true));
|
||||
$domxpath = $this->createDOMXPath($node->ownerDocument, $prefixes);
|
||||
$crawler->add($domxpath->query($xpath, $node));
|
||||
}
|
||||
|
||||
$prefixes = $this->findNamespacePrefixes($xpath);
|
||||
$domxpath = $this->createDOMXPath($document, $prefixes);
|
||||
|
||||
return new static($domxpath->query($xpath), $this->uri);
|
||||
return $crawler;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,13 +52,7 @@ abstract class FormField
|
||||
{
|
||||
$this->node = $node;
|
||||
$this->name = $node->getAttribute('name');
|
||||
|
||||
$this->document = new \DOMDocument('1.0', 'UTF-8');
|
||||
$this->node = $this->document->importNode($this->node, true);
|
||||
|
||||
$root = $this->document->appendChild($this->document->createElement('_root'));
|
||||
$root->appendChild($this->node);
|
||||
$this->xpath = new \DOMXPath($this->document);
|
||||
$this->xpath = new \DOMXPath($node->ownerDocument);
|
||||
|
||||
$this->initialize();
|
||||
}
|
||||
|
@ -394,34 +394,43 @@ class Form extends Link implements \ArrayAccess
|
||||
{
|
||||
$this->fields = new FormFieldRegistry();
|
||||
|
||||
$document = new \DOMDocument('1.0', 'UTF-8');
|
||||
$xpath = new \DOMXPath($document);
|
||||
$root = $document->appendChild($document->createElement('_root'));
|
||||
$xpath = new \DOMXPath($this->node->ownerDocument);
|
||||
|
||||
// add submitted button if it has a valid name
|
||||
if ('form' !== $this->button->nodeName && $this->button->hasAttribute('name') && $this->button->getAttribute('name')) {
|
||||
$this->set(new Field\InputFormField($document->importNode($this->button, true)));
|
||||
if ('input' == $this->button->nodeName && 'image' == $this->button->getAttribute('type')) {
|
||||
$name = $this->button->getAttribute('name');
|
||||
$this->button->setAttribute('value', '0');
|
||||
|
||||
// temporarily change the name of the input node for the x coordinate
|
||||
$this->button->setAttribute('name', $name.'.x');
|
||||
$this->set(new Field\InputFormField($this->button));
|
||||
|
||||
// temporarily change the name of the input node for the y coordinate
|
||||
$this->button->setAttribute('name', $name.'.y');
|
||||
$this->set(new Field\InputFormField($this->button));
|
||||
|
||||
// restore the original name of the input node
|
||||
$this->button->setAttribute('name', $name);
|
||||
} else {
|
||||
$this->set(new Field\InputFormField($this->button));
|
||||
}
|
||||
}
|
||||
|
||||
// find form elements corresponding to the current form
|
||||
if ($this->node->hasAttribute('id')) {
|
||||
// traverse through the whole document
|
||||
$node = $document->importNode($this->node->ownerDocument->documentElement, true);
|
||||
$root->appendChild($node);
|
||||
|
||||
// corresponding elements are either descendants or have a matching HTML5 form attribute
|
||||
$formId = Crawler::xpathLiteral($this->node->getAttribute('id'));
|
||||
$fieldNodes = $xpath->query(sprintf('descendant::input[@form=%s] | descendant::button[@form=%s] | descendant::textarea[@form=%s] | descendant::select[@form=%s] | //form[@id=%s]//input[not(@form)] | //form[@id=%s]//button[not(@form)] | //form[@id=%s]//textarea[not(@form)] | //form[@id=%s]//select[not(@form)]', $formId, $formId, $formId, $formId, $formId, $formId, $formId, $formId), $root);
|
||||
|
||||
// do the xpath query without $this->node as the context node (i.e. traverse through the whole document)
|
||||
$fieldNodes = $xpath->query(sprintf('descendant::input[@form=%s] | descendant::button[@form=%s] | descendant::textarea[@form=%s] | descendant::select[@form=%s] | //form[@id=%s]//input[not(@form)] | //form[@id=%s]//button[not(@form)] | //form[@id=%s]//textarea[not(@form)] | //form[@id=%s]//select[not(@form)]', $formId, $formId, $formId, $formId, $formId, $formId, $formId, $formId));
|
||||
foreach ($fieldNodes as $node) {
|
||||
$this->addField($node);
|
||||
}
|
||||
} else {
|
||||
// parent form has no id, add descendant elements only
|
||||
$node = $document->importNode($this->node, true);
|
||||
$root->appendChild($node);
|
||||
|
||||
// descendant elements with form attribute are not part of this form
|
||||
$fieldNodes = $xpath->query('descendant::input[not(@form)] | descendant::button[not(@form)] | descendant::textarea[not(@form)] | descendant::select[not(@form)]', $root);
|
||||
// do the xpath query with $this->node as the context node, to only find descendant elements
|
||||
// however, descendant elements with form attribute are not part of this form
|
||||
$fieldNodes = $xpath->query('descendant::input[not(@form)] | descendant::button[not(@form)] | descendant::textarea[not(@form)] | descendant::select[not(@form)]', $this->node);
|
||||
foreach ($fieldNodes as $node) {
|
||||
$this->addField($node);
|
||||
}
|
||||
|
@ -390,8 +390,10 @@ EOF
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->filterXPath() returns a new instance of a crawler');
|
||||
|
||||
$crawler = $this->createTestCrawler()->filterXPath('//ul');
|
||||
|
||||
$this->assertCount(6, $crawler->filterXPath('//li'), '->filterXPath() filters the node list with the XPath expression');
|
||||
|
||||
$crawler = $this->createTestCrawler();
|
||||
$this->assertCount(3, $crawler->filterXPath('//body')->filterXPath('//button')->parents(), '->filterXpath() preserves parents when chained');
|
||||
}
|
||||
|
||||
public function testFilterXPathWithDefaultNamespace()
|
||||
|
@ -223,6 +223,11 @@ class FormTest extends \PHPUnit_Framework_TestCase
|
||||
<input type="submit" name="foobar" value="foobar" />',
|
||||
array('foobar' => array('InputFormField', 'foobar')),
|
||||
),
|
||||
array(
|
||||
'turns an image input into x and y fields',
|
||||
'<input type="image" name="bar" />',
|
||||
array('bar.x' => array('InputFormField', '0'), 'bar.y' => array('InputFormField', '0')),
|
||||
),
|
||||
array(
|
||||
'returns textareas',
|
||||
'<textarea name="foo">foo</textarea>
|
||||
|
@ -175,8 +175,6 @@ class ContainerAwareEventDispatcherTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testGetListenersOnLazyLoad()
|
||||
{
|
||||
$event = new Event();
|
||||
|
||||
$service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
|
||||
|
||||
$container = new Container();
|
||||
@ -194,8 +192,6 @@ class ContainerAwareEventDispatcherTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testRemoveAfterDispatch()
|
||||
{
|
||||
$event = new Event();
|
||||
|
||||
$service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
|
||||
|
||||
$container = new Container();
|
||||
@ -211,8 +207,6 @@ class ContainerAwareEventDispatcherTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testRemoveBeforeDispatch()
|
||||
{
|
||||
$event = new Event();
|
||||
|
||||
$service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
|
||||
|
||||
$container = new Container();
|
||||
|
@ -240,6 +240,7 @@ class EventDispatcherTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testEventReceivesTheDispatcherInstance()
|
||||
{
|
||||
$dispatcher = null;
|
||||
$this->dispatcher->addListener('test', function ($event) use (&$dispatcher) {
|
||||
$dispatcher = $event->getDispatcher();
|
||||
});
|
||||
|
@ -13,7 +13,6 @@ namespace Symfony\Component\EventDispatcher\Tests;
|
||||
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
use Symfony\Component\EventDispatcher\ImmutableEventDispatcher;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
|
@ -92,6 +92,18 @@ class ExpressionLanguage
|
||||
/**
|
||||
* Registers a function.
|
||||
*
|
||||
* A function is defined by two PHP callables. The callables are used
|
||||
* by the language to compile and/or evaluate the function.
|
||||
*
|
||||
* The first function is used at compilation time and must return a
|
||||
* PHP representation of the function call (it receives the function
|
||||
* arguments as arguments).
|
||||
*
|
||||
* The second function is used for expression evaluation and must return
|
||||
* the value of the function call based on the values defined for the
|
||||
* expression (it receives the values as a first argument and the function
|
||||
* arguments as remaining arguments).
|
||||
*
|
||||
* @param string $name The function name
|
||||
* @param callable $compiler A callable able to compile the function
|
||||
* @param callable $evaluator A callable able to evaluate the function
|
||||
|
@ -45,4 +45,13 @@ class ExpressionLanguageTest extends \PHPUnit_Framework_TestCase
|
||||
$parsedExpression = $expressionLanguage->parse('1 + 1', array());
|
||||
$this->assertSame($savedParsedExpression, $parsedExpression);
|
||||
}
|
||||
|
||||
public function testConstantFunction()
|
||||
{
|
||||
$expressionLanguage = new ExpressionLanguage();
|
||||
$this->assertEquals(PHP_VERSION, $expressionLanguage->evaluate('constant("PHP_VERSION")'));
|
||||
|
||||
$expressionLanguage = new ExpressionLanguage();
|
||||
$this->assertEquals('constant("PHP_VERSION")', $expressionLanguage->compile('constant("PHP_VERSION")'));
|
||||
}
|
||||
}
|
||||
|
@ -19,15 +19,10 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
class DependencyInjectionExtension implements FormExtensionInterface
|
||||
{
|
||||
private $container;
|
||||
|
||||
private $typeServiceIds;
|
||||
|
||||
private $typeExtensionServiceIds;
|
||||
|
||||
private $guesserServiceIds;
|
||||
|
||||
private $guesser;
|
||||
|
||||
private $guesserLoaded = false;
|
||||
|
||||
public function __construct(ContainerInterface $container,
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -742,7 +742,7 @@ class ResponseTest extends ResponseTestCase
|
||||
'setCharset' => 'UTF-8',
|
||||
'setPublic' => null,
|
||||
'setPrivate' => null,
|
||||
'setDate' => new \DateTime,
|
||||
'setDate' => new \DateTime(),
|
||||
'expire' => null,
|
||||
'setMaxAge' => 1,
|
||||
'setSharedMaxAge' => 1,
|
||||
|
@ -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()
|
||||
|
@ -63,7 +63,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;
|
||||
}
|
||||
|
@ -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'])) {
|
||||
|
@ -106,6 +106,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));
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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');
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -56,29 +56,27 @@ class DumperPrefixCollection extends DumperCollection
|
||||
{
|
||||
$prefix = $route->getRoute()->compile()->getStaticPrefix();
|
||||
|
||||
// Same prefix, add to current leave
|
||||
if ($this->prefix === $prefix) {
|
||||
$this->add($route);
|
||||
for ($collection = $this; null !== $collection; $collection = $collection->getParent()) {
|
||||
|
||||
return $this;
|
||||
// Same prefix, add to current leave
|
||||
if ($collection->prefix === $prefix) {
|
||||
$collection->add($route);
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
// Prefix starts with route's prefix
|
||||
if ('' === $collection->prefix || 0 === strpos($prefix, $collection->prefix)) {
|
||||
$child = new DumperPrefixCollection();
|
||||
$child->setPrefix(substr($prefix, 0, strlen($collection->prefix)+1));
|
||||
$collection->add($child);
|
||||
|
||||
return $child->addPrefixRoute($route);
|
||||
}
|
||||
}
|
||||
|
||||
// Prefix starts with route's prefix
|
||||
if ('' === $this->prefix || 0 === strpos($prefix, $this->prefix)) {
|
||||
$collection = new DumperPrefixCollection();
|
||||
$collection->setPrefix(substr($prefix, 0, strlen($this->prefix)+1));
|
||||
$this->add($collection);
|
||||
|
||||
return $collection->addPrefixRoute($route);
|
||||
}
|
||||
|
||||
// No match, fallback to parent (recursively)
|
||||
|
||||
if (null === $parent = $this->getParent()) {
|
||||
throw new \LogicException("The collection root must not have a prefix");
|
||||
}
|
||||
|
||||
return $parent->addPrefixRoute($route);
|
||||
// Reached only if the root has a non empty prefix
|
||||
throw new \LogicException("The collection root must not have a prefix");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -49,7 +49,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())
|
||||
|
@ -32,7 +32,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');
|
||||
|
||||
|
@ -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;
|
||||
|
@ -25,7 +25,7 @@ class JsonEncoderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
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)));
|
||||
|
@ -46,7 +46,7 @@ class CustomNormalizerTest extends \PHPUnit_Framework_TestCase
|
||||
public function testSupportsNormalization()
|
||||
{
|
||||
$this->assertTrue($this->normalizer->supportsNormalization(new ScalarDummy()));
|
||||
$this->assertFalse($this->normalizer->supportsNormalization(new \stdClass));
|
||||
$this->assertFalse($this->normalizer->supportsNormalization(new \stdClass()));
|
||||
}
|
||||
|
||||
public function testSupportsDenormalization()
|
||||
|
@ -28,7 +28,7 @@ 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()
|
||||
@ -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'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -161,7 +161,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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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';
|
||||
|
@ -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');
|
||||
}
|
||||
@ -32,7 +31,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);
|
||||
$this->assertFalse($loader->load(new TemplateReference('foo', 'php')), '->load() returns false if the embed loader is not able to load the template');
|
||||
|
||||
$logger = $this->getMock('Psr\Log\LoggerInterface');
|
||||
|
@ -12,7 +12,6 @@
|
||||
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
|
||||
@ -27,7 +26,7 @@ class LoaderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testGetSetDebugger()
|
||||
{
|
||||
$loader = new ProjectTemplateLoader4(new TemplateNameParser());
|
||||
$loader = new ProjectTemplateLoader4();
|
||||
$debugger = $this->getMock('Symfony\Component\Templating\DebuggerInterface');
|
||||
$loader->setDebugger($debugger);
|
||||
$this->assertSame($debugger, $loader->getDebugger(), '->setDebugger() sets the debugger instance');
|
||||
|
@ -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)
|
||||
|
@ -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),
|
||||
|
@ -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()
|
||||
|
@ -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) {
|
||||
|
Reference in New Issue
Block a user