Merge branch '3.3' into 3.4
* 3.3: [TwigBundle] Add Doctrine Cache to dev dependencies [Yaml] Fix linting yaml with constants as keys [Routing] Revert the change in [#b42018] with respect to Routing/Route.php
This commit is contained in:
commit
c8cf42bcbb
@ -116,11 +116,7 @@ class Route implements \Serializable
|
|||||||
*/
|
*/
|
||||||
public function unserialize($serialized)
|
public function unserialize($serialized)
|
||||||
{
|
{
|
||||||
if (\PHP_VERSION_ID >= 70000) {
|
$data = unserialize($serialized);
|
||||||
$data = unserialize($serialized, array('allowed_classes' => array(CompiledRoute::class)));
|
|
||||||
} else {
|
|
||||||
$data = unserialize($serialized);
|
|
||||||
}
|
|
||||||
$this->path = $data['path'];
|
$this->path = $data['path'];
|
||||||
$this->host = $data['host'];
|
$this->host = $data['host'];
|
||||||
$this->defaults = $data['defaults'];
|
$this->defaults = $data['defaults'];
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
<?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\Routing\Tests\Fixtures;
|
||||||
|
|
||||||
|
use Symfony\Component\Routing\CompiledRoute;
|
||||||
|
|
||||||
|
class CustomCompiledRoute extends CompiledRoute
|
||||||
|
{
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?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\Routing\Tests\Fixtures;
|
||||||
|
|
||||||
|
use Symfony\Component\Routing\Route;
|
||||||
|
use Symfony\Component\Routing\RouteCompiler;
|
||||||
|
|
||||||
|
class CustomRouteCompiler extends RouteCompiler
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public static function compile(Route $route)
|
||||||
|
{
|
||||||
|
return new CustomCompiledRoute('', '', array(), array());
|
||||||
|
}
|
||||||
|
}
|
@ -220,6 +220,24 @@ class RouteTest extends TestCase
|
|||||||
$this->assertNotSame($route, $unserialized);
|
$this->assertNotSame($route, $unserialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that unserialization does not fail when the compiled Route is of a
|
||||||
|
* class other than CompiledRoute, such as a subclass of it.
|
||||||
|
*/
|
||||||
|
public function testSerializeWhenCompiledWithClass()
|
||||||
|
{
|
||||||
|
$route = new Route('/', array(), array(), array('compiler_class' => '\Symfony\Component\Routing\Tests\Fixtures\CustomRouteCompiler'));
|
||||||
|
$this->assertInstanceOf('\Symfony\Component\Routing\Tests\Fixtures\CustomCompiledRoute', $route->compile(), '->compile() returned a proper route');
|
||||||
|
|
||||||
|
$serialized = serialize($route);
|
||||||
|
try {
|
||||||
|
$unserialized = unserialize($serialized);
|
||||||
|
$this->assertInstanceOf('\Symfony\Component\Routing\Tests\Fixtures\CustomCompiledRoute', $unserialized->compile(), 'the unserialized route compiled successfully');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->fail('unserializing a route which uses a custom compiled route class');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that the serialized representation of a route in one symfony version
|
* Tests that the serialized representation of a route in one symfony version
|
||||||
* also works in later symfony versions, i.e. the unserialized route is in the
|
* also works in later symfony versions, i.e. the unserialized route is in the
|
||||||
|
@ -18,6 +18,7 @@ use Symfony\Component\Console\Output\OutputInterface;
|
|||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
use Symfony\Component\Yaml\Exception\ParseException;
|
use Symfony\Component\Yaml\Exception\ParseException;
|
||||||
use Symfony\Component\Yaml\Parser;
|
use Symfony\Component\Yaml\Parser;
|
||||||
|
use Symfony\Component\Yaml\Yaml;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates YAML files syntax and outputs encountered errors.
|
* Validates YAML files syntax and outputs encountered errors.
|
||||||
@ -111,7 +112,7 @@ EOF
|
|||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->getParser()->parse($content);
|
$this->getParser()->parse($content, Yaml::PARSE_CONSTANT);
|
||||||
} catch (ParseException $e) {
|
} catch (ParseException $e) {
|
||||||
return array('file' => $file, 'valid' => false, 'message' => $e->getMessage());
|
return array('file' => $file, 'valid' => false, 'message' => $e->getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -51,6 +51,15 @@ bar';
|
|||||||
$this->assertContains('Unable to parse at line 3 (near "bar").', trim($tester->getDisplay()));
|
$this->assertContains('Unable to parse at line 3 (near "bar").', trim($tester->getDisplay()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testConstantAsKey()
|
||||||
|
{
|
||||||
|
$yaml = <<<YAML
|
||||||
|
!php/const:Symfony\Component\Yaml\Tests\Command\Foo::TEST: bar
|
||||||
|
YAML;
|
||||||
|
$ret = $this->createCommandTester()->execute(array('filename' => $this->createFile($yaml)), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false));
|
||||||
|
$this->assertSame(0, $ret, 'lint:yaml exits with code 0 in case of success');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \RuntimeException
|
* @expectedException \RuntimeException
|
||||||
*/
|
*/
|
||||||
@ -105,3 +114,8 @@ bar';
|
|||||||
rmdir(sys_get_temp_dir().'/framework-yml-lint-test');
|
rmdir(sys_get_temp_dir().'/framework-yml-lint-test');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Foo
|
||||||
|
{
|
||||||
|
const TEST = 'foo';
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user