8000 fix dunglas's comments · symfony/symfony@c612385 · GitHub
[go: up one dir, main page]

Skip to content

Commit c612385

Browse files
author
Amrouche Hamza
committed
fix dunglas's comments
1 parent a264e76 commit c612385

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

src/Symfony/Component/Validator/Tests/Constraints/Fixtures/ChildA.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ class ChildA
1717
{
1818
/**
1919
* @Assert\Valid
20+
* @Assert\NotNull
2021
* @Assert\NotBlank
2122
*/
2223
public $name;
24+
/**
25+
* @var ChildB
26+
* @Assert\Valid
27+
* @Assert\NotNull
28+
*/
29+
public $childB;
2330
}

src/Symfony/Component/Validator/Tests/Constraints/Fixtures/ChildB.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,10 @@ class ChildB
2020
* @Assert\NotBlank
2121
*/
2222
public $name;
23+
/**
24+
* @var ChildA
25+
* @Assert\Valid
26+
* @Assert\NotBlank
27+
*/
28+
public $childA;
2329
}

src/Symfony/Component/Validator/Tests/Validator/RecursiveContextualValidatorTest.php

Whitespace-only changes.

src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,38 @@ public function testEmptyGroupsArrayDoesNotTriggerDeprecation()
6161

6262
$validator->validate($entity, null, array());
6363
}
64+
65+
public function testRelationBetweenChildAAndChildB()
66+
{
67+
$entity = new Entity();
68+
$childA = new ChildA();
69+
$childB = new ChildB();
70+
71+
$childA->childB = $childB;
72+
$childB->childA = $childA;
73+
74+
$childA->name = false;
75+
$childB->name = 'fake';
76+
$entity->childA = array($childA);
77+
$entity->childB = array($childB);
78+
79+
$validatorContext = $this->getMock('Symfony\Component\Validator\Validator\ContextualValidatorInterface');
80+
$validatorContext
81+
->expects($this->once())
82+
->method('validate')
83+
->with($entity, null, array())
84+
->willReturnSelf();
85+
86+
$validator = $this
87+
->getMockBuilder('Symfony\Component\Validator\Validator\RecursiveValidator')
88+
->disableOriginalConstructor()
89+
->setMethods(array('startContext'))
90+
->getMock();
91+
$validator
92+
->expects($this->once())
93+
->method('startContext')
94+
->willReturn($validatorContext);
95+
96+
$validator->validate($entity, null, array());
97+
}
6498
}

0 commit comments

Comments
 (0)
0