Merge branch '3.1'
* 3.1: [TwigBridge] removed deprecations added in Twig 1.27 PHP CS Fixer: use php_unit_dedicate_assert 3.0 Upgrade Guide: Added details describing how to pass data to a form through the options resolver fixed Filesystem:makePathRelative and added 2 more testcases no 304 response if method is not cacheable move tags from decorated to decorating service
This commit is contained in:
commit
de4a650d8c
1
.php_cs
1
.php_cs
@ -6,6 +6,7 @@ return Symfony\CS\Config\Config::create()
|
|||||||
->fixers(array(
|
->fixers(array(
|
||||||
'long_array_syntax',
|
'long_array_syntax',
|
||||||
'php_unit_construct',
|
'php_unit_construct',
|
||||||
|
'php_unit_dedicate_assert',
|
||||||
))
|
))
|
||||||
->finder(
|
->finder(
|
||||||
Symfony\CS\Finder\DefaultFinder::create()
|
Symfony\CS\Finder\DefaultFinder::create()
|
||||||
|
@ -410,6 +410,58 @@ UPGRADE FROM 2.x to 3.0
|
|||||||
$form = $this->createForm(MyType::class);
|
$form = $this->createForm(MyType::class);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
* Passing custom data to forms now needs to be done
|
||||||
|
through the options resolver.
|
||||||
|
|
||||||
|
In the controller:
|
||||||
|
|
||||||
|
Before:
|
||||||
|
```php
|
||||||
|
$form = $this->createForm(new MyType($variable), $entity, array(
|
||||||
|
'action' => $this->generateUrl('action_route'),
|
||||||
|
'method' => 'PUT',
|
||||||
|
));
|
||||||
|
```
|
||||||
|
After:
|
||||||
|
```php
|
||||||
|
$form = $this->createForm(MyType::class, $entity, array(
|
||||||
|
'action' => $this->generateUrl('action_route'),
|
||||||
|
'method' => 'PUT',
|
||||||
|
'custom_value' => $variable,
|
||||||
|
));
|
||||||
|
```
|
||||||
|
In the form type:
|
||||||
|
|
||||||
|
Before:
|
||||||
|
```php
|
||||||
|
class MyType extends AbstractType
|
||||||
|
{
|
||||||
|
private $value;
|
||||||
|
|
||||||
|
public function __construct($variableValue)
|
||||||
|
{
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
After:
|
||||||
|
```php
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
|
{
|
||||||
|
$value = $options['custom_value'];
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
|
{
|
||||||
|
$resolver->setDefaults(array(
|
||||||
|
'custom_value' => null,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
* The alias option of the `form.type_extension` tag was removed in favor of
|
* The alias option of the `form.type_extension` tag was removed in favor of
|
||||||
the `extended_type`/`extended-type` option.
|
the `extended_type`/`extended-type` option.
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.5.9",
|
"php": ">=5.5.9",
|
||||||
"doctrine/common": "~2.4",
|
"doctrine/common": "~2.4",
|
||||||
"twig/twig": "~1.26|~2.0",
|
"twig/twig": "~1.27|~2.0",
|
||||||
"psr/cache": "~1.0",
|
"psr/cache": "~1.0",
|
||||||
"psr/log": "~1.0",
|
"psr/log": "~1.0",
|
||||||
"symfony/polyfill-intl-icu": "~1.0",
|
"symfony/polyfill-intl-icu": "~1.0",
|
||||||
|
@ -142,7 +142,7 @@ EOF
|
|||||||
try {
|
try {
|
||||||
$temporaryLoader = new \Twig_Loader_Array(array((string) $file => $template));
|
$temporaryLoader = new \Twig_Loader_Array(array((string) $file => $template));
|
||||||
$twig->setLoader($temporaryLoader);
|
$twig->setLoader($temporaryLoader);
|
||||||
$nodeTree = $twig->parse($twig->tokenize($template, (string) $file));
|
$nodeTree = $twig->parse($twig->tokenize(new \Twig_Source($template, (string) $file)));
|
||||||
$twig->compile($nodeTree);
|
$twig->compile($nodeTree);
|
||||||
$twig->setLoader($realLoader);
|
$twig->setLoader($realLoader);
|
||||||
} catch (\Twig_Error $e) {
|
} catch (\Twig_Error $e) {
|
||||||
|
@ -23,7 +23,7 @@ class RoutingExtensionTest extends \PHPUnit_Framework_TestCase
|
|||||||
$twig = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0));
|
$twig = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0));
|
||||||
$twig->addExtension(new RoutingExtension($this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface')));
|
$twig->addExtension(new RoutingExtension($this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface')));
|
||||||
|
|
||||||
$nodes = $twig->parse($twig->tokenize($template));
|
$nodes = $twig->parse($twig->tokenize(new \Twig_Source($template)));
|
||||||
|
|
||||||
$this->assertSame($mustBeEscaped, $nodes->getNode('body')->getNode(0)->getNode('expr') instanceof \Twig_Node_Expression_Filter);
|
$this->assertSame($mustBeEscaped, $nodes->getNode('body')->getNode(0)->getNode('expr') instanceof \Twig_Node_Expression_Filter);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ class TranslationExtensionTest extends \PHPUnit_Framework_TestCase
|
|||||||
$twig = new \Twig_Environment($loader, array('debug' => true, 'cache' => false));
|
$twig = new \Twig_Environment($loader, array('debug' => true, 'cache' => false));
|
||||||
$twig->addExtension(new TranslationExtension(new Translator('en', new MessageSelector())));
|
$twig->addExtension(new TranslationExtension(new Translator('en', new MessageSelector())));
|
||||||
|
|
||||||
echo $twig->compile($twig->parse($twig->tokenize($twig->getLoader()->getSource('index'), 'index')))."\n\n";
|
echo $twig->compile($twig->parse($twig->tokenize(new \Twig_Source($twig->getLoader()->getSource('index'), 'index'))))."\n\n";
|
||||||
$this->assertEquals($expected, $this->getTemplate($template)->render($variables));
|
$this->assertEquals($expected, $this->getTemplate($template)->render($variables));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ class TwigNodeProvider
|
|||||||
new \Twig_Node_Expression_Array(array(), 0),
|
new \Twig_Node_Expression_Array(array(), 0),
|
||||||
new \Twig_Node_Expression_Array(array(), 0),
|
new \Twig_Node_Expression_Array(array(), 0),
|
||||||
null,
|
null,
|
||||||
null
|
new \Twig_Source('')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ class FormThemeTokenParserTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
|
$env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
|
||||||
$env->addTokenParser(new FormThemeTokenParser());
|
$env->addTokenParser(new FormThemeTokenParser());
|
||||||
$stream = $env->tokenize($source);
|
$stream = $env->tokenize(new \Twig_Source($source));
|
||||||
$parser = new \Twig_Parser($env);
|
$parser = new \Twig_Parser($env);
|
||||||
|
|
||||||
$this->assertEquals($expected, $parser->parse($stream)->getNode('body')->getNode(0));
|
$this->assertEquals($expected, $parser->parse($stream)->getNode('body')->getNode(0));
|
||||||
|
@ -64,7 +64,7 @@ class TransChoiceTokenParser extends TransTokenParser
|
|||||||
$body = $this->parser->subparse(array($this, 'decideTransChoiceFork'), true);
|
$body = $this->parser->subparse(array($this, 'decideTransChoiceFork'), true);
|
||||||
|
|
||||||
if (!$body instanceof \Twig_Node_Text && !$body instanceof \Twig_Node_Expression) {
|
if (!$body instanceof \Twig_Node_Text && !$body instanceof \Twig_Node_Expression) {
|
||||||
throw new \Twig_Error_Syntax('A message inside a transchoice tag must be a simple text.', $body->getLine(), $stream->getFilename());
|
throw new \Twig_Error_Syntax('A message inside a transchoice tag must be a simple text.', $body->getLine(), $stream->getSourceContext()->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
$stream->expect(\Twig_Token::BLOCK_END_TYPE);
|
$stream->expect(\Twig_Token::BLOCK_END_TYPE);
|
||||||
|
@ -55,7 +55,7 @@ class TransTokenParser extends \Twig_TokenParser
|
|||||||
$stream->next();
|
$stream->next();
|
||||||
$locale = $this->parser->getExpressionParser()->parseExpression();
|
$locale = $this->parser->getExpressionParser()->parseExpression();
|
||||||
} elseif (!$stream->test(\Twig_Token::BLOCK_END_TYPE)) {
|
} elseif (!$stream->test(\Twig_Token::BLOCK_END_TYPE)) {
|
||||||
throw new \Twig_Error_Syntax('Unexpected token. Twig was looking for the "with", "from", or "into" keyword.', $stream->getCurrent()->getLine(), $stream->getFilename());
|
throw new \Twig_Error_Syntax('Unexpected token. Twig was looking for the "with", "from", or "into" keyword.', $stream->getCurrent()->getLine(), $stream->getSourceContext()->getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ class TransTokenParser extends \Twig_TokenParser
|
|||||||
$body = $this->parser->subparse(array($this, 'decideTransFork'), true);
|
$body = $this->parser->subparse(array($this, 'decideTransFork'), true);
|
||||||
|
|
||||||
if (!$body instanceof \Twig_Node_Text && !$body instanceof \Twig_Node_Expression) {
|
if (!$body instanceof \Twig_Node_Text && !$body instanceof \Twig_Node_Expression) {
|
||||||
throw new \Twig_Error_Syntax('A message inside a trans tag must be a simple text.', $body->getLine(), $stream->getFilename());
|
throw new \Twig_Error_Syntax('A message inside a trans tag must be a simple text.', $body->getLine(), $stream->getSourceContext()->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
$stream->expect(\Twig_Token::BLOCK_END_TYPE);
|
$stream->expect(\Twig_Token::BLOCK_END_TYPE);
|
||||||
|
@ -62,9 +62,9 @@ class TwigExtractor extends AbstractFileExtractor implements ExtractorInterface
|
|||||||
$this->extractTemplate(file_get_contents($file->getPathname()), $catalogue);
|
$this->extractTemplate(file_get_contents($file->getPathname()), $catalogue);
|
||||||
} catch (\Twig_Error $e) {
|
} catch (\Twig_Error $e) {
|
||||||
if ($file instanceof SplFileInfo) {
|
if ($file instanceof SplFileInfo) {
|
||||||
$e->setTemplateFile($file->getRelativePathname());
|
$e->setTemplateName($file->getRelativePathname());
|
||||||
} elseif ($file instanceof \SplFileInfo) {
|
} elseif ($file instanceof \SplFileInfo) {
|
||||||
$e->setTemplateFile($file->getRealPath());
|
$e->setTemplateName($file->getRealPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
throw $e;
|
throw $e;
|
||||||
@ -85,7 +85,7 @@ class TwigExtractor extends AbstractFileExtractor implements ExtractorInterface
|
|||||||
$visitor = $this->twig->getExtension('Symfony\Bridge\Twig\Extension\TranslationExtension')->getTranslationNodeVisitor();
|
$visitor = $this->twig->getExtension('Symfony\Bridge\Twig\Extension\TranslationExtension')->getTranslationNodeVisitor();
|
||||||
$visitor->enable();
|
$visitor->enable();
|
||||||
|
|
||||||
$this->twig->parse($this->twig->tokenize($template));
|
$this->twig->parse($this->twig->tokenize(new \Twig_Source($template)));
|
||||||
|
|
||||||
foreach ($visitor->getMessages() as $message) {
|
foreach ($visitor->getMessages() as $message) {
|
||||||
$catalogue->set(trim($message[0]), $this->prefix.trim($message[0]), $message[1] ?: $this->defaultDomain);
|
$catalogue->set(trim($message[0]), $this->prefix.trim($message[0]), $message[1] ?: $this->defaultDomain);
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.5.9",
|
"php": ">=5.5.9",
|
||||||
"twig/twig": "~1.26|~2.0"
|
"twig/twig": "~1.27|~2.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"symfony/asset": "~2.8|~3.0",
|
"symfony/asset": "~2.8|~3.0",
|
||||||
|
@ -30,7 +30,7 @@ class ProfilerTest extends WebTestCase
|
|||||||
$client->enableProfiler();
|
$client->enableProfiler();
|
||||||
$crawler = $client->request('GET', '/profiler');
|
$crawler = $client->request('GET', '/profiler');
|
||||||
$profile = $client->getProfile();
|
$profile = $client->getProfile();
|
||||||
$this->assertTrue(is_object($profile));
|
$this->assertInternalType('object', $profile);
|
||||||
|
|
||||||
$client->request('GET', '/profiler');
|
$client->request('GET', '/profiler');
|
||||||
$this->assertFalse($client->getProfile());
|
$this->assertFalse($client->getProfile());
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
"symfony/yaml": "~2.8|~3.0",
|
"symfony/yaml": "~2.8|~3.0",
|
||||||
"symfony/expression-language": "~2.8|~3.0",
|
"symfony/expression-language": "~2.8|~3.0",
|
||||||
"doctrine/doctrine-bundle": "~1.4",
|
"doctrine/doctrine-bundle": "~1.4",
|
||||||
"twig/twig": "~1.26|~2.0"
|
"twig/twig": "~1.27|~2.0"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"symfony/security-acl": "For using the ACL functionality of this bundle"
|
"symfony/security-acl": "For using the ACL functionality of this bundle"
|
||||||
|
@ -120,7 +120,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
$rootNode
|
$rootNode
|
||||||
->fixXmlConfig('path')
|
->fixXmlConfig('path')
|
||||||
->children()
|
->children()
|
||||||
->variableNode('autoescape')->defaultValue('filename')->end()
|
->variableNode('autoescape')->defaultValue('name')->end()
|
||||||
->scalarNode('autoescape_service')->defaultNull()->end()
|
->scalarNode('autoescape_service')->defaultNull()->end()
|
||||||
->scalarNode('autoescape_service_method')->defaultNull()->end()
|
->scalarNode('autoescape_service_method')->defaultNull()->end()
|
||||||
->scalarNode('base_template_class')->example('Twig_Template')->cannotBeEmpty()->end()
|
->scalarNode('base_template_class')->example('Twig_Template')->cannotBeEmpty()->end()
|
||||||
|
@ -113,7 +113,7 @@ class TwigExtensionTest extends TestCase
|
|||||||
$this->compileContainer($container);
|
$this->compileContainer($container);
|
||||||
|
|
||||||
$options = $container->getDefinition('twig')->getArgument(1);
|
$options = $container->getDefinition('twig')->getArgument(1);
|
||||||
$this->assertEquals('filename', $options['autoescape']);
|
$this->assertEquals('name', $options['autoescape']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGlobalsWithDifferentTypesAndValues()
|
public function testGlobalsWithDifferentTypesAndValues()
|
||||||
|
@ -28,7 +28,7 @@ class NewCacheWamingTest extends \PHPUnit_Framework_TestCase
|
|||||||
$warmer->enableOptionalWarmers();
|
$warmer->enableOptionalWarmers();
|
||||||
$warmer->warmUp($kernel->getCacheDir());
|
$warmer->warmUp($kernel->getCacheDir());
|
||||||
|
|
||||||
$this->assertTrue(file_exists($kernel->getCacheDir().'/twig'));
|
$this->assertFileExists($kernel->getCacheDir().'/twig');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCacheIsProperlyWarmedWhenTemplatingIsDisabled()
|
public function testCacheIsProperlyWarmedWhenTemplatingIsDisabled()
|
||||||
@ -40,7 +40,7 @@ class NewCacheWamingTest extends \PHPUnit_Framework_TestCase
|
|||||||
$warmer->enableOptionalWarmers();
|
$warmer->enableOptionalWarmers();
|
||||||
$warmer->warmUp($kernel->getCacheDir());
|
$warmer->warmUp($kernel->getCacheDir());
|
||||||
|
|
||||||
$this->assertTrue(file_exists($kernel->getCacheDir().'/twig'));
|
$this->assertFileExists($kernel->getCacheDir().'/twig');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
|
@ -51,8 +51,8 @@ class TwigEngine extends BaseEngine implements EngineInterface
|
|||||||
} catch (\Twig_Error $e) {
|
} catch (\Twig_Error $e) {
|
||||||
if ($name instanceof TemplateReference) {
|
if ($name instanceof TemplateReference) {
|
||||||
try {
|
try {
|
||||||
// try to get the real file name of the template where the error occurred
|
// try to get the real name of the template where the error occurred
|
||||||
$e->setTemplateFile(sprintf('%s', $this->locator->locate($this->parser->parse($e->getTemplateFile()))));
|
$e->setTemplateName(sprintf('%s', $this->locator->locate($this->parser->parse($e->getTemplateName()))));
|
||||||
} catch (\Exception $e2) {
|
} catch (\Exception $e2) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
"symfony/twig-bridge": "~3.2",
|
"symfony/twig-bridge": "~3.2",
|
||||||
"symfony/http-foundation": "~2.8|~3.0",
|
"symfony/http-foundation": "~2.8|~3.0",
|
||||||
"symfony/http-kernel": "~2.8|~3.0",
|
"symfony/http-kernel": "~2.8|~3.0",
|
||||||
"twig/twig": "~1.26|~2.0"
|
"twig/twig": "~1.27|~2.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"symfony/asset": "~2.8|~3.0",
|
"symfony/asset": "~2.8|~3.0",
|
||||||
|
@ -51,10 +51,12 @@ class DecoratorServicePass implements CompilerPassInterface
|
|||||||
$public = $alias->isPublic();
|
$public = $alias->isPublic();
|
||||||
$container->setAlias($renamedId, new Alias((string) $alias, false));
|
$container->setAlias($renamedId, new Alias((string) $alias, false));
|
||||||
} else {
|
} else {
|
||||||
$definition = $container->getDefinition($inner);
|
$decoratedDefinition = $container->getDefinition($inner);
|
||||||
$public = $definition->isPublic();
|
$definition->setTags($decoratedDefinition->getTags(), $definition->getTags());
|
||||||
$definition->setPublic(false);
|
$public = $decoratedDefinition->isPublic();
|
||||||
$container->setDefinition($renamedId, $definition);
|
$decoratedDefinition->setPublic(false);
|
||||||
|
$decoratedDefinition->setTags(array());
|
||||||
|
$container->setDefinition($renamedId, $decoratedDefinition);
|
||||||
}
|
}
|
||||||
|
|
||||||
$container->setAlias($inner, new Alias($id, $public));
|
$container->setAlias($inner, new Alias($id, $public));
|
||||||
|
@ -124,6 +124,24 @@ class DecoratorServicePassTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertNull($quxDefinition->getDecoratedService());
|
$this->assertNull($quxDefinition->getDecoratedService());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testProcessMovesTagsFromDecoratedDefinitionToDecoratingDefinition()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
$container
|
||||||
|
->register('foo')
|
||||||
|
->setTags(array('name' => 'bar'))
|
||||||
|
;
|
||||||
|
$container
|
||||||
|
->register('baz')
|
||||||
|
->setDecoratedService('foo')
|
||||||
|
;
|
||||||
|
|
||||||
|
$this->process($container);
|
||||||
|
|
||||||
|
$this->assertEmpty($container->getDefinition('baz.inner')->getTags());
|
||||||
|
$this->assertEquals(array('name' => 'bar'), $container->getDefinition('baz')->getTags());
|
||||||
|
}
|
||||||
|
|
||||||
protected function process(ContainerBuilder $container)
|
protected function process(ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
$repeatedPass = new DecoratorServicePass();
|
$repeatedPass = new DecoratorServicePass();
|
||||||
|
@ -453,10 +453,14 @@ class Filesystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Determine how deep the start path is relative to the common path (ie, "web/bundles" = 2 levels)
|
// Determine how deep the start path is relative to the common path (ie, "web/bundles" = 2 levels)
|
||||||
|
if (count($startPathArr) === 1 && $startPathArr[0] === '') {
|
||||||
|
$depth = 0;
|
||||||
|
} else {
|
||||||
$depth = count($startPathArr) - $index;
|
$depth = count($startPathArr) - $index;
|
||||||
|
}
|
||||||
|
|
||||||
// When we need to traverse from the start, and we are starting from a root path, don't add '../'
|
// When we need to traverse from the start, and we are starting from a root path, don't add '../'
|
||||||
if ('/' === $startPath[0] && 0 === $index && 1 === $depth) {
|
if ('/' === $startPath[0] && 0 === $index && 0 === $depth) {
|
||||||
$traverser = '';
|
$traverser = '';
|
||||||
} else {
|
} else {
|
||||||
// Repeated "../" for each level need to reach the common path
|
// Repeated "../" for each level need to reach the common path
|
||||||
|
@ -1089,6 +1089,8 @@ class FilesystemTest extends FilesystemTestCase
|
|||||||
array('/a/aab/bb/', '/a/aa/', '../aab/bb/'),
|
array('/a/aab/bb/', '/a/aa/', '../aab/bb/'),
|
||||||
array('/a/aab/bb/', '/', 'a/aab/bb/'),
|
array('/a/aab/bb/', '/', 'a/aab/bb/'),
|
||||||
array('/a/aab/bb/', '/b/aab', '../../a/aab/bb/'),
|
array('/a/aab/bb/', '/b/aab', '../../a/aab/bb/'),
|
||||||
|
array('/aab/bb', '/aa', '../aab/bb/'),
|
||||||
|
array('/aab', '/aa', '../aab/'),
|
||||||
);
|
);
|
||||||
|
|
||||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||||
|
@ -58,7 +58,7 @@ abstract class BaseValidatorExtensionTest extends TypeTestCase
|
|||||||
'validation_groups' => array($this, 'testValidationGroupsCanBeSetToCallback'),
|
'validation_groups' => array($this, 'testValidationGroupsCanBeSetToCallback'),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertTrue(is_callable($form->getConfig()->getOption('validation_groups')));
|
$this->assertInternalType('callable', $form->getConfig()->getOption('validation_groups'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testValidationGroupsCanBeSetToClosure()
|
public function testValidationGroupsCanBeSetToClosure()
|
||||||
@ -67,7 +67,7 @@ abstract class BaseValidatorExtensionTest extends TypeTestCase
|
|||||||
'validation_groups' => function (FormInterface $form) { },
|
'validation_groups' => function (FormInterface $form) { },
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertTrue(is_callable($form->getConfig()->getOption('validation_groups')));
|
$this->assertInternalType('callable', $form->getConfig()->getOption('validation_groups'));
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract protected function createForm(array $options = array());
|
abstract protected function createForm(array $options = array());
|
||||||
|
@ -1049,7 +1049,7 @@ class Response
|
|||||||
*/
|
*/
|
||||||
public function isNotModified(Request $request)
|
public function isNotModified(Request $request)
|
||||||
{
|
{
|
||||||
if (!$request->isMethodSafe()) {
|
if (!$request->isMethodCacheable()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,13 +97,15 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
} elseif (isset($trace[$i]['object']) && $trace[$i]['object'] instanceof \Twig_Template) {
|
} elseif (isset($trace[$i]['object']) && $trace[$i]['object'] instanceof \Twig_Template) {
|
||||||
$info = $trace[$i]['object'];
|
$template = $trace[$i]['object'];
|
||||||
$name = $info->getTemplateName();
|
$name = $template->getTemplateName();
|
||||||
$src = method_exists($info, 'getSource') ? $info->getSource() : $info->getEnvironment()->getLoader()->getSource($name);
|
$file = method_exists($template, 'getSourceContext') ? $template->getSourceContext()->getPath() : false;
|
||||||
$info = $info->getDebugInfo();
|
$src = method_exists($template, 'getSourceContext') ? $template->getSourceContext()->getCode() : (method_exists($template, 'getSource') ? $template->getSource() : false);
|
||||||
|
$info = $template->getDebugInfo();
|
||||||
if (null !== $src && isset($info[$trace[$i - 1]['line']])) {
|
if (null !== $src && isset($info[$trace[$i - 1]['line']])) {
|
||||||
$file = false;
|
|
||||||
$line = $info[$trace[$i - 1]['line']];
|
$line = $info[$trace[$i - 1]['line']];
|
||||||
|
|
||||||
|
if ($src) {
|
||||||
$src = explode("\n", $src);
|
$src = explode("\n", $src);
|
||||||
$fileExcerpt = array();
|
$fileExcerpt = array();
|
||||||
|
|
||||||
@ -113,6 +115,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
|||||||
|
|
||||||
$fileExcerpt = '<ol start="'.max($line - 3, 1).'">'.implode("\n", $fileExcerpt).'</ol>';
|
$fileExcerpt = '<ol start="'.max($line - 3, 1).'">'.implode("\n", $fileExcerpt).'</ol>';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ class FileDumperTest extends \PHPUnit_Framework_TestCase
|
|||||||
$dumper = new ConcreteFileDumper();
|
$dumper = new ConcreteFileDumper();
|
||||||
$dumper->dump($catalogue, array('path' => $tempDir));
|
$dumper->dump($catalogue, array('path' => $tempDir));
|
||||||
|
|
||||||
$this->assertTrue(file_exists($backupFile));
|
$this->assertFileExists($backupFile);
|
||||||
|
|
||||||
@unlink($file);
|
@unlink($file);
|
||||||
@unlink($backupFile);
|
@unlink($backupFile);
|
||||||
@ -65,7 +65,7 @@ class FileDumperTest extends \PHPUnit_Framework_TestCase
|
|||||||
$dumper->setRelativePathTemplate('test/translations/%domain%.%locale%.%extension%');
|
$dumper->setRelativePathTemplate('test/translations/%domain%.%locale%.%extension%');
|
||||||
$dumper->dump($catalogue, array('path' => $tempDir));
|
$dumper->dump($catalogue, array('path' => $tempDir));
|
||||||
|
|
||||||
$this->assertTrue(file_exists($file));
|
$this->assertFileExists($file);
|
||||||
|
|
||||||
@unlink($file);
|
@unlink($file);
|
||||||
@rmdir($translationsDir);
|
@rmdir($translationsDir);
|
||||||
|
Reference in New Issue
Block a user