Merge branch '2.3' into 2.4
* 2.3: changed some PHPUnit assertions to more specific ones fixed Kernel::stripComments() normalizing new-lines added a BC comment Update FileLoader to fix issue #10339
This commit is contained in:
commit
52f8dc7c1b
@ -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()
|
||||
|
@ -554,7 +554,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -735,7 +735,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
|
||||
|
@ -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()
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user