Merge branch '2.4'
* 2.4: [Form][2.3] Fixes empty file-inputs getting treated as extra field. changed some PHPUnit assertions to more specific ones fixed Kernel::stripComments() normalizing new-lines added a BC comment Update FileLoader to fix issue #10339 bumped Symfony version to 2.3.12 updated VERSION for 2.3.11 update CONTRIBUTORS for 2.3.11 updated CHANGELOG for 2.3.11 Throw exception when unable to normalize embedded object Fixed evaluation of short circuit operators Follow-up to #10312: Fixed minor performance related issues in Yaml\Inline. [2.4][HttpKernel] Fix issue #10209 When the profiler has `only_exception` option activated and a subrequest throw an exception, the parent profile cannot be found.
This commit is contained in:
commit
77bfac719c
@ -7,6 +7,14 @@ in 2.3 minor versions.
|
||||
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
|
||||
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v2.3.0...v2.3.1
|
||||
|
||||
* 2.3.11 (2014-02-27)
|
||||
|
||||
* bug #10146 [WebProfilerBundle] fixed parsing Mongo DSN and added Test for it (malarzm)
|
||||
* bug #10299 [Finder] () is also a valid delimiter (WouterJ)
|
||||
* bug #10255 [FrameworkBundle] Fixed wrong redirect url if path contains some query parameters (pulzarraider)
|
||||
* bug #10285 Bypass sigchild detection if phpinfo is not available (Seldaek)
|
||||
* bug #10269 [Form] Revert "Fix "Array was modified outside object" in ResizeFormListener." (norzechowicz)
|
||||
|
||||
* 2.3.10 (2014-02-12)
|
||||
|
||||
* bug #10231 [Console] removed problematic regex (fabpot)
|
||||
|
@ -33,21 +33,21 @@ Symfony2 is the result of the work of many people who made the code better
|
||||
- stealth35 (stealth35)
|
||||
- Alexander Mols (asm89)
|
||||
- Bulat Shakirzyanov (avalanche123)
|
||||
- Grégoire Pineau (lyrixx)
|
||||
- Francis Besset (francisbesset)
|
||||
- Miha Vrhovnik
|
||||
- Henrik Bjørnskov (henrikbjorn)
|
||||
- Grégoire Pineau (lyrixx)
|
||||
- Konstantin Kudryashov (everzet)
|
||||
- Bilal Amarni (bamarni)
|
||||
- Florin Patan (florinpatan)
|
||||
- Saša Stamenković (umpirsky)
|
||||
- Eric Clemmons (ericclemmons)
|
||||
- Wouter De Jong (wouterj)
|
||||
- Deni
|
||||
- Henrik Westphal (snc)
|
||||
- Dariusz Górecki (canni)
|
||||
- Wouter De Jong (wouterj)
|
||||
- Arnout Boks (aboks)
|
||||
- Andrej Hudec (pulzarraider)
|
||||
- Arnout Boks (aboks)
|
||||
- Lee McDermott
|
||||
- Brandon Turner
|
||||
- Daniel Holmes (dholmes)
|
||||
@ -162,6 +162,7 @@ Symfony2 is the result of the work of many people who made the code better
|
||||
- Wouter Van Hecke
|
||||
- Michael Holm (hollo)
|
||||
- Marc Weistroff (futurecat)
|
||||
- Pierre-Yves LEBECQ (pylebecq)
|
||||
- Roman Marintšenko (inori)
|
||||
- Florian Klein (docteurklein)
|
||||
- Manuel Kiessling (manuelkiessling)
|
||||
@ -175,7 +176,9 @@ Symfony2 is the result of the work of many people who made the code better
|
||||
- Uwe Jäger (uwej711)
|
||||
- Aurelijus Valeiša (aurelijus)
|
||||
- Gustavo Piltcher
|
||||
- Chekote
|
||||
- Stepan Tanasiychuk (stfalcon)
|
||||
- Tiago Ribeiro (fixe)
|
||||
- Bob den Otter (bopp)
|
||||
- Adrian Rudnik (kreischweide)
|
||||
- Francesc Rosàs (frosas)
|
||||
@ -184,6 +187,7 @@ Symfony2 is the result of the work of many people who made the code better
|
||||
- janschoenherr
|
||||
- Marco Pivetta (ocramius)
|
||||
- Ricard Clau (ricardclau)
|
||||
- Nicolas Grekas (nicolas-grekas)
|
||||
- Erin Millard
|
||||
- Matthew Lewinski (lewinski)
|
||||
- Manuel Reinhard (sprain)
|
||||
@ -197,7 +201,6 @@ Symfony2 is the result of the work of many people who made the code better
|
||||
- Felix Labrecque
|
||||
- Yaroslav Kiliba
|
||||
- Sébastien Lavoie (lavoiesl)
|
||||
- Pierre-Yves LEBECQ (pylebecq)
|
||||
- Terje Bråten
|
||||
- Kristen Gilden (kgilden)
|
||||
- hossein zolfi (ocean)
|
||||
@ -216,13 +219,11 @@ Symfony2 is the result of the work of many people who made the code better
|
||||
- Ismael Ambrosi (iambrosi)
|
||||
- Shein Alexey
|
||||
- Joe Lencioni
|
||||
- Chekote
|
||||
- Kai
|
||||
- Stefano Sala (stefano.sala)
|
||||
- Xavier HAUSHERR
|
||||
- Albert Jessurum (ajessu)
|
||||
- Laszlo Korte
|
||||
- Tiago Ribeiro (fixe)
|
||||
- Alessandro Desantis
|
||||
- hubert lecorche (hlecorche)
|
||||
- Eugene Leonovich (rybakit)
|
||||
@ -279,6 +280,8 @@ Symfony2 is the result of the work of many people who made the code better
|
||||
- alexpods
|
||||
- Erik Trapman (eriktrapman)
|
||||
- De Cock Xavier (xdecock)
|
||||
- Alex Pott
|
||||
- Norbert Orzechowicz (norzechowicz)
|
||||
- Matthijs van den Bos (matthijs)
|
||||
- Nils Adermann (naderman)
|
||||
- Gábor Fási
|
||||
@ -383,7 +386,6 @@ Symfony2 is the result of the work of many people who made the code better
|
||||
- Xavier Lacot (xavier)
|
||||
- Olivier Maisonneuve (olineuve)
|
||||
- Francis Turmel (fturmel)
|
||||
- Nicolas Grekas (nicolas-grekas)
|
||||
- cgonzalez
|
||||
- Jayson Xu (superjavason)
|
||||
- Jaik Dean (jaikdean)
|
||||
@ -458,6 +460,7 @@ Symfony2 is the result of the work of many people who made the code better
|
||||
- Chris Jones (leek)
|
||||
- xaav
|
||||
- Mahmoud Mostafa (mahmoud)
|
||||
- Gildas Quéméner (gquemener)
|
||||
- Ricky Su (ricky)
|
||||
- Radosław Benkel
|
||||
- ttomor
|
||||
@ -520,6 +523,7 @@ Symfony2 is the result of the work of many people who made the code better
|
||||
- Benoit Garret
|
||||
- DerManoMann
|
||||
- Roland Franssen (ro0)
|
||||
- Maciej Malarz
|
||||
- Rodrigo Díez Villamuera (rodrigodiez)
|
||||
- e-ivanov
|
||||
- Jochen Bayer (jocl)
|
||||
@ -654,6 +658,7 @@ Symfony2 is the result of the work of many people who made the code better
|
||||
- Ramon Kleiss (akathos)
|
||||
- Jakub Škvára (jskvara)
|
||||
- Nicolas Badey (nico-b)
|
||||
- Shane Preece (shane)
|
||||
- povilas
|
||||
- Alexander Obuhovich
|
||||
- Alessandro Tagliapietra (alex88)
|
||||
@ -672,6 +677,7 @@ Symfony2 is the result of the work of many people who made the code better
|
||||
- pborreli
|
||||
- Eric Caron
|
||||
- 2manypeople
|
||||
- Wing
|
||||
- Thomas Bibb
|
||||
- Josef Cech
|
||||
- Matthew Foster (mfoster)
|
||||
@ -687,6 +693,7 @@ Symfony2 is the result of the work of many people who made the code better
|
||||
- Andreas
|
||||
- Strate
|
||||
- Thomas Chmielowiec
|
||||
- Andrey Ryaguzov
|
||||
- Gunther Konig
|
||||
- František Bereň
|
||||
- Benjamin Grandfond (benjamin)
|
||||
@ -928,7 +935,6 @@ Symfony2 is the result of the work of many people who made the code better
|
||||
- Moritz Borgmann (mborgmann)
|
||||
- Matt Drollette (mdrollette)
|
||||
- Adam Monsen (meonkeys)
|
||||
- Norbert Orzechowicz (norzechowicz)
|
||||
- ollie harridge (ollietb)
|
||||
- Paweł Szczepanek (pauluz)
|
||||
- Petr Jaroš (petajaros)
|
||||
@ -949,6 +955,7 @@ Symfony2 is the result of the work of many people who made the code better
|
||||
- Eugene Babushkin (warl)
|
||||
- Xavier Amado (xamado)
|
||||
- Florent Cailhol
|
||||
- szymek
|
||||
- craigmarvelley
|
||||
- Stano Turza
|
||||
- simpson
|
||||
|
@ -29,7 +29,7 @@ class CollectionToArrayTransformerTest extends Propel1TestCase
|
||||
$result = $this->transformer->transform(new PropelObjectCollection());
|
||||
|
||||
$this->assertTrue(is_array($result));
|
||||
$this->assertEquals(0, count($result));
|
||||
$this->assertCount(0, $result);
|
||||
}
|
||||
|
||||
public function testTransformWithNull()
|
||||
@ -37,7 +37,7 @@ class CollectionToArrayTransformerTest extends Propel1TestCase
|
||||
$result = $this->transformer->transform(null);
|
||||
|
||||
$this->assertTrue(is_array($result));
|
||||
$this->assertEquals(0, count($result));
|
||||
$this->assertCount(0, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,7 +56,7 @@ class CollectionToArrayTransformerTest extends Propel1TestCase
|
||||
$result = $this->transformer->transform($coll);
|
||||
|
||||
$this->assertTrue(is_array($result));
|
||||
$this->assertEquals(2, count($result));
|
||||
$this->assertCount(2, $result);
|
||||
$this->assertEquals('foo', $result[0]);
|
||||
$this->assertEquals('bar', $result[1]);
|
||||
}
|
||||
@ -66,7 +66,7 @@ class CollectionToArrayTransformerTest extends Propel1TestCase
|
||||
$result = $this->transformer->reverseTransform(null);
|
||||
|
||||
$this->assertInstanceOf('\PropelObjectCollection', $result);
|
||||
$this->assertEquals(0, count($result->getData()));
|
||||
$this->assertCount(0, $result->getData());
|
||||
}
|
||||
|
||||
public function testReverseTransformWithEmptyString()
|
||||
@ -74,7 +74,7 @@ class CollectionToArrayTransformerTest extends Propel1TestCase
|
||||
$result = $this->transformer->reverseTransform('');
|
||||
|
||||
$this->assertInstanceOf('\PropelObjectCollection', $result);
|
||||
$this->assertEquals(0, count($result->getData()));
|
||||
$this->assertCount(0, $result->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,7 +95,7 @@ class CollectionToArrayTransformerTest extends Propel1TestCase
|
||||
$this->assertInstanceOf('\PropelObjectCollection', $result);
|
||||
|
||||
$this->assertTrue(is_array($data));
|
||||
$this->assertEquals(2, count($data));
|
||||
$this->assertCount(2, $data);
|
||||
$this->assertEquals('foo', $data[0]);
|
||||
$this->assertEquals('bar', $data[1]);
|
||||
$this->assertsame($inputData, $data);
|
||||
|
@ -46,7 +46,7 @@ class TemplateFinderTest extends TestCase
|
||||
$finder->findAllTemplates()
|
||||
);
|
||||
|
||||
$this->assertEquals(6, count($templates), '->findAllTemplates() find all templates in the bundles and global folders');
|
||||
$this->assertCount(6, $templates, '->findAllTemplates() find all templates in the bundles and global folders');
|
||||
$this->assertContains('BaseBundle::base.format.engine', $templates);
|
||||
$this->assertContains('BaseBundle::this.is.a.template.format.engine', $templates);
|
||||
$this->assertContains('BaseBundle:controller:base.format.engine', $templates);
|
||||
|
@ -73,7 +73,7 @@ class TwigLoaderPassTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->pass->process($this->builder);
|
||||
$calls = $this->chainLoader->getMethodCalls();
|
||||
$this->assertEquals(2, count($calls));
|
||||
$this->assertCount(2, $calls);
|
||||
$this->assertEquals('addLoader', $calls[0][0]);
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,11 @@ abstract class FileLoader extends Loader
|
||||
$loader = $this->resolve($resource, $type);
|
||||
|
||||
if ($loader instanceof FileLoader && null !== $this->currentDir) {
|
||||
$resource = $this->locator->locate($resource, $this->currentDir, false);
|
||||
// we fallback to the current locator to keep BC
|
||||
// as some some loaders do not call the parent __construct()
|
||||
// @deprecated should be removed in 3.0
|
||||
$locator = $loader->getLocator() ?: $this->locator;
|
||||
$resource = $locator->locate($resource, $this->currentDir, false);
|
||||
}
|
||||
|
||||
$resources = is_array($resource) ? $resource : array($resource);
|
||||
|
@ -45,7 +45,7 @@ class NodeBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
->setNodeClass('newtype', $class)
|
||||
->node('', 'newtype');
|
||||
|
||||
$this->assertEquals(get_class($node), $class);
|
||||
$this->assertInstanceOf($class, $node);
|
||||
}
|
||||
|
||||
public function testOverridingAnExistingNodeType()
|
||||
@ -57,7 +57,7 @@ class NodeBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
->setNodeClass('variable', $class)
|
||||
->node('', 'variable');
|
||||
|
||||
$this->assertEquals(get_class($node), $class);
|
||||
$this->assertInstanceOf($class, $node);
|
||||
}
|
||||
|
||||
public function testNodeTypesAreNotCaseSensitive()
|
||||
@ -67,14 +67,14 @@ class NodeBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
$node1 = $builder->node('', 'VaRiAbLe');
|
||||
$node2 = $builder->node('', 'variable');
|
||||
|
||||
$this->assertEquals(get_class($node1), get_class($node2));
|
||||
$this->assertInstanceOf(get_class($node1), $node2);
|
||||
|
||||
$builder->setNodeClass('CuStOm', __NAMESPACE__.'\\SomeNodeDefinition');
|
||||
|
||||
$node1 = $builder->node('', 'CUSTOM');
|
||||
$node2 = $builder->node('', 'custom');
|
||||
|
||||
$this->assertEquals(get_class($node1), get_class($node2));
|
||||
$this->assertInstanceOf(get_class($node1), $node2);
|
||||
}
|
||||
|
||||
public function testNumericNodeCreation()
|
||||
@ -82,10 +82,10 @@ class NodeBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
$builder = new NodeBuilder();
|
||||
|
||||
$node = $builder->integerNode('foo')->min(3)->max(5);
|
||||
$this->assertEquals('Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition', get_class($node));
|
||||
$this->assertInstanceOf('Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition', $node);
|
||||
|
||||
$node = $builder->floatNode('bar')->min(3.0)->max(5.0);
|
||||
$this->assertEquals('Symfony\Component\Config\Definition\Builder\FloatNodeDefinition', get_class($node));
|
||||
$this->assertInstanceOf('Symfony\Component\Config\Definition\Builder\FloatNodeDefinition', $node);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,11 +28,11 @@ class TreeBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$nodeBuilder = $root->children();
|
||||
|
||||
$this->assertEquals(get_class($nodeBuilder), 'Symfony\Component\Config\Tests\Definition\Builder\NodeBuilder');
|
||||
$this->assertInstanceOf('Symfony\Component\Config\Tests\Definition\Builder\NodeBuilder', $nodeBuilder);
|
||||
|
||||
$nodeBuilder = $nodeBuilder->arrayNode('deeper')->children();
|
||||
|
||||
$this->assertEquals(get_class($nodeBuilder), 'Symfony\Component\Config\Tests\Definition\Builder\NodeBuilder');
|
||||
$this->assertInstanceOf('Symfony\Component\Config\Tests\Definition\Builder\NodeBuilder', $nodeBuilder);
|
||||
}
|
||||
|
||||
public function testOverrideABuiltInNodeType()
|
||||
@ -42,7 +42,7 @@ class TreeBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$definition = $root->children()->variableNode('variable');
|
||||
|
||||
$this->assertEquals(get_class($definition), 'Symfony\Component\Config\Tests\Definition\Builder\VariableNodeDefinition');
|
||||
$this->assertInstanceOf('Symfony\Component\Config\Tests\Definition\Builder\VariableNodeDefinition', $definition);
|
||||
}
|
||||
|
||||
public function testAddANodeType()
|
||||
@ -52,7 +52,7 @@ class TreeBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$definition = $root->children()->barNode('variable');
|
||||
|
||||
$this->assertEquals(get_class($definition), 'Symfony\Component\Config\Tests\Definition\Builder\BarNodeDefinition');
|
||||
$this->assertInstanceOf('Symfony\Component\Config\Tests\Definition\Builder\BarNodeDefinition', $definition);
|
||||
}
|
||||
|
||||
public function testCreateABuiltInNodeTypeWithACustomNodeBuilder()
|
||||
@ -62,7 +62,7 @@ class TreeBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$definition = $root->children()->booleanNode('boolean');
|
||||
|
||||
$this->assertEquals(get_class($definition), 'Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition');
|
||||
$this->assertInstanceOf('Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition', $definition);
|
||||
}
|
||||
|
||||
public function testPrototypedArrayNodeUseTheCustomNodeBuilder()
|
||||
|
@ -20,10 +20,12 @@ class FileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* @covers Symfony\Component\Config\Loader\FileLoader
|
||||
*/
|
||||
public function testImport()
|
||||
public function testImportWithFileLocatorDelegation()
|
||||
{
|
||||
$locatorMock = $this->getMock('Symfony\Component\Config\FileLocatorInterface');
|
||||
$locatorMock->expects($this->any())->method('locate')->will($this->onConsecutiveCalls(
|
||||
|
||||
$locatorMockForAdditionalLoader = $this->getMock('Symfony\Component\Config\FileLocatorInterface');
|
||||
$locatorMockForAdditionalLoader->expects($this->any())->method('locate')->will($this->onConsecutiveCalls(
|
||||
array('path/to/file1'), // Default
|
||||
array('path/to/file1', 'path/to/file2'), // First is imported
|
||||
array('path/to/file1', 'path/to/file2'), // Second is imported
|
||||
@ -32,8 +34,13 @@ class FileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
));
|
||||
|
||||
$fileLoader = new TestFileLoader($locatorMock);
|
||||
$fileLoader->setSupports(false);
|
||||
$fileLoader->setCurrentDir('.');
|
||||
$fileLoader->setResolver($loaderResolver = new LoaderResolver(array($fileLoader)));
|
||||
|
||||
$additionalLoader = new TestFileLoader($locatorMockForAdditionalLoader);
|
||||
$additionalLoader->setCurrentDir('.');
|
||||
|
||||
$fileLoader->setResolver($loaderResolver = new LoaderResolver(array($fileLoader, $additionalLoader)));
|
||||
|
||||
// Default case
|
||||
$this->assertSame('path/to/file1', $fileLoader->import('my_resource'));
|
||||
@ -66,6 +73,8 @@ class FileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
class TestFileLoader extends FileLoader
|
||||
{
|
||||
private $supports = true;
|
||||
|
||||
public function load($resource, $type = null)
|
||||
{
|
||||
return $resource;
|
||||
@ -73,7 +82,7 @@ class TestFileLoader extends FileLoader
|
||||
|
||||
public function supports($resource, $type = null)
|
||||
{
|
||||
return true;
|
||||
return $this->supports;
|
||||
}
|
||||
|
||||
public function addLoading($resource)
|
||||
@ -90,4 +99,9 @@ class TestFileLoader extends FileLoader
|
||||
{
|
||||
self::$loading = array();
|
||||
}
|
||||
|
||||
public function setSupports($supports)
|
||||
{
|
||||
$this->supports = $supports;
|
||||
}
|
||||
}
|
||||
|
@ -102,11 +102,11 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$application = new Application();
|
||||
$commands = $application->all();
|
||||
$this->assertEquals('Symfony\\Component\\Console\\Command\\HelpCommand', get_class($commands['help']), '->all() returns the registered commands');
|
||||
$this->assertInstanceOf('Symfony\\Component\\Console\\Command\\HelpCommand', $commands['help'], '->all() returns the registered commands');
|
||||
|
||||
$application->add(new \FooCommand());
|
||||
$commands = $application->all('foo');
|
||||
$this->assertEquals(1, count($commands), '->all() takes a namespace as its first argument');
|
||||
$this->assertCount(1, $commands, '->all() takes a namespace as its first argument');
|
||||
}
|
||||
|
||||
public function testRegister()
|
||||
@ -535,8 +535,8 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
|
||||
$application->run();
|
||||
ob_end_clean();
|
||||
|
||||
$this->assertSame('Symfony\Component\Console\Input\ArgvInput', get_class($command->input), '->run() creates an ArgvInput by default if none is given');
|
||||
$this->assertSame('Symfony\Component\Console\Output\ConsoleOutput', get_class($command->output), '->run() creates a ConsoleOutput by default if none is given');
|
||||
$this->assertInstanceOf('Symfony\Component\Console\Input\ArgvInput', $command->input, '->run() creates an ArgvInput by default if none is given');
|
||||
$this->assertInstanceOf('Symfony\Component\Console\Output\ConsoleOutput', $command->output, '->run() creates a ConsoleOutput by default if none is given');
|
||||
|
||||
$application = new Application();
|
||||
$application->setAutoExit(false);
|
||||
|
@ -47,7 +47,7 @@ class ParserTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$parser = new Parser();
|
||||
$selectors = $parser->parse($source);
|
||||
$this->assertEquals(1, count($selectors));
|
||||
$this->assertCount(1, $selectors);
|
||||
|
||||
/** @var SelectorNode $selector */
|
||||
$selector = $selectors[0];
|
||||
@ -60,7 +60,7 @@ class ParserTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$parser = new Parser();
|
||||
$selectors = $parser->parse($source);
|
||||
$this->assertEquals(1, count($selectors));
|
||||
$this->assertCount(1, $selectors);
|
||||
|
||||
/** @var SelectorNode $selector */
|
||||
$selector = $selectors[0];
|
||||
@ -72,7 +72,7 @@ class ParserTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$parser = new Parser();
|
||||
$selectors = $parser->parse(sprintf(':nth-child(%s)', $series));
|
||||
$this->assertEquals(1, count($selectors));
|
||||
$this->assertCount(1, $selectors);
|
||||
|
||||
/** @var FunctionNode $function */
|
||||
$function = $selectors[0]->getTree();
|
||||
@ -84,7 +84,7 @@ class ParserTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$parser = new Parser();
|
||||
$selectors = $parser->parse(sprintf(':nth-child(%s)', $series));
|
||||
$this->assertEquals(1, count($selectors));
|
||||
$this->assertCount(1, $selectors);
|
||||
|
||||
/** @var FunctionNode $function */
|
||||
$function = $selectors[0]->getTree();
|
||||
|
@ -24,7 +24,7 @@ class ClassParserTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$parser = new ClassParser();
|
||||
$selectors = $parser->parse($source);
|
||||
$this->assertEquals(1, count($selectors));
|
||||
$this->assertCount(1, $selectors);
|
||||
|
||||
/** @var SelectorNode $selector */
|
||||
$selector = $selectors[0];
|
||||
|
@ -24,7 +24,7 @@ class ElementParserTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$parser = new ElementParser();
|
||||
$selectors = $parser->parse($source);
|
||||
$this->assertEquals(1, count($selectors));
|
||||
$this->assertCount(1, $selectors);
|
||||
|
||||
/** @var SelectorNode $selector */
|
||||
$selector = $selectors[0];
|
||||
|
@ -23,13 +23,13 @@ class EmptyStringParserTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$parser = new EmptyStringParser();
|
||||
$selectors = $parser->parse('');
|
||||
$this->assertEquals(1, count($selectors));
|
||||
$this->assertCount(1, $selectors);
|
||||
|
||||
/** @var SelectorNode $selector */
|
||||
$selector = $selectors[0];
|
||||
$this->assertEquals('Element[*]', (string) $selector->getTree());
|
||||
|
||||
$selectors = $parser->parse('this will produce an empty array');
|
||||
$this->assertEquals(0, count($selectors));
|
||||
$this->assertCount(0, $selectors);
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class HashParserTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$parser = new HashParser();
|
||||
$selectors = $parser->parse($source);
|
||||
$this->assertEquals(1, count($selectors));
|
||||
$this->assertCount(1, $selectors);
|
||||
|
||||
/** @var SelectorNode $selector */
|
||||
$selector = $selectors[0];
|
||||
|
@ -113,7 +113,7 @@ class FlattenExceptionTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->assertEquals($exception->getMessage(), $flattened->getMessage(), 'The message is copied from the original exception.');
|
||||
$this->assertEquals($exception->getCode(), $flattened->getCode(), 'The code is copied from the original exception.');
|
||||
$this->assertEquals(get_class($exception), $flattened->getClass(), 'The class is set to the class of the original exception');
|
||||
$this->assertInstanceOf($flattened->getClass(), $exception, 'The class is set to the class of the original exception');
|
||||
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
$xml = $m->invoke($loader, self::$fixturesPath.'/xml/services1.xml');
|
||||
$this->assertEquals('Symfony\\Component\\DependencyInjection\\SimpleXMLElement', get_class($xml), '->parseFile() returns an SimpleXMLElement object');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\SimpleXMLElement', $xml, '->parseFile() returns an SimpleXMLElement object');
|
||||
}
|
||||
|
||||
public function testLoadParameters()
|
||||
@ -167,20 +167,20 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
|
||||
$loader->load('services5.xml');
|
||||
$services = $container->getDefinitions();
|
||||
$this->assertEquals(4, count($services), '->load() attributes unique ids to anonymous services');
|
||||
$this->assertCount(4, $services, '->load() attributes unique ids to anonymous services');
|
||||
|
||||
// anonymous service as an argument
|
||||
$args = $services['foo']->getArguments();
|
||||
$this->assertEquals(1, count($args), '->load() references anonymous services as "normal" ones');
|
||||
$this->assertEquals('Symfony\\Component\\DependencyInjection\\Reference', get_class($args[0]), '->load() converts anonymous services to references to "normal" services');
|
||||
$this->assertCount(1, $args, '->load() references anonymous services as "normal" ones');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Reference', $args[0], '->load() converts anonymous services to references to "normal" services');
|
||||
$this->assertTrue(isset($services[(string) $args[0]]), '->load() makes a reference to the created ones');
|
||||
$inner = $services[(string) $args[0]];
|
||||
$this->assertEquals('BarClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones');
|
||||
|
||||
// inner anonymous services
|
||||
$args = $inner->getArguments();
|
||||
$this->assertEquals(1, count($args), '->load() references anonymous services as "normal" ones');
|
||||
$this->assertEquals('Symfony\\Component\\DependencyInjection\\Reference', get_class($args[0]), '->load() converts anonymous services to references to "normal" services');
|
||||
$this->assertCount(1, $args, '->load() references anonymous services as "normal" ones');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Reference', $args[0], '->load() converts anonymous services to references to "normal" services');
|
||||
$this->assertTrue(isset($services[(string) $args[0]]), '->load() makes a reference to the created ones');
|
||||
$inner = $services[(string) $args[0]];
|
||||
$this->assertEquals('BazClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones');
|
||||
@ -188,7 +188,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
// anonymous service as a property
|
||||
$properties = $services['foo']->getProperties();
|
||||
$property = $properties['p'];
|
||||
$this->assertEquals('Symfony\\Component\\DependencyInjection\\Reference', get_class($property), '->load() converts anonymous services to references to "normal" services');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Reference', $property, '->load() converts anonymous services to references to "normal" services');
|
||||
$this->assertTrue(isset($services[(string) $property]), '->load() makes a reference to the created ones');
|
||||
$inner = $services[(string) $property];
|
||||
$this->assertEquals('BazClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones');
|
||||
@ -201,7 +201,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
$loader->load('services6.xml');
|
||||
$services = $container->getDefinitions();
|
||||
$this->assertTrue(isset($services['foo']), '->load() parses <service> elements');
|
||||
$this->assertEquals('Symfony\\Component\\DependencyInjection\\Definition', get_class($services['foo']), '->load() converts <service> element to Definition instances');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Definition', $services['foo'], '->load() converts <service> element to Definition instances');
|
||||
$this->assertEquals('FooClass', $services['foo']->getClass(), '->load() parses the class attribute');
|
||||
$this->assertEquals('container', $services['scope.container']->getScope());
|
||||
$this->assertEquals('custom', $services['scope.custom']->getScope());
|
||||
@ -394,11 +394,11 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
$loader1 = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml/extension1'));
|
||||
$loader1->load('services.xml');
|
||||
$services = $container->getDefinitions();
|
||||
$this->assertEquals(2, count($services), '->load() attributes unique ids to anonymous services');
|
||||
$this->assertCount(2, $services, '->load() attributes unique ids to anonymous services');
|
||||
$loader2 = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml/extension2'));
|
||||
$loader2->load('services.xml');
|
||||
$services = $container->getDefinitions();
|
||||
$this->assertEquals(4, count($services), '->load() attributes unique ids to anonymous services');
|
||||
$this->assertCount(4, $services, '->load() attributes unique ids to anonymous services');
|
||||
|
||||
$services = $container->getDefinitions();
|
||||
$args1 = $services['extension1.foo']->getArguments();
|
||||
|
@ -103,7 +103,7 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
$loader->load('services6.yml');
|
||||
$services = $container->getDefinitions();
|
||||
$this->assertTrue(isset($services['foo']), '->load() parses service elements');
|
||||
$this->assertEquals('Symfony\\Component\\DependencyInjection\\Definition', get_class($services['foo']), '->load() converts service element to Definition instances');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Definition', $services['foo'], '->load() converts service element to Definition instances');
|
||||
$this->assertEquals('FooClass', $services['foo']->getClass(), '->load() parses the class attribute');
|
||||
$this->assertEquals('container', $services['scope.container']->getScope());
|
||||
$this->assertEquals('custom', $services['scope.custom']->getScope());
|
||||
|
@ -604,7 +604,7 @@ class FormTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$form = $this->createForm('<form method="post"><input type="text" name="bar" value="bar" /><input type="submit" /></form>');
|
||||
|
||||
$this->assertEquals('Symfony\\Component\\DomCrawler\\Field\\InputFormField', get_class($form->get('bar')), '->get() returns the field object associated with the given name');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Field\\InputFormField', $form->get('bar'), '->get() returns the field object associated with the given name');
|
||||
|
||||
try {
|
||||
$form->get('foo');
|
||||
@ -619,8 +619,8 @@ class FormTest extends \PHPUnit_Framework_TestCase
|
||||
$form = $this->createForm('<form method="post"><input type="text" name="bar" value="bar" /><input type="submit" /></form>');
|
||||
|
||||
$fields = $form->all();
|
||||
$this->assertEquals(1, count($fields), '->all() return an array of form field objects');
|
||||
$this->assertEquals('Symfony\\Component\\DomCrawler\\Field\\InputFormField', get_class($fields['bar']), '->all() return an array of form field objects');
|
||||
$this->assertCount(1, $fields, '->all() return an array of form field objects');
|
||||
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Field\\InputFormField', $fields['bar'], '->all() return an array of form field objects');
|
||||
}
|
||||
|
||||
public function testSubmitWithoutAFormButton()
|
||||
|
@ -83,9 +83,10 @@ class BinaryNode extends Node
|
||||
{
|
||||
$operator = $this->attributes['operator'];
|
||||
$left = $this->nodes['left']->evaluate($functions, $values);
|
||||
$right = $this->nodes['right']->evaluate($functions, $values);
|
||||
|
||||
if (isset(self::$functions[$operator])) {
|
||||
$right = $this->nodes['right']->evaluate($functions, $values);
|
||||
|
||||
if ('not in' == $operator) {
|
||||
return !call_user_func('in_array', $left, $right);
|
||||
}
|
||||
@ -96,10 +97,15 @@ class BinaryNode extends Node
|
||||
switch ($operator) {
|
||||
case 'or':
|
||||
case '||':
|
||||
return $left || $right;
|
||||
return $left || $this->nodes['right']->evaluate($functions, $values);
|
||||
case 'and':
|
||||
case '&&':
|
||||
return $left && $right;
|
||||
return $left && $this->nodes['right']->evaluate($functions, $values);
|
||||
}
|
||||
|
||||
$right = $this->nodes['right']->evaluate($functions, $values);
|
||||
|
||||
switch ($operator) {
|
||||
case '|':
|
||||
return $left | $right;
|
||||
case '^':
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace Symfony\Component\ExpressionLanguage\Tests;
|
||||
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
|
||||
use Symfony\Component\ExpressionLanguage\ParsedExpression;
|
||||
|
||||
class ExpressionLanguageTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
@ -54,4 +53,47 @@ class ExpressionLanguageTest extends \PHPUnit_Framework_TestCase
|
||||
$expressionLanguage = new ExpressionLanguage();
|
||||
$this->assertEquals('constant("PHP_VERSION")', $expressionLanguage->compile('constant("PHP_VERSION")'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider shortCircuitProviderEvaluate
|
||||
*/
|
||||
public function testShortCircuitOperatorsEvaluate($expression, array $values, $expected)
|
||||
{
|
||||
$expressionLanguage = new ExpressionLanguage();
|
||||
$this->assertEquals($expected, $expressionLanguage->evaluate($expression, $values));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider shortCircuitProviderCompile
|
||||
*/
|
||||
public function testShortCircuitOperatorsCompile($expression, array $names, $expected)
|
||||
{
|
||||
$result = null;
|
||||
$expressionLanguage = new ExpressionLanguage();
|
||||
eval(sprintf('$result = %s;', $expressionLanguage->compile($expression, $names)));
|
||||
$this->assertSame($expected, $result);
|
||||
}
|
||||
|
||||
public function shortCircuitProviderEvaluate()
|
||||
{
|
||||
$object = $this->getMockBuilder('stdClass')->setMethods(array('foo'))->getMock();
|
||||
$object->expects($this->never())->method('foo');
|
||||
|
||||
return array(
|
||||
array('false and object.foo()', array('object' => $object), false),
|
||||
array('false && object.foo()', array('object' => $object), false),
|
||||
array('true || object.foo()', array('object' => $object), true),
|
||||
array('true or object.foo()', array('object' => $object), true),
|
||||
);
|
||||
}
|
||||
|
||||
public function shortCircuitProviderCompile()
|
||||
{
|
||||
return array(
|
||||
array('false and foo', array('foo' => 'foo'), false),
|
||||
array('false && foo', array('foo' => 'foo'), false),
|
||||
array('true || foo', array('foo' => 'foo'), true),
|
||||
array('true or foo', array('foo' => 'foo'), true),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -565,7 +565,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
$finder = $this->buildFinder($adapter);
|
||||
$finder->in($locations)->depth('< 1')->name('test.php');
|
||||
|
||||
$this->assertEquals(1, count($finder));
|
||||
$this->assertCount(1, $finder);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -746,7 +746,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
$this->assertIterator($this->toAbsolute(array('foo bar', 'test.php', 'test.py')), $finder->getIterator());
|
||||
$this->fail('Finder should throw an exception when opening a non-readable directory.');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertEquals('Symfony\\Component\\Finder\\Exception\\AccessDeniedException', get_class($e));
|
||||
$this->assertInstanceOf('Symfony\\Component\\Finder\\Exception\\AccessDeniedException', $e);
|
||||
}
|
||||
|
||||
// restore original permissions
|
||||
|
@ -129,7 +129,7 @@ class CompoundFormTest extends AbstractFormTest
|
||||
$child = $factory->create('file', null, array('auto_initialize' => false));
|
||||
|
||||
$this->form->add($child);
|
||||
$this->form->submit(array('file' => null));
|
||||
$this->form->submit(array('file' => null), false);
|
||||
|
||||
$this->assertCount(0, $this->form->getExtraData());
|
||||
}
|
||||
|
@ -150,6 +150,6 @@ class FlashBagTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
$this->assertEquals(count($flashes), $i);
|
||||
$this->assertEquals(0, count($this->bag->all()));
|
||||
$this->assertCount(0, $this->bag->all());
|
||||
}
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ class SessionTest extends \PHPUnit_Framework_TestCase
|
||||
$this->session->set('hello', 'world');
|
||||
$this->session->set('symfony2', 'rocks');
|
||||
|
||||
$this->assertEquals(2, count($this->session));
|
||||
$this->assertCount(2, $this->session);
|
||||
}
|
||||
|
||||
public function testGetMeta()
|
||||
|
@ -79,11 +79,11 @@ class PdoSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$storage = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions'), array());
|
||||
$storage->write('foo', 'bar');
|
||||
$this->assertEquals(1, count($this->pdo->query('SELECT * FROM sessions')->fetchAll()));
|
||||
$this->assertCount(1, $this->pdo->query('SELECT * FROM sessions')->fetchAll());
|
||||
|
||||
$storage->destroy('foo');
|
||||
|
||||
$this->assertEquals(0, count($this->pdo->query('SELECT * FROM sessions')->fetchAll()));
|
||||
$this->assertCount(0, $this->pdo->query('SELECT * FROM sessions')->fetchAll());
|
||||
}
|
||||
|
||||
public function testSessionGC()
|
||||
@ -93,10 +93,10 @@ class PdoSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
$storage->write('foo', 'bar');
|
||||
$storage->write('baz', 'bar');
|
||||
|
||||
$this->assertEquals(2, count($this->pdo->query('SELECT * FROM sessions')->fetchAll()));
|
||||
$this->assertCount(2, $this->pdo->query('SELECT * FROM sessions')->fetchAll());
|
||||
|
||||
$storage->gc(-1);
|
||||
$this->assertEquals(0, count($this->pdo->query('SELECT * FROM sessions')->fetchAll()));
|
||||
$this->assertCount(0, $this->pdo->query('SELECT * FROM sessions')->fetchAll());
|
||||
}
|
||||
|
||||
public function testGetConnection()
|
||||
|
@ -127,7 +127,9 @@ class ProfilerListener implements EventSubscriberInterface
|
||||
foreach ($this->profiles as $request) {
|
||||
// isset call should be removed when requestStack is required
|
||||
if (isset($this->parents[$request]) && null !== $parentRequest = $this->parents[$request]) {
|
||||
$this->profiles[$parentRequest]->addChild($this->profiles[$request]);
|
||||
if (isset($this->profiles[$parentRequest])) {
|
||||
$this->profiles[$parentRequest]->addChild($this->profiles[$request]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -757,23 +757,39 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
$rawChunk = '';
|
||||
$output = '';
|
||||
$tokens = token_get_all($source);
|
||||
$ignoreSpace = false;
|
||||
for (reset($tokens); false !== $token = current($tokens); next($tokens)) {
|
||||
if (is_string($token)) {
|
||||
$rawChunk .= $token;
|
||||
} elseif (T_START_HEREDOC === $token[0]) {
|
||||
$output .= preg_replace(array('/\s+$/Sm', '/\n+/S'), "\n", $rawChunk).$token[1];
|
||||
$output .= $rawChunk.$token[1];
|
||||
do {
|
||||
$token = next($tokens);
|
||||
$output .= $token[1];
|
||||
} while ($token[0] !== T_END_HEREDOC);
|
||||
$rawChunk = '';
|
||||
} elseif (!in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) {
|
||||
} elseif (T_WHITESPACE === $token[0]) {
|
||||
if ($ignoreSpace) {
|
||||
$ignoreSpace = false;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// replace multiple new lines with a single newline
|
||||
$rawChunk .= preg_replace(array('/\n{2,}/S'), "\n", $token[1]);
|
||||
} elseif (in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) {
|
||||
$ignoreSpace = true;
|
||||
} else {
|
||||
$rawChunk .= $token[1];
|
||||
|
||||
// The PHP-open tag already has a new-line
|
||||
if (T_OPEN_TAG === $token[0]) {
|
||||
$ignoreSpace = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// replace multiple new lines with a single newline
|
||||
$output .= preg_replace(array('/\s+$/Sm', '/\n+/S'), "\n", $rawChunk);
|
||||
$output .= $rawChunk;
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
@ -11,10 +11,12 @@
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Tests\EventListener;
|
||||
|
||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
|
||||
use Symfony\Component\HttpKernel\EventListener\ProfilerListener;
|
||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
||||
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
|
||||
class ProfilerListenerTest extends \PHPUnit_Framework_TestCase
|
||||
@ -52,4 +54,50 @@ class ProfilerListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$listener->onKernelResponse(new FilterResponseEvent($kernel, $request, Kernel::MASTER_REQUEST, $response));
|
||||
$listener->onKernelTerminate(new PostResponseEvent($kernel, $request, $response));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a master and sub request with an exception and `onlyException` profiler option enabled.
|
||||
*/
|
||||
public function testKernelTerminate()
|
||||
{
|
||||
$profile = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profile')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$profiler = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$profiler->expects($this->once())
|
||||
->method('collect')
|
||||
->will($this->returnValue($profile));
|
||||
|
||||
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
|
||||
|
||||
$masterRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$subRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$response = $this->getMockBuilder('Symfony\Component\HttpFoundation\Response')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$onlyException = true;
|
||||
$listener = new ProfilerListener($profiler, null, $onlyException);
|
||||
|
||||
// master request
|
||||
$listener->onKernelRequest(new GetResponseEvent($kernel, $masterRequest, Kernel::MASTER_REQUEST));
|
||||
$listener->onKernelResponse(new FilterResponseEvent($kernel, $masterRequest, Kernel::MASTER_REQUEST, $response));
|
||||
|
||||
// sub request
|
||||
$listener->onKernelRequest(new GetResponseEvent($kernel, $subRequest, Kernel::SUB_REQUEST));
|
||||
$listener->onKernelException(new GetResponseForExceptionEvent($kernel, $subRequest, Kernel::SUB_REQUEST, new HttpException(404)));
|
||||
$listener->onKernelResponse(new FilterResponseEvent($kernel, $subRequest, Kernel::SUB_REQUEST, $response));
|
||||
|
||||
$listener->onKernelTerminate(new PostResponseEvent($kernel, $masterRequest, $response));
|
||||
}
|
||||
}
|
||||
|
@ -208,6 +208,10 @@ class KernelTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$string = 'string should not be modified';
|
||||
|
||||
$string = 'string should not be
|
||||
|
||||
modified';
|
||||
|
||||
|
||||
$heredoc = <<<HD
|
||||
|
||||
@ -242,16 +246,17 @@ EOF;
|
||||
$expected = <<<'EOF'
|
||||
<?php
|
||||
$string = 'string should not be modified';
|
||||
$heredoc =
|
||||
<<<HD
|
||||
$string = 'string should not be
|
||||
|
||||
modified';
|
||||
$heredoc = <<<HD
|
||||
|
||||
|
||||
Heredoc should not be modified
|
||||
|
||||
|
||||
HD;
|
||||
$nowdoc =
|
||||
<<<'ND'
|
||||
$nowdoc = <<<'ND'
|
||||
|
||||
|
||||
Nowdoc should not be modified
|
||||
@ -262,7 +267,7 @@ class TestClass
|
||||
{
|
||||
public function doStuff()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF;
|
||||
|
||||
|
@ -99,6 +99,9 @@ class GetSetMethodNormalizer extends SerializerAwareNormalizer implements Normal
|
||||
$attributeValue = call_user_func($this->callbacks[$attributeName], $attributeValue);
|
||||
}
|
||||
if (null !== $attributeValue && !is_scalar($attributeValue)) {
|
||||
if (!$this->serializer instanceof NormalizerInterface) {
|
||||
throw new \LogicException(sprintf('Cannot normalize attribute "%s" because injected serializer is not a normalizer', $attributeName));
|
||||
}
|
||||
$attributeValue = $this->serializer->normalize($attributeValue, $format);
|
||||
}
|
||||
|
||||
|
@ -12,23 +12,42 @@
|
||||
namespace Symfony\Component\Serializer\Tests\Normalizer;
|
||||
|
||||
use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
||||
class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
$this->serializer = $this->getMock(__NAMESPACE__.'\SerializerNormalizer');
|
||||
$this->normalizer = new GetSetMethodNormalizer();
|
||||
$this->normalizer->setSerializer($this->getMock('Symfony\Component\Serializer\Serializer'));
|
||||
$this->normalizer->setSerializer($this->serializer);
|
||||
}
|
||||
|
||||
public function testNormalize()
|
||||
{
|
||||
$obj = new GetSetDummy();
|
||||
$object = new \stdClass();
|
||||
$obj->setFoo('foo');
|
||||
$obj->setBar('bar');
|
||||
$obj->setCamelCase('camelcase');
|
||||
$obj->setObject($object);
|
||||
|
||||
$this->serializer
|
||||
->expects($this->once())
|
||||
->method('normalize')
|
||||
->with($object, 'any')
|
||||
->will($this->returnValue('string_object'))
|
||||
;
|
||||
|
||||
$this->assertEquals(
|
||||
array('foo' => 'foo', 'bar' => 'bar', 'fooBar' => 'foobar', 'camelCase' => 'camelcase'),
|
||||
array(
|
||||
'foo' => 'foo',
|
||||
'bar' => 'bar',
|
||||
'fooBar' => 'foobar',
|
||||
'camelCase' => 'camelcase',
|
||||
'object' => 'string_object',
|
||||
),
|
||||
$this->normalizer->normalize($obj, 'any')
|
||||
);
|
||||
}
|
||||
@ -116,7 +135,7 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testIgnoredAttributes()
|
||||
{
|
||||
$this->normalizer->setIgnoredAttributes(array('foo', 'bar', 'camelCase'));
|
||||
$this->normalizer->setIgnoredAttributes(array('foo', 'bar', 'camelCase', 'object'));
|
||||
|
||||
$obj = new GetSetDummy();
|
||||
$obj->setFoo('foo');
|
||||
@ -188,6 +207,22 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Cannot normalize attribute "object" because injected serializer is not a normalizer
|
||||
*/
|
||||
public function testUnableToNormalizeObjectAttribute()
|
||||
{
|
||||
$serializer = $this->getMock('Symfony\Component\Serializer\SerializerInterface');
|
||||
$this->normalizer->setSerializer($serializer);
|
||||
|
||||
$obj = new GetSetDummy();
|
||||
$object = new \stdClass();
|
||||
$obj->setObject($object);
|
||||
|
||||
$this->normalizer->normalize($obj, 'any');
|
||||
}
|
||||
}
|
||||
|
||||
class GetSetDummy
|
||||
@ -195,6 +230,7 @@ class GetSetDummy
|
||||
protected $foo;
|
||||
private $bar;
|
||||
protected $camelCase;
|
||||
protected $object;
|
||||
|
||||
public function getFoo()
|
||||
{
|
||||
@ -235,6 +271,16 @@ class GetSetDummy
|
||||
{
|
||||
throw new \RuntimeException("Dummy::otherMethod() should not be called");
|
||||
}
|
||||
|
||||
public function setObject($object)
|
||||
{
|
||||
$this->object = $object;
|
||||
}
|
||||
|
||||
public function getObject()
|
||||
{
|
||||
return $this->object;
|
||||
}
|
||||
}
|
||||
|
||||
class GetConstructorDummy
|
||||
@ -263,3 +309,7 @@ class GetConstructorDummy
|
||||
throw new \RuntimeException("Dummy::otherMethod() should not be called");
|
||||
}
|
||||
}
|
||||
|
||||
abstract class SerializerNormalizer implements SerializerInterface, NormalizerInterface
|
||||
{
|
||||
}
|
||||
|
@ -220,7 +220,9 @@ class Inline
|
||||
throw new ParseException(sprintf('Malformed inline YAML string (%s).', $scalar));
|
||||
}
|
||||
|
||||
$output = $evaluate ? self::evaluateScalar($output) : $output;
|
||||
if ($evaluate) {
|
||||
$output = self::evaluateScalar($output);
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
@ -388,9 +390,9 @@ class Inline
|
||||
$scalar = trim($scalar);
|
||||
$scalarLower = strtolower($scalar);
|
||||
switch (true) {
|
||||
case 'null' == $scalarLower:
|
||||
case '' == $scalar:
|
||||
case '~' == $scalar:
|
||||
case 'null' === $scalarLower:
|
||||
case '' === $scalar:
|
||||
case '~' === $scalar:
|
||||
return null;
|
||||
case 'true' === $scalarLower:
|
||||
return true;
|
||||
@ -425,10 +427,10 @@ class Inline
|
||||
return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
|
||||
case is_numeric($scalar):
|
||||
return '0x' == $scalar[0].$scalar[1] ? hexdec($scalar) : floatval($scalar);
|
||||
case 0 == strcasecmp($scalar, '.inf'):
|
||||
case 0 == strcasecmp($scalar, '.NaN'):
|
||||
case '.inf' === $scalarLower:
|
||||
case '.nan' === $scalarLower:
|
||||
return -log(0);
|
||||
case 0 == strcasecmp($scalar, '-.inf'):
|
||||
case '-.inf' === $scalarLower:
|
||||
return log(0);
|
||||
case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $scalar):
|
||||
return floatval(str_replace(',', '', $scalar));
|
||||
|
Reference in New Issue
Block a user