8000 Merge branch '2.7' into 2.8 · symfony/symfony@874d418 · GitHub
[go: up one dir, main page]

Skip to content

Commit 874d418

Browse files
Merge branch '2.7' into 2.8
* 2.7: [FrameworkBundle] Fix visibility of a test helper [link] clear the cache after linking [link] Prevent warnings when running link with 2.7 [Validator] ExpressionValidator should use OBJECT_TO_STRING to allow value in message
2 parents 1941a78 + 6eedbb5 commit 874d418

File tree

5 files changed

+69
-5
lines changed

5 files changed

+69
-5
lines changed

link

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@ if (!is_dir("$argv[1]/vendor/symfony")) {
3535
}
3636

3737
$sfPackages = array('symfony/symfony' => __DIR__);
38+
39+
$filesystem = new Filesystem();
3840
foreach (glob(__DIR__.'/src/Symfony/{Bundle,Bridge,Component,Component/Security}/*', GLOB_BRACE | GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
39-
$sfPackages[json_decode(file_get_contents("$dir/composer.json"))->name] = $dir;
41+
if ($filesystem->exists($composer = "$dir/composer.json")) {
42+
$sfPackages[json_decode(file_get_contents($composer))->name] = $dir;
43+
}
4044
}
4145

42-
$filesystem = new Filesystem();
4346
foreach (glob("$argv[1]/vendor/symfony/*", GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
4447
$package = 'symfony/'.basename($dir);
4548
if (is_link($dir)) {
@@ -57,3 +60,7 @@ foreach (glob("$argv[1]/vendor/symfony/*", GLOB_ONLYDIR | GLOB_NOSORT) as $dir)
5760
$filesystem->symlink($sfDir, $dir);
5861
echo "\"$package\" has been linked to \"$sfPackages[$package]\".".PHP_EOL;
5962
}
63+
64+
foreach (glob("$argv[1]/var/cache/*") as $cacheDir) {
65+
$filesystem->remove($cacheDir);
66+
}

src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ private function createRedirectController($httpPort = null, $httpsPort = null)
290290
return $controller;
291291
}
292292

293-
public function assertRedirectUrl(Response $returnResponse, $expectedUrl)
293+
private function assertRedirectUrl(Response $returnResponse, $expectedUrl)
294294
{
295295
$this->assertTrue($returnResponse->isRedirect($expectedUrl), "Expected: $expectedUrl\nGot: ".$returnResponse->headers->get('Location'));
296296
}

src/Symfony/Component/Validator/Constraints/ExpressionValidator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ public function validate($value, Constraint $constraint)
7272
if (!$this->getExpressionLanguage()->evaluate($constraint->expression, $variables)) {
7373
if ($this->context instanceof ExecutionContextInterface) {
7474
$this->context->buildViolation($constraint->message)
75-
->setParameter('{{ value }}', $this->formatValue($value))
75+
->setParameter('{{ value }}', $this->formatValue($value, self::OBJECT_TO_STRING))
7676
->setCode(Expression::EXPRESSION_FAILED_ERROR)
7777
->addViolation();
7878
} else {
7979
$this->buildViolation($constraint->message)
80-
->setParameter('{{ value }}', $this->formatValue($value))
80+
->setParameter('{{ value }}', $this->formatValue($value, self::OBJECT_TO_STRING))
8181
->setCode(Expression::EXPRESSION_FAILED_ERROR)
8282
->addViolation();
8383
}

src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Validator\Constraints\Expression;
1616
use Symfony\Component\Validator\Constraints\ExpressionValidator;
1717
use Symfony\Component\Validator\Tests\Fixtures\Entity;
18+
use Symfony\Component\Validator\Tests\Fixtures\ToString;
1819
use Symfony\Component\Validator\Validation;
1920

2021
class ExpressionValidatorTest extends AbstractConstraintValidatorTest
@@ -93,6 +94,40 @@ public function testFailingExpressionAtObjectLevel()
9394
->assertRaised();
9495
}
9596

97+
public function testSucceedingExpressionAtObjectLevelWithToString()
98+
{
99+
$constraint = new Expression('this.data == 1');
100+
101+
$object = new ToString();
102+
$object->data = '1';
103+
104+
$this->setObject($object);
105+
106+
$this->validator->validate($object, $constraint);
107+
108+
$this->assertNoViolation();
109+
}
110+
111+
public function testFailingExpressionAtObjectLevelWithToString()
112+
{
113+
$constraint = new Expression(array(
114+
'expression' => 'this.data == 1',
115+
'message' => 'myMessage',
116+
));
117+
118+
$object = new ToString();
119+
$object->data = '2';
120+
121+
$this->setObject($object);
122+
123+
$this->validator->validate($object, $constraint);
124+
125+
$this->buildViolation('myMessage')
126+
->setParameter('{{ value }}', 'toString')
127+
->setCode(Expression::EXPRESSION_FAILED_ERROR)
128+
->assertRaised();
129+
}
130+
96131
public function testSucceedingExpressionAtPropertyLevel()
97132
{
98133
$constraint = new Expression('value == this.data');
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Validator\Tests\Fixtures;
13+
14+
class ToString
15+
{
16+
public $data;
17+
18+
public function __toString()
19+
{
20+
return 'toString';
21+
}
22+
}

0 commit comments

Comments
 (0)
0