Merge branch '4.1' into 4.2
* 4.1: [Twig] Replace for-loops with blocks for attributes fixed CS [Tests] Change to willThrowException [Console] fix PHPDoc in Command Update FileLoaderLoadException.php Fix wrong calls to clearstatcache Add Vietnamese translation for validators Allow running PHPUnit with "xdebug.scream" ON [VarDumper] Add descriptors tests [Yaml] detect circular references [DI] fix reporting bindings on overriden services as unused [Routing] minor fix or previous PR
This commit is contained in:
commit
5ee0c04fd7
@ -98,7 +98,7 @@
|
|||||||
{% set label = name|humanize %}
|
{% set label = name|humanize %}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
|
<label{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
|
||||||
{{- widget|raw }} {{ label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans({}, translation_domain)) -}}
|
{{- widget|raw }} {{ label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans({}, translation_domain)) -}}
|
||||||
</label>
|
</label>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
|
@ -260,7 +260,7 @@
|
|||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
|
|
||||||
{{ widget|raw }}
|
{{ widget|raw }}
|
||||||
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
|
<label{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
|
||||||
{{- label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans({}, translation_domain)) -}}
|
{{- label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans({}, translation_domain)) -}}
|
||||||
{{- form_errors(form) -}}
|
{{- form_errors(form) -}}
|
||||||
</label>
|
</label>
|
||||||
|
@ -352,7 +352,7 @@
|
|||||||
{%- else -%}
|
{%- else -%}
|
||||||
{% set form_method = "POST" %}
|
{% set form_method = "POST" %}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
<form{% if name != '' %} name="{{ name }}"{% endif %} method="{{ form_method|lower }}"{% if action != '' %} action="{{ action }}"{% endif %}{% for attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}{% if multipart %} enctype="multipart/form-data"{% endif %}>
|
<form{% if name != '' %} name="{{ name }}"{% endif %} method="{{ form_method|lower }}"{% if action != '' %} action="{{ action }}"{% endif %}{{ block('attributes') }}{% if multipart %} enctype="multipart/form-data"{% endif %}>
|
||||||
{%- if form_method != method -%}
|
{%- if form_method != method -%}
|
||||||
<input type="hidden" name="_method" value="{{ method }}" />
|
<input type="hidden" name="_method" value="{{ method }}" />
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
|
@ -258,7 +258,7 @@
|
|||||||
{% set label = name|humanize %}
|
{% set label = name|humanize %}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
|
<label{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
|
||||||
{{ widget|raw }}
|
{{ widget|raw }}
|
||||||
{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}
|
{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}
|
||||||
</label>
|
</label>
|
||||||
|
@ -123,7 +123,7 @@ class TranslationDebugCommandTest extends TestCase
|
|||||||
$kernel->expects($this->once())
|
$kernel->expects($this->once())
|
||||||
->method('getBundle')
|
->method('getBundle')
|
||||||
->with($this->equalTo('dir'))
|
->with($this->equalTo('dir'))
|
||||||
->will($this->throwException(new \InvalidArgumentException()));
|
->willThrowException(new \InvalidArgumentException());
|
||||||
|
|
||||||
$tester = $this->createCommandTester(array(), array(), $kernel);
|
$tester = $this->createCommandTester(array(), array(), $kernel);
|
||||||
$tester->execute(array('locale' => 'en', 'bundle' => 'dir'));
|
$tester->execute(array('locale' => 'en', 'bundle' => 'dir'));
|
||||||
|
@ -60,7 +60,7 @@ class TemplateLocatorTest extends TestCase
|
|||||||
$fileLocator
|
$fileLocator
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('locate')
|
->method('locate')
|
||||||
->will($this->throwException(new \InvalidArgumentException($errorMessage)))
|
->willThrowException(new \InvalidArgumentException($errorMessage))
|
||||||
;
|
;
|
||||||
|
|
||||||
$locator = new TemplateLocator($fileLocator);
|
$locator = new TemplateLocator($fileLocator);
|
||||||
|
@ -68,7 +68,7 @@ class FilesystemLoaderTest extends TestCase
|
|||||||
$locator
|
$locator
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('locate')
|
->method('locate')
|
||||||
->will($this->throwException(new \InvalidArgumentException('Unable to find template "NonExistent".')))
|
->willThrowException(new \InvalidArgumentException('Unable to find template "NonExistent".'))
|
||||||
;
|
;
|
||||||
|
|
||||||
$loader = new FilesystemLoader($locator, $parser);
|
$loader = new FilesystemLoader($locator, $parser);
|
||||||
|
@ -252,7 +252,7 @@ class WebDebugToolbarListenerTest extends TestCase
|
|||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('generate')
|
->method('generate')
|
||||||
->with('_profiler', array('token' => 'xxxxxxxx'))
|
->with('_profiler', array('token' => 'xxxxxxxx'))
|
||||||
->will($this->throwException(new \Exception('foo')))
|
->willThrowException(new \Exception('foo'))
|
||||||
;
|
;
|
||||||
|
|
||||||
$event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response);
|
$event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response);
|
||||||
@ -273,7 +273,7 @@ class WebDebugToolbarListenerTest extends TestCase
|
|||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('generate')
|
->method('generate')
|
||||||
->with('_profiler', array('token' => 'xxxxxxxx'))
|
->with('_profiler', array('token' => 'xxxxxxxx'))
|
||||||
->will($this->throwException(new \Exception("This\nmultiline\r\ntabbed text should\tcome out\r on\n \ta single plain\r\nline")))
|
->willThrowException(new \Exception("This\nmultiline\r\ntabbed text should\tcome out\r on\n \ta single plain\r\nline"))
|
||||||
;
|
;
|
||||||
|
|
||||||
$event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response);
|
$event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response);
|
||||||
|
@ -44,17 +44,17 @@ class FileLoaderLoadException extends \Exception
|
|||||||
|
|
||||||
// show tweaked trace to complete the human readable sentence
|
// show tweaked trace to complete the human readable sentence
|
||||||
if (null === $sourceResource) {
|
if (null === $sourceResource) {
|
||||||
$message .= sprintf('(which is loaded in resource "%s")', $this->varToString($resource));
|
$message .= sprintf('(which is loaded in resource "%s")', $resource);
|
||||||
} else {
|
} else {
|
||||||
$message .= sprintf('(which is being imported from "%s")', $this->varToString($sourceResource));
|
$message .= sprintf('(which is being imported from "%s")', $sourceResource);
|
||||||
}
|
}
|
||||||
$message .= '.';
|
$message .= '.';
|
||||||
|
|
||||||
// if there's no previous message, present it the default way
|
// if there's no previous message, present it the default way
|
||||||
} elseif (null === $sourceResource) {
|
} elseif (null === $sourceResource) {
|
||||||
$message .= sprintf('Cannot load resource "%s".', $this->varToString($resource));
|
$message .= sprintf('Cannot load resource "%s".', $resource);
|
||||||
} else {
|
} else {
|
||||||
$message .= sprintf('Cannot import resource "%s" from "%s".', $this->varToString($resource), $this->varToString($sourceResource));
|
$message .= sprintf('Cannot import resource "%s" from "%s".', $resource, $sourceResource);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is the resource located inside a bundle?
|
// Is the resource located inside a bundle?
|
||||||
|
@ -361,9 +361,9 @@ class Command
|
|||||||
* Adds an argument.
|
* Adds an argument.
|
||||||
*
|
*
|
||||||
* @param string $name The argument name
|
* @param string $name The argument name
|
||||||
* @param int|null $mode The argument mode: self::REQUIRED or self::OPTIONAL
|
* @param int|null $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL
|
||||||
* @param string $description A description text
|
* @param string $description A description text
|
||||||
* @param string|string[]|null $default The default value (for self::OPTIONAL mode only)
|
* @param string|string[]|null $default The default value (for InputArgument::OPTIONAL mode only)
|
||||||
*
|
*
|
||||||
* @throws InvalidArgumentException When argument mode is not valid
|
* @throws InvalidArgumentException When argument mode is not valid
|
||||||
*
|
*
|
||||||
@ -381,9 +381,9 @@ class Command
|
|||||||
*
|
*
|
||||||
* @param string $name The option name
|
* @param string $name The option name
|
||||||
* @param string|array $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
|
* @param string|array $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
|
||||||
* @param int|null $mode The option mode: One of the VALUE_* constants
|
* @param int|null $mode The option mode: One of the InputOption::VALUE_* constants
|
||||||
* @param string $description A description text
|
* @param string $description A description text
|
||||||
* @param string|string[]|int|bool|null $default The default value (must be null for self::VALUE_NONE)
|
* @param string|string[]|int|bool|null $default The default value (must be null for InputOption::VALUE_NONE)
|
||||||
*
|
*
|
||||||
* @throws InvalidArgumentException If option mode is invalid or incompatible
|
* @throws InvalidArgumentException If option mode is invalid or incompatible
|
||||||
*
|
*
|
||||||
|
@ -1003,7 +1003,7 @@ class ApplicationTest extends TestCase
|
|||||||
$application->setAutoExit(false);
|
$application->setAutoExit(false);
|
||||||
$application->expects($this->once())
|
$application->expects($this->once())
|
||||||
->method('doRun')
|
->method('doRun')
|
||||||
->will($this->throwException($exception));
|
->willThrowException($exception);
|
||||||
|
|
||||||
$exitCode = $application->run(new ArrayInput(array()), new NullOutput());
|
$exitCode = $application->run(new ArrayInput(array()), new NullOutput());
|
||||||
|
|
||||||
@ -1042,7 +1042,7 @@ class ApplicationTest extends TestCase
|
|||||||
$application->setAutoExit(false);
|
$application->setAutoExit(false);
|
||||||
$application->expects($this->once())
|
$application->expects($this->once())
|
||||||
->method('doRun')
|
->method('doRun')
|
||||||
->will($this->throwException($exception));
|
->willThrowException($exception);
|
||||||
|
|
||||||
$exitCode = $application->run(new ArrayInput(array()), new NullOutput());
|
$exitCode = $application->run(new ArrayInput(array()), new NullOutput());
|
||||||
|
|
||||||
|
@ -34,6 +34,8 @@ class ResolveBindingsPass extends AbstractRecursivePass
|
|||||||
*/
|
*/
|
||||||
public function process(ContainerBuilder $container)
|
public function process(ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
|
$this->usedBindings = $container->getRemovedBindingIds();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
parent::process($container);
|
parent::process($container);
|
||||||
|
|
||||||
|
@ -124,6 +124,8 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||||||
|
|
||||||
private $removedIds = array();
|
private $removedIds = array();
|
||||||
|
|
||||||
|
private $removedBindingIds = array();
|
||||||
|
|
||||||
private static $internalTypes = array(
|
private static $internalTypes = array(
|
||||||
'int' => true,
|
'int' => true,
|
||||||
'float' => true,
|
'float' => true,
|
||||||
@ -500,7 +502,8 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||||||
throw new BadMethodCallException(sprintf('Setting service "%s" for an unknown or non-synthetic service definition on a compiled container is not allowed.', $id));
|
throw new BadMethodCallException(sprintf('Setting service "%s" for an unknown or non-synthetic service definition on a compiled container is not allowed.', $id));
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($this->definitions[$id], $this->aliasDefinitions[$id], $this->removedIds[$id]);
|
$this->removeId($id);
|
||||||
|
unset($this->removedIds[$id]);
|
||||||
|
|
||||||
parent::set($id, $service);
|
parent::set($id, $service);
|
||||||
}
|
}
|
||||||
@ -513,8 +516,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||||||
public function removeDefinition($id)
|
public function removeDefinition($id)
|
||||||
{
|
{
|
||||||
if (isset($this->definitions[$id = (string) $id])) {
|
if (isset($this->definitions[$id = (string) $id])) {
|
||||||
unset($this->definitions[$id]);
|
$this->removeId($id);
|
||||||
$this->removedIds[$id] = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -836,7 +838,8 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||||||
throw new InvalidArgumentException(sprintf('An alias can not reference itself, got a circular reference on "%s".', $alias));
|
throw new InvalidArgumentException(sprintf('An alias can not reference itself, got a circular reference on "%s".', $alias));
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($this->definitions[$alias], $this->removedIds[$alias]);
|
$this->removeId($alias);
|
||||||
|
unset($this->removedIds[$alias]);
|
||||||
|
|
||||||
return $this->aliasDefinitions[$alias] = $id;
|
return $this->aliasDefinitions[$alias] = $id;
|
||||||
}
|
}
|
||||||
@ -849,8 +852,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||||||
public function removeAlias($alias)
|
public function removeAlias($alias)
|
||||||
{
|
{
|
||||||
if (isset($this->aliasDefinitions[$alias = (string) $alias])) {
|
if (isset($this->aliasDefinitions[$alias = (string) $alias])) {
|
||||||
unset($this->aliasDefinitions[$alias]);
|
$this->removeId($alias);
|
||||||
$this->removedIds[$alias] = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -979,7 +981,8 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||||||
|
|
||||||
$id = (string) $id;
|
$id = (string) $id;
|
||||||
|
|
||||||
unset($this->aliasDefinitions[$id], $this->removedIds[$id]);
|
$this->removeId($id);
|
||||||
|
unset($this->removedIds[$id]);
|
||||||
|
|
||||||
return $this->definitions[$id] = $definition;
|
return $this->definitions[$id] = $definition;
|
||||||
}
|
}
|
||||||
@ -1508,6 +1511,18 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||||||
return $services;
|
return $services;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets removed binding ids.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
public function getRemovedBindingIds()
|
||||||
|
{
|
||||||
|
return $this->removedBindingIds;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes a reasonably unique hash of a value.
|
* Computes a reasonably unique hash of a value.
|
||||||
*
|
*
|
||||||
@ -1612,4 +1627,21 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function removeId($id)
|
||||||
|
{
|
||||||
|
$this->removedIds[$id] = true;
|
||||||
|
unset($this->aliasDefinitions[$id]);
|
||||||
|
|
||||||
|
if (!isset($this->definitions[$id])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->definitions[$id]->getBindings() as $binding) {
|
||||||
|
list(, $identifier) = $binding->getValues();
|
||||||
|
$this->removedBindingIds[$identifier] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($this->definitions[$id]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,6 +112,24 @@ class ResolveBindingsPassTest extends TestCase
|
|||||||
$this->assertEquals(array(array('setDefaultLocale', array('fr'))), $definition->getMethodCalls());
|
$this->assertEquals(array(array('setDefaultLocale', array('fr'))), $definition->getMethodCalls());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testOverriddenBindings()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
|
||||||
|
$binding = new BoundArgument('bar');
|
||||||
|
|
||||||
|
$container->register('foo', 'stdClass')
|
||||||
|
->setBindings(array('$foo' => clone $binding));
|
||||||
|
$container->register('bar', 'stdClass')
|
||||||
|
->setBindings(array('$foo' => clone $binding));
|
||||||
|
|
||||||
|
$container->register('foo', 'stdClass');
|
||||||
|
|
||||||
|
(new ResolveBindingsPass())->process($container);
|
||||||
|
|
||||||
|
$this->assertInstanceOf('stdClass', $container->get('foo'));
|
||||||
|
}
|
||||||
|
|
||||||
public function testTupleBinding()
|
public function testTupleBinding()
|
||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
|
@ -399,7 +399,7 @@ class ResolveChildDefinitionsPassTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
|
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
|
||||||
* @expectedExceptionMessageRegExp /^Circular reference detected for service "c", path: "c -> b -> a -> c"./
|
* @expectedExceptionMessageRegExp /^Circular reference detected for service "a", path: "a -> c -> b -> a"./
|
||||||
*/
|
*/
|
||||||
public function testProcessDetectsChildDefinitionIndirectCircularReference()
|
public function testProcessDetectsChildDefinitionIndirectCircularReference()
|
||||||
{
|
{
|
||||||
|
@ -559,7 +559,7 @@ class ContainerBuilderTest extends TestCase
|
|||||||
$config->setDefinition('baz', new Definition('BazClass'));
|
$config->setDefinition('baz', new Definition('BazClass'));
|
||||||
$config->setAlias('alias_for_foo', 'foo');
|
$config->setAlias('alias_for_foo', 'foo');
|
||||||
$container->merge($config);
|
$container->merge($config);
|
||||||
$this->assertEquals(array('service_container', 'foo', 'bar', 'baz'), array_keys($container->getDefinitions()), '->merge() merges definitions already defined ones');
|
$this->assertEquals(array('foo', 'bar', 'service_container', 'baz'), array_keys($container->getDefinitions()), '->merge() merges definitions already defined ones');
|
||||||
|
|
||||||
$aliases = $container->getAliases();
|
$aliases = $container->getAliases();
|
||||||
$this->assertArrayHasKey('alias_for_foo', $aliases);
|
$this->assertArrayHasKey('alias_for_foo', $aliases);
|
||||||
|
@ -4,6 +4,9 @@ services:
|
|||||||
class: Symfony\Component\DependencyInjection\ContainerInterface
|
class: Symfony\Component\DependencyInjection\ContainerInterface
|
||||||
public: true
|
public: true
|
||||||
synthetic: true
|
synthetic: true
|
||||||
|
foo:
|
||||||
|
class: App\FooService
|
||||||
|
public: true
|
||||||
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo:
|
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo:
|
||||||
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo
|
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo
|
||||||
public: true
|
public: true
|
||||||
@ -16,6 +19,3 @@ services:
|
|||||||
|
|
||||||
shared: false
|
shared: false
|
||||||
configurator: c
|
configurator: c
|
||||||
foo:
|
|
||||||
class: App\FooService
|
|
||||||
public: true
|
|
||||||
|
@ -4,15 +4,6 @@ services:
|
|||||||
class: Symfony\Component\DependencyInjection\ContainerInterface
|
class: Symfony\Component\DependencyInjection\ContainerInterface
|
||||||
public: true
|
public: true
|
||||||
synthetic: true
|
synthetic: true
|
||||||
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo:
|
|
||||||
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo
|
|
||||||
public: true
|
|
||||||
tags:
|
|
||||||
- { name: foo }
|
|
||||||
- { name: baz }
|
|
||||||
deprecated: '%service_id%'
|
|
||||||
arguments: [1]
|
|
||||||
factory: f
|
|
||||||
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar:
|
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar:
|
||||||
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar
|
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar
|
||||||
public: true
|
public: true
|
||||||
@ -23,3 +14,12 @@ services:
|
|||||||
lazy: true
|
lazy: true
|
||||||
arguments: [1]
|
arguments: [1]
|
||||||
factory: f
|
factory: f
|
||||||
|
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo:
|
||||||
|
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo
|
||||||
|
public: true
|
||||||
|
tags:
|
||||||
|
- { name: foo }
|
||||||
|
- { name: baz }
|
||||||
|
deprecated: '%service_id%'
|
||||||
|
arguments: [1]
|
||||||
|
factory: f
|
||||||
|
@ -4,15 +4,6 @@ services:
|
|||||||
class: Symfony\Component\DependencyInjection\ContainerInterface
|
class: Symfony\Component\DependencyInjection\ContainerInterface
|
||||||
public: true
|
public: true
|
||||||
synthetic: true
|
synthetic: true
|
||||||
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo:
|
|
||||||
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo
|
|
||||||
public: true
|
|
||||||
tags:
|
|
||||||
- { name: foo }
|
|
||||||
- { name: baz }
|
|
||||||
deprecated: '%service_id%'
|
|
||||||
arguments: [1]
|
|
||||||
factory: f
|
|
||||||
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar:
|
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar:
|
||||||
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar
|
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar
|
||||||
public: true
|
public: true
|
||||||
@ -23,3 +14,12 @@ services:
|
|||||||
lazy: true
|
lazy: true
|
||||||
arguments: [1]
|
arguments: [1]
|
||||||
factory: f
|
factory: f
|
||||||
|
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo:
|
||||||
|
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo
|
||||||
|
public: true
|
||||||
|
tags:
|
||||||
|
- { name: foo }
|
||||||
|
- { name: baz }
|
||||||
|
deprecated: '%service_id%'
|
||||||
|
arguments: [1]
|
||||||
|
factory: f
|
||||||
|
@ -1209,7 +1209,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
|||||||
|
|
||||||
// restore original permissions
|
// restore original permissions
|
||||||
chmod($testDir, 0777);
|
chmod($testDir, 0777);
|
||||||
clearstatcache($testDir);
|
clearstatcache(true, $testDir);
|
||||||
|
|
||||||
if ($couldRead) {
|
if ($couldRead) {
|
||||||
$this->markTestSkipped('could read test files while test requires unreadable');
|
$this->markTestSkipped('could read test files while test requires unreadable');
|
||||||
@ -1248,7 +1248,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
|||||||
|
|
||||||
// restore original permissions
|
// restore original permissions
|
||||||
chmod($testDir, 0777);
|
chmod($testDir, 0777);
|
||||||
clearstatcache($testDir);
|
clearstatcache(true, $testDir);
|
||||||
|
|
||||||
if ($couldRead) {
|
if ($couldRead) {
|
||||||
$this->markTestSkipped('could read test files while test requires unreadable');
|
$this->markTestSkipped('could read test files while test requires unreadable');
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
|
||||||
|
<file source-language="en" datatype="plaintext" original="file.ext">
|
||||||
|
<body>
|
||||||
|
<trans-unit id="28">
|
||||||
|
<source>This form should not contain extra fields.</source>
|
||||||
|
<target>Mẫu này không nên chứa trường mở rộng</target>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="29">
|
||||||
|
<source>The uploaded file was too large. Please try to upload a smaller file.</source>
|
||||||
|
<target>Tập tin tải lên quá lớn. Vui lòng thử lại với tập tin nhỏ hơn.</target>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="30">
|
||||||
|
<source>The CSRF token is invalid. Please try to resubmit the form.</source>
|
||||||
|
<target>CSRF token không hợp lệ. Vui lòng thử lại.</target>
|
||||||
|
</trans-unit>
|
||||||
|
</body>
|
||||||
|
</file>
|
||||||
|
</xliff>
|
@ -620,7 +620,7 @@ class SimpleFormTest extends AbstractFormTest
|
|||||||
$transformer = $this->getDataTransformer();
|
$transformer = $this->getDataTransformer();
|
||||||
$transformer->expects($this->once())
|
$transformer->expects($this->once())
|
||||||
->method('reverseTransform')
|
->method('reverseTransform')
|
||||||
->will($this->throwException(new TransformationFailedException()));
|
->willThrowException(new TransformationFailedException());
|
||||||
|
|
||||||
$form = $this->getBuilder()
|
$form = $this->getBuilder()
|
||||||
->addViewTransformer($transformer)
|
->addViewTransformer($transformer)
|
||||||
@ -636,7 +636,7 @@ class SimpleFormTest extends AbstractFormTest
|
|||||||
$transformer = $this->getDataTransformer();
|
$transformer = $this->getDataTransformer();
|
||||||
$transformer->expects($this->once())
|
$transformer->expects($this->once())
|
||||||
->method('reverseTransform')
|
->method('reverseTransform')
|
||||||
->will($this->throwException(new TransformationFailedException()));
|
->willThrowException(new TransformationFailedException());
|
||||||
|
|
||||||
$form = $this->getBuilder()
|
$form = $this->getBuilder()
|
||||||
->addModelTransformer($transformer)
|
->addModelTransformer($transformer)
|
||||||
|
@ -743,7 +743,10 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
|||||||
$fs->dumpFile($dir.$file, $code);
|
$fs->dumpFile($dir.$file, $code);
|
||||||
@chmod($dir.$file, 0666 & ~umask());
|
@chmod($dir.$file, 0666 & ~umask());
|
||||||
}
|
}
|
||||||
@unlink(\dirname($dir.$file).'.legacy');
|
$legacyFile = \dirname($dir.$file).'.legacy';
|
||||||
|
if (file_exists($legacyFile)) {
|
||||||
|
@unlink($legacyFile);
|
||||||
|
}
|
||||||
|
|
||||||
$cache->write($rootCode, $container->getResources());
|
$cache->write($rootCode, $container->getResources());
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ class TranslatorListenerTest extends TestCase
|
|||||||
$this->translator
|
$this->translator
|
||||||
->expects($this->at(0))
|
->expects($this->at(0))
|
||||||
->method('setLocale')
|
->method('setLocale')
|
||||||
->will($this->throwException(new \InvalidArgumentException()));
|
->willThrowException(new \InvalidArgumentException());
|
||||||
$this->translator
|
$this->translator
|
||||||
->expects($this->at(1))
|
->expects($this->at(1))
|
||||||
->method('setLocale')
|
->method('setLocale')
|
||||||
@ -85,7 +85,7 @@ class TranslatorListenerTest extends TestCase
|
|||||||
$this->translator
|
$this->translator
|
||||||
->expects($this->at(0))
|
->expects($this->at(0))
|
||||||
->method('setLocale')
|
->method('setLocale')
|
||||||
->will($this->throwException(new \InvalidArgumentException()));
|
->willThrowException(new \InvalidArgumentException());
|
||||||
$this->translator
|
$this->translator
|
||||||
->expects($this->at(1))
|
->expects($this->at(1))
|
||||||
->method('setLocale')
|
->method('setLocale')
|
||||||
|
@ -80,7 +80,7 @@ class HIncludeFragmentRendererTest extends TestCase
|
|||||||
$engine->expects($this->once())
|
$engine->expects($this->once())
|
||||||
->method('exists')
|
->method('exists')
|
||||||
->with('default')
|
->with('default')
|
||||||
->will($this->throwException(new \InvalidArgumentException()));
|
->willThrowException(new \InvalidArgumentException());
|
||||||
|
|
||||||
// only default
|
// only default
|
||||||
$strategy = new HIncludeFragmentRenderer($engine);
|
$strategy = new HIncludeFragmentRenderer($engine);
|
||||||
@ -93,7 +93,7 @@ class HIncludeFragmentRendererTest extends TestCase
|
|||||||
$engine->expects($this->once())
|
$engine->expects($this->once())
|
||||||
->method('exists')
|
->method('exists')
|
||||||
->with('loading...')
|
->with('loading...')
|
||||||
->will($this->throwException(new \RuntimeException()));
|
->willThrowException(new \RuntimeException());
|
||||||
|
|
||||||
// only default
|
// only default
|
||||||
$strategy = new HIncludeFragmentRenderer($engine);
|
$strategy = new HIncludeFragmentRenderer($engine);
|
||||||
|
@ -148,7 +148,7 @@ class BundleEntryReaderTest extends TestCase
|
|||||||
$this->readerImpl->expects($this->at(0))
|
$this->readerImpl->expects($this->at(0))
|
||||||
->method('read')
|
->method('read')
|
||||||
->with(self::RES_DIR, 'en_GB')
|
->with(self::RES_DIR, 'en_GB')
|
||||||
->will($this->throwException(new ResourceBundleNotFoundException()));
|
->willThrowException(new ResourceBundleNotFoundException());
|
||||||
|
|
||||||
$this->readerImpl->expects($this->at(1))
|
$this->readerImpl->expects($this->at(1))
|
||||||
->method('read')
|
->method('read')
|
||||||
@ -166,7 +166,7 @@ class BundleEntryReaderTest extends TestCase
|
|||||||
$this->readerImpl->expects($this->once())
|
$this->readerImpl->expects($this->once())
|
||||||
->method('read')
|
->method('read')
|
||||||
->with(self::RES_DIR, 'en_GB')
|
->with(self::RES_DIR, 'en_GB')
|
||||||
->will($this->throwException(new ResourceBundleNotFoundException()));
|
->willThrowException(new ResourceBundleNotFoundException());
|
||||||
|
|
||||||
$this->reader->readEntry(self::RES_DIR, 'en_GB', array('Entries', 'Bam'), false);
|
$this->reader->readEntry(self::RES_DIR, 'en_GB', array('Entries', 'Bam'), false);
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ DUMP;
|
|||||||
$message = new DummyMessage('dummy message');
|
$message = new DummyMessage('dummy message');
|
||||||
|
|
||||||
$bus = $this->getMockBuilder(MessageBusInterface::class)->getMock();
|
$bus = $this->getMockBuilder(MessageBusInterface::class)->getMock();
|
||||||
$bus->method('dispatch')->with($message)->will($this->throwException(new \RuntimeException('foo')));
|
$bus->method('dispatch')->with($message)->willThrowException(new \RuntimeException('foo'));
|
||||||
$bus = new TraceableMessageBus($bus);
|
$bus = new TraceableMessageBus($bus);
|
||||||
|
|
||||||
$collector = new MessengerDataCollector();
|
$collector = new MessengerDataCollector();
|
||||||
|
@ -70,7 +70,7 @@ class TraceableMessageBusTest extends TestCase
|
|||||||
$message = new DummyMessage('Hello');
|
$message = new DummyMessage('Hello');
|
||||||
|
|
||||||
$bus = $this->getMockBuilder(MessageBusInterface::class)->getMock();
|
$bus = $this->getMockBuilder(MessageBusInterface::class)->getMock();
|
||||||
$bus->expects($this->once())->method('dispatch')->with($message)->will($this->throwException($exception = new \RuntimeException('Meh.')));
|
$bus->expects($this->once())->method('dispatch')->with($message)->willThrowException($exception = new \RuntimeException('Meh.'));
|
||||||
|
|
||||||
$traceableBus = new TraceableMessageBus($bus);
|
$traceableBus = new TraceableMessageBus($bus);
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ class AuthenticationProviderManagerTest extends TestCase
|
|||||||
} elseif (null !== $exception) {
|
} elseif (null !== $exception) {
|
||||||
$provider->expects($this->once())
|
$provider->expects($this->once())
|
||||||
->method('authenticate')
|
->method('authenticate')
|
||||||
->will($this->throwException($this->getMockBuilder($exception)->setMethods(null)->getMock()))
|
->willThrowException($this->getMockBuilder($exception)->setMethods(null)->getMock())
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class DaoAuthenticationProviderTest extends TestCase
|
|||||||
$userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock();
|
$userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock();
|
||||||
$userProvider->expects($this->once())
|
$userProvider->expects($this->once())
|
||||||
->method('loadUserByUsername')
|
->method('loadUserByUsername')
|
||||||
->will($this->throwException(new UsernameNotFoundException()))
|
->willThrowException(new UsernameNotFoundException())
|
||||||
;
|
;
|
||||||
|
|
||||||
$provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock());
|
$provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock());
|
||||||
@ -56,7 +56,7 @@ class DaoAuthenticationProviderTest extends TestCase
|
|||||||
$userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock();
|
$userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock();
|
||||||
$userProvider->expects($this->once())
|
$userProvider->expects($this->once())
|
||||||
->method('loadUserByUsername')
|
->method('loadUserByUsername')
|
||||||
->will($this->throwException(new \RuntimeException()))
|
->willThrowException(new \RuntimeException())
|
||||||
;
|
;
|
||||||
|
|
||||||
$provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock());
|
$provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock());
|
||||||
|
@ -73,7 +73,7 @@ class LdapBindAuthenticationProviderTest extends TestCase
|
|||||||
$ldap
|
$ldap
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('bind')
|
->method('bind')
|
||||||
->will($this->throwException(new ConnectionException()))
|
->willThrowException(new ConnectionException())
|
||||||
;
|
;
|
||||||
$userChecker = $this->getMockBuilder(UserCheckerInterface::class)->getMock();
|
$userChecker = $this->getMockBuilder(UserCheckerInterface::class)->getMock();
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ class PreAuthenticatedAuthenticationProviderTest extends TestCase
|
|||||||
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
|
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
|
||||||
$userChecker->expects($this->once())
|
$userChecker->expects($this->once())
|
||||||
->method('checkPostAuth')
|
->method('checkPostAuth')
|
||||||
->will($this->throwException(new LockedException()))
|
->willThrowException(new LockedException())
|
||||||
;
|
;
|
||||||
|
|
||||||
$provider = $this->getProvider($user, $userChecker);
|
$provider = $this->getProvider($user, $userChecker);
|
||||||
|
@ -57,7 +57,7 @@ class RememberMeAuthenticationProviderTest extends TestCase
|
|||||||
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
|
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
|
||||||
$userChecker->expects($this->once())
|
$userChecker->expects($this->once())
|
||||||
->method('checkPreAuth')
|
->method('checkPreAuth')
|
||||||
->will($this->throwException(new DisabledException()));
|
->willThrowException(new DisabledException());
|
||||||
|
|
||||||
$provider = $this->getProvider($userChecker);
|
$provider = $this->getProvider($userChecker);
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class SimpleAuthenticationProviderTest extends TestCase
|
|||||||
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
|
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
|
||||||
$userChecker->expects($this->once())
|
$userChecker->expects($this->once())
|
||||||
->method('checkPreAuth')
|
->method('checkPreAuth')
|
||||||
->will($this->throwException(new DisabledException()));
|
->willThrowException(new DisabledException());
|
||||||
|
|
||||||
$authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock();
|
$authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock();
|
||||||
$authenticator->expects($this->once())
|
$authenticator->expects($this->once())
|
||||||
@ -64,7 +64,7 @@ class SimpleAuthenticationProviderTest extends TestCase
|
|||||||
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
|
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
|
||||||
$userChecker->expects($this->once())
|
$userChecker->expects($this->once())
|
||||||
->method('checkPostAuth')
|
->method('checkPostAuth')
|
||||||
->will($this->throwException(new LockedException()));
|
->willThrowException(new LockedException());
|
||||||
|
|
||||||
$authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock();
|
$authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock();
|
||||||
$authenticator->expects($this->once())
|
$authenticator->expects($this->once())
|
||||||
|
@ -48,7 +48,7 @@ class UserAuthenticationProviderTest extends TestCase
|
|||||||
$provider = $this->getProvider(false, false);
|
$provider = $this->getProvider(false, false);
|
||||||
$provider->expects($this->once())
|
$provider->expects($this->once())
|
||||||
->method('retrieveUser')
|
->method('retrieveUser')
|
||||||
->will($this->throwException(new UsernameNotFoundException()))
|
->willThrowException(new UsernameNotFoundException())
|
||||||
;
|
;
|
||||||
|
|
||||||
$provider->authenticate($this->getSupportedToken());
|
$provider->authenticate($this->getSupportedToken());
|
||||||
@ -62,7 +62,7 @@ class UserAuthenticationProviderTest extends TestCase
|
|||||||
$provider = $this->getProvider(false, true);
|
$provider = $this->getProvider(false, true);
|
||||||
$provider->expects($this->once())
|
$provider->expects($this->once())
|
||||||
->method('retrieveUser')
|
->method('retrieveUser')
|
||||||
->will($this->throwException(new UsernameNotFoundException()))
|
->willThrowException(new UsernameNotFoundException())
|
||||||
;
|
;
|
||||||
|
|
||||||
$provider->authenticate($this->getSupportedToken());
|
$provider->authenticate($this->getSupportedToken());
|
||||||
@ -90,7 +90,7 @@ class UserAuthenticationProviderTest extends TestCase
|
|||||||
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
|
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
|
||||||
$userChecker->expects($this->once())
|
$userChecker->expects($this->once())
|
||||||
->method('checkPreAuth')
|
->method('checkPreAuth')
|
||||||
->will($this->throwException(new CredentialsExpiredException()))
|
->willThrowException(new CredentialsExpiredException())
|
||||||
;
|
;
|
||||||
|
|
||||||
$provider = $this->getProvider($userChecker);
|
$provider = $this->getProvider($userChecker);
|
||||||
@ -110,7 +110,7 @@ class UserAuthenticationProviderTest extends TestCase
|
|||||||
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
|
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
|
||||||
$userChecker->expects($this->once())
|
$userChecker->expects($this->once())
|
||||||
->method('checkPostAuth')
|
->method('checkPostAuth')
|
||||||
->will($this->throwException(new AccountExpiredException()))
|
->willThrowException(new AccountExpiredException())
|
||||||
;
|
;
|
||||||
|
|
||||||
$provider = $this->getProvider($userChecker);
|
$provider = $this->getProvider($userChecker);
|
||||||
@ -135,7 +135,7 @@ class UserAuthenticationProviderTest extends TestCase
|
|||||||
;
|
;
|
||||||
$provider->expects($this->once())
|
$provider->expects($this->once())
|
||||||
->method('checkAuthentication')
|
->method('checkAuthentication')
|
||||||
->will($this->throwException(new BadCredentialsException()))
|
->willThrowException(new BadCredentialsException())
|
||||||
;
|
;
|
||||||
|
|
||||||
$provider->authenticate($this->getSupportedToken());
|
$provider->authenticate($this->getSupportedToken());
|
||||||
@ -154,7 +154,7 @@ class UserAuthenticationProviderTest extends TestCase
|
|||||||
;
|
;
|
||||||
$provider->expects($this->once())
|
$provider->expects($this->once())
|
||||||
->method('checkAuthentication')
|
->method('checkAuthentication')
|
||||||
->will($this->throwException(new BadCredentialsException('Foo')))
|
->willThrowException(new BadCredentialsException('Foo'))
|
||||||
;
|
;
|
||||||
|
|
||||||
$provider->authenticate($this->getSupportedToken());
|
$provider->authenticate($this->getSupportedToken());
|
||||||
|
@ -25,7 +25,7 @@ class ChainUserProviderTest extends TestCase
|
|||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('loadUserByUsername')
|
->method('loadUserByUsername')
|
||||||
->with($this->equalTo('foo'))
|
->with($this->equalTo('foo'))
|
||||||
->will($this->throwException(new UsernameNotFoundException('not found')))
|
->willThrowException(new UsernameNotFoundException('not found'))
|
||||||
;
|
;
|
||||||
|
|
||||||
$provider2 = $this->getProvider();
|
$provider2 = $this->getProvider();
|
||||||
@ -50,7 +50,7 @@ class ChainUserProviderTest extends TestCase
|
|||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('loadUserByUsername')
|
->method('loadUserByUsername')
|
||||||
->with($this->equalTo('foo'))
|
->with($this->equalTo('foo'))
|
||||||
->will($this->throwException(new UsernameNotFoundException('not found')))
|
->willThrowException(new UsernameNotFoundException('not found'))
|
||||||
;
|
;
|
||||||
|
|
||||||
$provider2 = $this->getProvider();
|
$provider2 = $this->getProvider();
|
||||||
@ -58,7 +58,7 @@ class ChainUserProviderTest extends TestCase
|
|||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('loadUserByUsername')
|
->method('loadUserByUsername')
|
||||||
->with($this->equalTo('foo'))
|
->with($this->equalTo('foo'))
|
||||||
->will($this->throwException(new UsernameNotFoundException('not found')))
|
->willThrowException(new UsernameNotFoundException('not found'))
|
||||||
;
|
;
|
||||||
|
|
||||||
$provider = new ChainUserProvider(array($provider1, $provider2));
|
$provider = new ChainUserProvider(array($provider1, $provider2));
|
||||||
@ -71,7 +71,7 @@ class ChainUserProviderTest extends TestCase
|
|||||||
$provider1
|
$provider1
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('refreshUser')
|
->method('refreshUser')
|
||||||
->will($this->throwException(new UnsupportedUserException('unsupported')))
|
->willThrowException(new UnsupportedUserException('unsupported'))
|
||||||
;
|
;
|
||||||
|
|
||||||
$provider2 = $this->getProvider();
|
$provider2 = $this->getProvider();
|
||||||
@ -91,7 +91,7 @@ class ChainUserProviderTest extends TestCase
|
|||||||
$provider1
|
$provider1
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('refreshUser')
|
->method('refreshUser')
|
||||||
->will($this->throwException(new UsernameNotFoundException('not found')))
|
->willThrowException(new UsernameNotFoundException('not found'))
|
||||||
;
|
;
|
||||||
|
|
||||||
$provider2 = $this->getProvider();
|
$provider2 = $this->getProvider();
|
||||||
@ -114,14 +114,14 @@ class ChainUserProviderTest extends TestCase
|
|||||||
$provider1
|
$provider1
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('refreshUser')
|
->method('refreshUser')
|
||||||
->will($this->throwException(new UnsupportedUserException('unsupported')))
|
->willThrowException(new UnsupportedUserException('unsupported'))
|
||||||
;
|
;
|
||||||
|
|
||||||
$provider2 = $this->getProvider();
|
$provider2 = $this->getProvider();
|
||||||
$provider2
|
$provider2
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('refreshUser')
|
->method('refreshUser')
|
||||||
->will($this->throwException(new UnsupportedUserException('unsupported')))
|
->willThrowException(new UnsupportedUserException('unsupported'))
|
||||||
;
|
;
|
||||||
|
|
||||||
$provider = new ChainUserProvider(array($provider1, $provider2));
|
$provider = new ChainUserProvider(array($provider1, $provider2));
|
||||||
@ -178,7 +178,7 @@ class ChainUserProviderTest extends TestCase
|
|||||||
$provider1
|
$provider1
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('refreshUser')
|
->method('refreshUser')
|
||||||
->will($this->throwException(new UnsupportedUserException('unsupported')))
|
->willThrowException(new UnsupportedUserException('unsupported'))
|
||||||
;
|
;
|
||||||
|
|
||||||
$provider2 = $this->getProvider();
|
$provider2 = $this->getProvider();
|
||||||
|
@ -33,7 +33,7 @@ class LdapUserProviderTest extends TestCase
|
|||||||
$ldap
|
$ldap
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('bind')
|
->method('bind')
|
||||||
->will($this->throwException(new ConnectionException()))
|
->willThrowException(new ConnectionException())
|
||||||
;
|
;
|
||||||
|
|
||||||
$provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com');
|
$provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com');
|
||||||
|
@ -183,7 +183,7 @@ class GuardAuthenticationListenerTest extends TestCase
|
|||||||
$authenticator
|
$authenticator
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getCredentials')
|
->method('getCredentials')
|
||||||
->will($this->throwException($authException));
|
->willThrowException($authException);
|
||||||
|
|
||||||
// this is not called
|
// this is not called
|
||||||
$this->authenticationManager
|
$this->authenticationManager
|
||||||
|
@ -90,7 +90,7 @@ class AbstractPreAuthenticatedListenerTest extends TestCase
|
|||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('authenticate')
|
->method('authenticate')
|
||||||
->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken'))
|
->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken'))
|
||||||
->will($this->throwException($exception))
|
->willThrowException($exception)
|
||||||
;
|
;
|
||||||
|
|
||||||
$listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array(
|
$listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array(
|
||||||
@ -138,7 +138,7 @@ class AbstractPreAuthenticatedListenerTest extends TestCase
|
|||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('authenticate')
|
->method('authenticate')
|
||||||
->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken'))
|
->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken'))
|
||||||
->will($this->throwException($exception))
|
->willThrowException($exception)
|
||||||
;
|
;
|
||||||
|
|
||||||
$listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array(
|
$listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array(
|
||||||
@ -228,7 +228,7 @@ class AbstractPreAuthenticatedListenerTest extends TestCase
|
|||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('authenticate')
|
->method('authenticate')
|
||||||
->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken'))
|
->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken'))
|
||||||
->will($this->throwException($exception))
|
->willThrowException($exception)
|
||||||
;
|
;
|
||||||
|
|
||||||
$listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array(
|
$listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array(
|
||||||
|
@ -90,7 +90,7 @@ class RememberMeListenerTest extends TestCase
|
|||||||
$manager
|
$manager
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('authenticate')
|
->method('authenticate')
|
||||||
->will($this->throwException($exception))
|
->willThrowException($exception)
|
||||||
;
|
;
|
||||||
|
|
||||||
$event = $this->getGetResponseEvent();
|
$event = $this->getGetResponseEvent();
|
||||||
@ -132,7 +132,7 @@ class RememberMeListenerTest extends TestCase
|
|||||||
$manager
|
$manager
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('authenticate')
|
->method('authenticate')
|
||||||
->will($this->throwException($exception))
|
->willThrowException($exception)
|
||||||
;
|
;
|
||||||
|
|
||||||
$event = $this->getGetResponseEvent();
|
$event = $this->getGetResponseEvent();
|
||||||
@ -159,7 +159,7 @@ class RememberMeListenerTest extends TestCase
|
|||||||
$service
|
$service
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('autoLogin')
|
->method('autoLogin')
|
||||||
->will($this->throwException($exception))
|
->willThrowException($exception)
|
||||||
;
|
;
|
||||||
|
|
||||||
$service
|
$service
|
||||||
|
@ -75,7 +75,7 @@ class SimplePreAuthenticationListenerTest extends TestCase
|
|||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('authenticate')
|
->method('authenticate')
|
||||||
->with($this->equalTo($this->token))
|
->with($this->equalTo($this->token))
|
||||||
->will($this->throwException($exception))
|
->willThrowException($exception)
|
||||||
;
|
;
|
||||||
|
|
||||||
$this->tokenStorage->expects($this->once())
|
$this->tokenStorage->expects($this->once())
|
||||||
|
@ -200,7 +200,7 @@ class HttpUtilsTest extends TestCase
|
|||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('match')
|
->method('match')
|
||||||
->with('/')
|
->with('/')
|
||||||
->will($this->throwException(new ResourceNotFoundException()))
|
->willThrowException(new ResourceNotFoundException())
|
||||||
;
|
;
|
||||||
|
|
||||||
$utils = new HttpUtils(null, $urlMatcher);
|
$utils = new HttpUtils(null, $urlMatcher);
|
||||||
@ -215,7 +215,7 @@ class HttpUtilsTest extends TestCase
|
|||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('matchRequest')
|
->method('matchRequest')
|
||||||
->with($request)
|
->with($request)
|
||||||
->will($this->throwException(new MethodNotAllowedException(array())))
|
->willThrowException(new MethodNotAllowedException(array()))
|
||||||
;
|
;
|
||||||
|
|
||||||
$utils = new HttpUtils(null, $urlMatcher);
|
$utils = new HttpUtils(null, $urlMatcher);
|
||||||
@ -260,7 +260,7 @@ class HttpUtilsTest extends TestCase
|
|||||||
$urlMatcher
|
$urlMatcher
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('match')
|
->method('match')
|
||||||
->will($this->throwException(new \RuntimeException()))
|
->willThrowException(new \RuntimeException())
|
||||||
;
|
;
|
||||||
|
|
||||||
$utils = new HttpUtils(null, $urlMatcher);
|
$utils = new HttpUtils(null, $urlMatcher);
|
||||||
|
@ -66,7 +66,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
|
|||||||
$tokenProvider
|
$tokenProvider
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('loadTokenBySeries')
|
->method('loadTokenBySeries')
|
||||||
->will($this->throwException(new TokenNotFoundException('Token not found.')))
|
->willThrowException(new TokenNotFoundException('Token not found.'))
|
||||||
;
|
;
|
||||||
$service->setTokenProvider($tokenProvider);
|
$service->setTokenProvider($tokenProvider);
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
|
|||||||
$userProvider
|
$userProvider
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('loadUserByUsername')
|
->method('loadUserByUsername')
|
||||||
->will($this->throwException(new UsernameNotFoundException('user not found')))
|
->willThrowException(new UsernameNotFoundException('user not found'))
|
||||||
;
|
;
|
||||||
|
|
||||||
$this->assertNull($service->autoLogin($request));
|
$this->assertNull($service->autoLogin($request));
|
||||||
|
@ -50,7 +50,7 @@ class TokenBasedRememberMeServicesTest extends TestCase
|
|||||||
$userProvider
|
$userProvider
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('loadUserByUsername')
|
->method('loadUserByUsername')
|
||||||
->will($this->throwException(new UsernameNotFoundException('user not found')))
|
->willThrowException(new UsernameNotFoundException('user not found'))
|
||||||
;
|
;
|
||||||
|
|
||||||
$this->assertNull($service->autoLogin($request));
|
$this->assertNull($service->autoLogin($request));
|
||||||
|
@ -57,7 +57,7 @@ class HtmlDescriptor implements DumpDescriptorInterface
|
|||||||
$sourceDescription = '';
|
$sourceDescription = '';
|
||||||
if (isset($context['source'])) {
|
if (isset($context['source'])) {
|
||||||
$source = $context['source'];
|
$source = $context['source'];
|
||||||
$projectDir = $source['project_dir'];
|
$projectDir = $source['project_dir'] ?? null;
|
||||||
$sourceDescription = sprintf('%s on line %d', $source['name'], $source['line']);
|
$sourceDescription = sprintf('%s on line %d', $source['name'], $source['line']);
|
||||||
if (isset($source['file_link'])) {
|
if (isset($source['file_link'])) {
|
||||||
$sourceDescription = sprintf('<a href="%s">%s</a>', $source['file_link'], $sourceDescription);
|
$sourceDescription = sprintf('<a href="%s">%s</a>', $source['file_link'], $sourceDescription);
|
||||||
|
@ -0,0 +1,134 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\VarDumper\Tests\Command\Descriptor;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Component\Console\Output\BufferedOutput;
|
||||||
|
use Symfony\Component\VarDumper\Cloner\Data;
|
||||||
|
use Symfony\Component\VarDumper\Command\Descriptor\CliDescriptor;
|
||||||
|
use Symfony\Component\VarDumper\Dumper\CliDumper;
|
||||||
|
|
||||||
|
class CliDescriptorTest extends TestCase
|
||||||
|
{
|
||||||
|
private static $timezone;
|
||||||
|
|
||||||
|
public static function setUpBeforeClass()
|
||||||
|
{
|
||||||
|
self::$timezone = date_default_timezone_get();
|
||||||
|
date_default_timezone_set('UTC');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function tearDownAfterClass()
|
||||||
|
{
|
||||||
|
date_default_timezone_set(self::$timezone);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider provideContext
|
||||||
|
*/
|
||||||
|
public function testDescribe(array $context, string $expectedOutput)
|
||||||
|
{
|
||||||
|
$output = new BufferedOutput();
|
||||||
|
$descriptor = new CliDescriptor(new CliDumper(function ($s) {
|
||||||
|
return $s;
|
||||||
|
}));
|
||||||
|
|
||||||
|
$descriptor->describe($output, new Data(array(array(123))), $context + array('timestamp' => 1544804268.3668), 1);
|
||||||
|
|
||||||
|
$this->assertStringMatchesFormat(trim($expectedOutput), str_replace(PHP_EOL, "\n", trim($output->fetch())));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideContext()
|
||||||
|
{
|
||||||
|
yield 'source' => array(
|
||||||
|
array(
|
||||||
|
'source' => array(
|
||||||
|
'name' => 'CliDescriptorTest.php',
|
||||||
|
'line' => 30,
|
||||||
|
'file' => '/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
<<<TXT
|
||||||
|
Received from client #1
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
-------- ---------------------------------------------------------------------------------------------------
|
||||||
|
date Fri, 14 Dec 2018 16:17:48 +0000
|
||||||
|
source CliDescriptorTest.php on line 30
|
||||||
|
file /Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php
|
||||||
|
-------- ---------------------------------------------------------------------------------------------------
|
||||||
|
TXT
|
||||||
|
);
|
||||||
|
|
||||||
|
yield 'source full' => array(
|
||||||
|
array(
|
||||||
|
'source' => array(
|
||||||
|
'name' => 'CliDescriptorTest.php',
|
||||||
|
'line' => 30,
|
||||||
|
'file_relative' => 'src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php',
|
||||||
|
'file' => '/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php',
|
||||||
|
'file_link' => 'phpstorm://open?file=/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php&line=30',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
<<<TXT
|
||||||
|
Received from client #1
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
-------- --------------------------------------------------------------------------------
|
||||||
|
date Fri, 14 Dec 2018 16:17:48 +0000
|
||||||
|
source CliDescriptorTest.php on line 30
|
||||||
|
file src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php
|
||||||
|
-------- --------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Open source in your IDE/browser:
|
||||||
|
phpstorm://open?file=/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php&line=30
|
||||||
|
TXT
|
||||||
|
);
|
||||||
|
|
||||||
|
yield 'cli' => array(
|
||||||
|
array(
|
||||||
|
'cli' => array(
|
||||||
|
'identifier' => 'd8bece1c',
|
||||||
|
'command_line' => 'bin/phpunit',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
<<<TXT
|
||||||
|
$ bin/phpunit
|
||||||
|
-------------
|
||||||
|
|
||||||
|
------ ---------------------------------
|
||||||
|
date Fri, 14 Dec 2018 16:17:48 +0000
|
||||||
|
------ ---------------------------------
|
||||||
|
TXT
|
||||||
|
);
|
||||||
|
|
||||||
|
yield 'request' => array(
|
||||||
|
array(
|
||||||
|
'request' => array(
|
||||||
|
'identifier' => 'd8bece1c',
|
||||||
|
'controller' => new Data(array(array('FooController.php'))),
|
||||||
|
'method' => 'GET',
|
||||||
|
'uri' => 'http://localhost/foo',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
<<<TXT
|
||||||
|
GET http://localhost/foo
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
------------ ---------------------------------
|
||||||
|
date Fri, 14 Dec 2018 16:17:48 +0000
|
||||||
|
controller "FooController.php"
|
||||||
|
------------ ---------------------------------
|
||||||
|
TXT
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,195 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\VarDumper\Tests\Command\Descriptor;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Component\Console\Output\BufferedOutput;
|
||||||
|
use Symfony\Component\VarDumper\Cloner\Data;
|
||||||
|
use Symfony\Component\VarDumper\Command\Descriptor\HtmlDescriptor;
|
||||||
|
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
|
||||||
|
|
||||||
|
class HtmlDescriptorTest extends TestCase
|
||||||
|
{
|
||||||
|
private static $timezone;
|
||||||
|
|
||||||
|
public static function setUpBeforeClass()
|
||||||
|
{
|
||||||
|
self::$timezone = date_default_timezone_get();
|
||||||
|
date_default_timezone_set('UTC');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function tearDownAfterClass()
|
||||||
|
{
|
||||||
|
date_default_timezone_set(self::$timezone);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testItOutputsStylesAndScriptsOnFirstDescribeCall()
|
||||||
|
{
|
||||||
|
$output = new BufferedOutput();
|
||||||
|
$dumper = $this->createMock(HtmlDumper::class);
|
||||||
|
$dumper->method('dump')->willReturn('[DUMPED]');
|
||||||
|
$descriptor = new HtmlDescriptor($dumper);
|
||||||
|
|
||||||
|
$descriptor->describe($output, new Data(array(array(123))), array('timestamp' => 1544804268.3668), 1);
|
||||||
|
|
||||||
|
$this->assertStringMatchesFormat('<style>%A</style><script>%A</script>%A', $output->fetch(), 'styles & scripts are output');
|
||||||
|
|
||||||
|
$descriptor->describe($output, new Data(array(array(123))), array('timestamp' => 1544804268.3668), 1);
|
||||||
|
|
||||||
|
$this->assertStringNotMatchesFormat('<style>%A</style><script>%A</script>%A', $output->fetch(), 'styles & scripts are output only once');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider provideContext
|
||||||
|
*/
|
||||||
|
public function testDescribe(array $context, string $expectedOutput)
|
||||||
|
{
|
||||||
|
$output = new BufferedOutput();
|
||||||
|
$dumper = $this->createMock(HtmlDumper::class);
|
||||||
|
$dumper->method('dump')->willReturn('[DUMPED]');
|
||||||
|
$descriptor = new HtmlDescriptor($dumper);
|
||||||
|
|
||||||
|
$descriptor->describe($output, new Data(array(array(123))), $context + array('timestamp' => 1544804268.3668), 1);
|
||||||
|
|
||||||
|
$this->assertStringMatchesFormat(trim($expectedOutput), trim(preg_replace('@<style>.*</style><script>.*</script>@s', '', $output->fetch())));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideContext()
|
||||||
|
{
|
||||||
|
yield 'source' => array(
|
||||||
|
array(
|
||||||
|
'source' => array(
|
||||||
|
'name' => 'CliDescriptorTest.php',
|
||||||
|
'line' => 30,
|
||||||
|
'file' => '/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
<<<TXT
|
||||||
|
<article data-dedup-id="%s">
|
||||||
|
<header>
|
||||||
|
<div class="row">
|
||||||
|
<h2 class="col">-</h2>
|
||||||
|
<time class="col text-small" title="2018-12-14T16:17:48+00:00" datetime="2018-12-14T16:17:48+00:00">
|
||||||
|
Fri, 14 Dec 2018 16:17:48 +0000
|
||||||
|
</time>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</header>
|
||||||
|
<section class="body">
|
||||||
|
<p class="text-small">
|
||||||
|
CliDescriptorTest.php on line 30
|
||||||
|
</p>
|
||||||
|
[DUMPED]
|
||||||
|
</section>
|
||||||
|
</article>
|
||||||
|
TXT
|
||||||
|
);
|
||||||
|
|
||||||
|
yield 'source full' => array(
|
||||||
|
array(
|
||||||
|
'source' => array(
|
||||||
|
'name' => 'CliDescriptorTest.php',
|
||||||
|
'project_dir' => 'src/Symfony/',
|
||||||
|
'line' => 30,
|
||||||
|
'file_relative' => 'src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php',
|
||||||
|
'file' => '/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php',
|
||||||
|
'file_link' => 'phpstorm://open?file=/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php&line=30',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
<<<TXT
|
||||||
|
<article data-dedup-id="%s">
|
||||||
|
<header>
|
||||||
|
<div class="row">
|
||||||
|
<h2 class="col">-</h2>
|
||||||
|
<time class="col text-small" title="2018-12-14T16:17:48+00:00" datetime="2018-12-14T16:17:48+00:00">
|
||||||
|
Fri, 14 Dec 2018 16:17:48 +0000
|
||||||
|
</time>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<ul class="tags">
|
||||||
|
<li><span class="badge">project dir</span>src/Symfony/</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<section class="body">
|
||||||
|
<p class="text-small">
|
||||||
|
<a href="phpstorm://open?file=/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php&line=30">CliDescriptorTest.php on line 30</a>
|
||||||
|
</p>
|
||||||
|
[DUMPED]
|
||||||
|
</section>
|
||||||
|
</article>
|
||||||
|
TXT
|
||||||
|
);
|
||||||
|
|
||||||
|
yield 'cli' => array(
|
||||||
|
array(
|
||||||
|
'cli' => array(
|
||||||
|
'identifier' => 'd8bece1c',
|
||||||
|
'command_line' => 'bin/phpunit',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
<<<TXT
|
||||||
|
<article data-dedup-id="d8bece1c">
|
||||||
|
<header>
|
||||||
|
<div class="row">
|
||||||
|
<h2 class="col"><code>$ </code>bin/phpunit</h2>
|
||||||
|
<time class="col text-small" title="2018-12-14T16:17:48+00:00" datetime="2018-12-14T16:17:48+00:00">
|
||||||
|
Fri, 14 Dec 2018 16:17:48 +0000
|
||||||
|
</time>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</header>
|
||||||
|
<section class="body">
|
||||||
|
<p class="text-small">
|
||||||
|
|
||||||
|
</p>
|
||||||
|
[DUMPED]
|
||||||
|
</section>
|
||||||
|
</article>
|
||||||
|
TXT
|
||||||
|
);
|
||||||
|
|
||||||
|
yield 'request' => array(
|
||||||
|
array(
|
||||||
|
'request' => array(
|
||||||
|
'identifier' => 'd8bece1c',
|
||||||
|
'controller' => new Data(array(array('FooController.php'))),
|
||||||
|
'method' => 'GET',
|
||||||
|
'uri' => 'http://localhost/foo',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
<<<TXT
|
||||||
|
<article data-dedup-id="d8bece1c">
|
||||||
|
<header>
|
||||||
|
<div class="row">
|
||||||
|
<h2 class="col"><code>GET</code> <a href="http://localhost/foo">http://localhost/foo</a></h2>
|
||||||
|
<time class="col text-small" title="2018-12-14T16:17:48+00:00" datetime="2018-12-14T16:17:48+00:00">
|
||||||
|
Fri, 14 Dec 2018 16:17:48 +0000
|
||||||
|
</time>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<ul class="tags">
|
||||||
|
<li><span class="badge">controller</span><span class='dumped-tag'>[DUMPED]</span></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<section class="body">
|
||||||
|
<p class="text-small">
|
||||||
|
|
||||||
|
</p>
|
||||||
|
[DUMPED]
|
||||||
|
</section>
|
||||||
|
</article>
|
||||||
|
TXT
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -22,6 +22,7 @@
|
|||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"ext-iconv": "*",
|
"ext-iconv": "*",
|
||||||
|
"symfony/console": "~3.4|~4.0",
|
||||||
"symfony/process": "~3.4|~4.0",
|
"symfony/process": "~3.4|~4.0",
|
||||||
"twig/twig": "~1.34|~2.4"
|
"twig/twig": "~1.34|~2.4"
|
||||||
},
|
},
|
||||||
|
@ -35,6 +35,7 @@ class Parser
|
|||||||
private $refs = array();
|
private $refs = array();
|
||||||
private $skippedLineNumbers = array();
|
private $skippedLineNumbers = array();
|
||||||
private $locallySkippedLineNumbers = array();
|
private $locallySkippedLineNumbers = array();
|
||||||
|
private $refsBeingParsed = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a YAML file into a PHP value.
|
* Parses a YAML file into a PHP value.
|
||||||
@ -169,6 +170,7 @@ class Parser
|
|||||||
|
|
||||||
if (isset($values['value']) && '&' === $values['value'][0] && self::preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#u', $values['value'], $matches)) {
|
if (isset($values['value']) && '&' === $values['value'][0] && self::preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#u', $values['value'], $matches)) {
|
||||||
$isRef = $matches['ref'];
|
$isRef = $matches['ref'];
|
||||||
|
$this->refsBeingParsed[] = $isRef;
|
||||||
$values['value'] = $matches['value'];
|
$values['value'] = $matches['value'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,6 +203,7 @@ class Parser
|
|||||||
}
|
}
|
||||||
if ($isRef) {
|
if ($isRef) {
|
||||||
$this->refs[$isRef] = end($data);
|
$this->refs[$isRef] = end($data);
|
||||||
|
array_pop($this->refsBeingParsed);
|
||||||
}
|
}
|
||||||
} elseif (
|
} elseif (
|
||||||
self::preg_match('#^(?P<key>(?:![^\s]++\s++)?(?:'.Inline::REGEX_QUOTED_STRING.'|(?:!?!php/const:)?[^ \'"\[\{!].*?)) *\:(\s++(?P<value>.+))?$#u', rtrim($this->currentLine), $values)
|
self::preg_match('#^(?P<key>(?:![^\s]++\s++)?(?:'.Inline::REGEX_QUOTED_STRING.'|(?:!?!php/const:)?[^ \'"\[\{!].*?)) *\:(\s++(?P<value>.+))?$#u', rtrim($this->currentLine), $values)
|
||||||
@ -235,6 +238,10 @@ class Parser
|
|||||||
if (isset($values['value'][0]) && '*' === $values['value'][0]) {
|
if (isset($values['value'][0]) && '*' === $values['value'][0]) {
|
||||||
$refName = substr(rtrim($values['value']), 1);
|
$refName = substr(rtrim($values['value']), 1);
|
||||||
if (!array_key_exists($refName, $this->refs)) {
|
if (!array_key_exists($refName, $this->refs)) {
|
||||||
|
if (false !== $pos = array_search($refName, $this->refsBeingParsed, true)) {
|
||||||
|
throw new ParseException(sprintf('Circular reference [%s, %s] detected for reference "%s".', implode(', ', \array_slice($this->refsBeingParsed, $pos)), $refName, $refName), $this->currentLineNb + 1, $this->currentLine, $this->filename);
|
||||||
|
}
|
||||||
|
|
||||||
throw new ParseException(sprintf('Reference "%s" does not exist.', $refName), $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
|
throw new ParseException(sprintf('Reference "%s" does not exist.', $refName), $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,6 +295,7 @@ class Parser
|
|||||||
}
|
}
|
||||||
} elseif ('<<' !== $key && isset($values['value']) && '&' === $values['value'][0] && self::preg_match('#^&(?P<ref>[^ ]++) *+(?P<value>.*)#u', $values['value'], $matches)) {
|
} elseif ('<<' !== $key && isset($values['value']) && '&' === $values['value'][0] && self::preg_match('#^&(?P<ref>[^ ]++) *+(?P<value>.*)#u', $values['value'], $matches)) {
|
||||||
$isRef = $matches['ref'];
|
$isRef = $matches['ref'];
|
||||||
|
$this->refsBeingParsed[] = $isRef;
|
||||||
$values['value'] = $matches['value'];
|
$values['value'] = $matches['value'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,6 +353,7 @@ class Parser
|
|||||||
}
|
}
|
||||||
if ($isRef) {
|
if ($isRef) {
|
||||||
$this->refs[$isRef] = $data[$key];
|
$this->refs[$isRef] = $data[$key];
|
||||||
|
array_pop($this->refsBeingParsed);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// multiple documents are not supported
|
// multiple documents are not supported
|
||||||
@ -450,6 +459,7 @@ class Parser
|
|||||||
$parser->totalNumberOfLines = $this->totalNumberOfLines;
|
$parser->totalNumberOfLines = $this->totalNumberOfLines;
|
||||||
$parser->skippedLineNumbers = $skippedLineNumbers;
|
$parser->skippedLineNumbers = $skippedLineNumbers;
|
||||||
$parser->refs = &$this->refs;
|
$parser->refs = &$this->refs;
|
||||||
|
$parser->refsBeingParsed = $this->refsBeingParsed;
|
||||||
|
|
||||||
return $parser->doParse($yaml, $flags);
|
return $parser->doParse($yaml, $flags);
|
||||||
}
|
}
|
||||||
@ -639,6 +649,10 @@ class Parser
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!array_key_exists($value, $this->refs)) {
|
if (!array_key_exists($value, $this->refs)) {
|
||||||
|
if (false !== $pos = array_search($value, $this->refsBeingParsed, true)) {
|
||||||
|
throw new ParseException(sprintf('Circular reference [%s, %s] detected for reference "%s".', implode(', ', \array_slice($this->refsBeingParsed, $pos)), $value, $value), $this->currentLineNb + 1, $this->currentLine, $this->filename);
|
||||||
|
}
|
||||||
|
|
||||||
throw new ParseException(sprintf('Reference "%s" does not exist.', $value), $this->currentLineNb + 1, $this->currentLine, $this->filename);
|
throw new ParseException(sprintf('Reference "%s" does not exist.', $value), $this->currentLineNb + 1, $this->currentLine, $this->filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2023,6 +2023,48 @@ EOE;
|
|||||||
$this->parser->parse($yaml);
|
$this->parser->parse($yaml);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider circularReferenceProvider
|
||||||
|
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||||
|
* @expectedExceptionMessage Circular reference [foo, bar, foo] detected
|
||||||
|
*/
|
||||||
|
public function testDetectCircularReferences($yaml)
|
||||||
|
{
|
||||||
|
$this->parser->parse($yaml, Yaml::PARSE_CUSTOM_TAGS);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function circularReferenceProvider()
|
||||||
|
{
|
||||||
|
$tests = array();
|
||||||
|
|
||||||
|
$yaml = <<<YAML
|
||||||
|
foo:
|
||||||
|
- &foo
|
||||||
|
- &bar
|
||||||
|
bar: foobar
|
||||||
|
baz: *foo
|
||||||
|
YAML;
|
||||||
|
$tests['sequence'] = array($yaml);
|
||||||
|
|
||||||
|
$yaml = <<<YAML
|
||||||
|
foo: &foo
|
||||||
|
bar: &bar
|
||||||
|
foobar: baz
|
||||||
|
baz: *foo
|
||||||
|
YAML;
|
||||||
|
$tests['mapping'] = array($yaml);
|
||||||
|
|
||||||
|
$yaml = <<<YAML
|
||||||
|
foo: &foo
|
||||||
|
bar: &bar
|
||||||
|
foobar: baz
|
||||||
|
<<: *foo
|
||||||
|
YAML;
|
||||||
|
$tests['mapping with merge key'] = array($yaml);
|
||||||
|
|
||||||
|
return $tests;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider indentedMappingData
|
* @dataProvider indentedMappingData
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user