Version 1
[yaffs-website] / vendor / symfony / validator / Tests / ConstraintViolationTest.php
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;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Validator\ConstraintViolation;
16
17 class ConstraintViolationTest extends TestCase
18 {
19     public function testToStringHandlesArrays()
20     {
21         $violation = new ConstraintViolation(
22             'Array',
23             '{{ value }}',
24             array('{{ value }}' => array(1, 2, 3)),
25             'Root',
26             'property.path',
27             null
28         );
29
30         $expected = <<<'EOF'
31 Root.property.path:
32     Array
33 EOF;
34
35         $this->assertSame($expected, (string) $violation);
36     }
37
38     public function testToStringHandlesArrayRoots()
39     {
40         $violation = new ConstraintViolation(
41             '42 cannot be used here',
42             'this is the message template',
43             array(),
44             array('some_value' => 42),
45             'some_value',
46             null
47         );
48
49         $expected = <<<'EOF'
50 Array.some_value:
51     42 cannot be used here
52 EOF;
53
54         $this->assertSame($expected, (string) $violation);
55     }
56 }