Skip to content

Commit f5ad6b0

Browse files
Merge remote-tracking branch 'origin/3.4' into 4.4
* origin/3.4: add mising sr (latn & cyrl) translations allow consumers to mock all methods
2 parents c71d8ab + e575d3f commit f5ad6b0

File tree

3 files changed

+95
-1
lines changed

3 files changed

+95
-1
lines changed

Resources/translations/validators.sr_Cyrl.xlf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,26 @@
366366
<source>This value should be between {{ min }} and {{ max }}.</source>
367367
<target>Ова вредност треба да буде између {{ min }} и {{ max }}.</target>
368368
</trans-unit>
369+
<trans-unit id="95">
370+
<source>This value is not a valid hostname.</source>
371+
<target>Ова вредност није исправно име послужитеља (hostname).</target>
372+
</trans-unit>
373+
<trans-unit id="96">
374+
<source>The number of elements in this collection should be a multiple of {{ compared_value }}.</source>
375+
<target>Број елемената у овој колекцији би требало да буде дељив са {{ compared_value }}.</target>
376+
</trans-unit>
377+
<trans-unit id="97">
378+
<source>This value should satisfy at least one of the following constraints:</source>
379+
<target>Ова вредност би требало да задовољава најмање једно од наредних ограничења:</target>
380+
</trans-unit>
381+
<trans-unit id="98">
382+
<source>Each element of this collection should satisfy its own set of constraints.</source>
383+
<target>Сваки елемент ове колекције би требало да задовољи сопствени скуп ограничења.</target>
384+
</trans-unit>
385+
<trans-unit id="99">
386+
<source>This value is not a valid International Securities Identification Number (ISIN).</source>
387+
<target>Ова вредност није исправна међународна идентификациона ознака хартија од вредности (ISIN).</target>
388+
</trans-unit>
369389
</body>
370390
</file>
371391
</xliff>

Resources/translations/validators.sr_Latn.xlf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,26 @@
366366
<source>This value should be between {{ min }} and {{ max }}.</source>
367367
<target>Ova vrednost treba da bude između {{ min }} i {{ max }}.</target>
368368
</trans-unit>
369+
<trans-unit id="95">
370+
<source>This value is not a valid hostname.</source>
371+
<target>Ova vrednost nije ispravno ime poslužitelja (hostname).</target>
372+
</trans-unit>
373+
<trans-unit id="96">
374+
<source>The number of elements in this collection should be a multiple of {{ compared_value }}.</source>
375+
<target>Broj elemenata u ovoj kolekciji bi trebalo da bude deljiv sa {{ compared_value }}.</target>
376+
</trans-unit>
377+
<trans-unit id="97">
378+
<source>This value should satisfy at least one of the following constraints:</source>
379+
<target>Ova vrednost bi trebalo da zadovoljava namjanje jedno od narednih ograničenja:</target>
380+
</trans-unit>
381+
<trans-unit id="98">
382+
<source>Each element of this collection should satisfy its own set of constraints.</source>
383+
<target>Svaki element ove kolekcije bi trebalo da zadovolji sopstveni skup ograničenja.</target>
384+
</trans-unit>
385+
<trans-unit id="99">
386+
<source>This value is not a valid International Securities Identification Number (ISIN).</source>
387+
<target>Ova vrednost nije ispravna međunarodna identifikaciona oznaka hartija od vrednosti (ISIN).</target>
388+
</trans-unit>
369389
</body>
370390
</file>
371391
</xliff>

Test/ConstraintValidatorTestCase.php

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,44 @@ protected function createContext()
114114
$context->setNode($this->value, $this->object, $this->metadata, $this->propertyPath);
115115
$context->setConstraint($this->constraint);
116116

117+
$contextualValidator = $this->getMockBuilder(AssertingContextualValidator::class)
118+
->setMethods([
119+
'atPath',
120+
'validate',
121+
'validateProperty',
122+
'validatePropertyValue',
123+
'getViolations',
124+
])
125+
->getMock();
126+
$contextualValidator->expects($this->any())
127+
->method('atPath')
128+
->willReturnCallback(function ($path) use ($contextualValidator) {
129+
return $contextualValidator->doAtPath($path);
130+
});
131+
$contextualValidator->expects($this->any())
132+
->method('validate')
133+
->willReturnCallback(function ($value, $constraints = null, $groups = null) use ($contextualValidator) {
134+
return $contextualValidator->doValidate($value, $constraints, $groups);
135+
});
136+
$contextualValidator->expects($this->any())
137+
->method('validateProperty')
138+
->willReturnCallback(function ($object, $propertyName, $groups = null) use ($contextualValidator) {
139+
return $contextualValidator->validateProperty($object, $propertyName, $groups);
140+
});
141+
$contextualValidator->expects($this->any())
142+
->method('validatePropertyValue')
143+
->willReturnCallback(function ($objectOrClass, $propertyName, $value, $groups = null) use ($contextualValidator) {
144+
return $contextualValidator->doValidatePropertyValue($objectOrClass, $propertyName, $value, $groups);
145+
});
146+
$contextualValidator->expects($this->any())
147+
->method('getViolations')
148+
->willReturnCallback(function () use ($contextualValidator) {
149+
return $contextualValidator->doGetViolations();
150+
});
117151
$validator->expects($this->any())
118152
->method('inContext')
119153
->with($context)
120-
->willReturn($this->getMockBuilder(AssertingContextualValidator::class)->setMethods(null)->getMock());
154+
->willReturn($contextualValidator);
121155

122156
return $context;
123157
}
@@ -355,6 +389,10 @@ class AssertingContextualValidator implements ContextualValidatorInterface
355389
private $expectedValidate = [];
356390

357391
public function atPath($path)
392+
{
393+
}
394+
395+
public function doAtPath($path)
358396
{
359397
Assert::assertFalse($this->expectNoValidate, 'No validation calls have been expected.');
360398

@@ -368,6 +406,10 @@ public function atPath($path)
368406
}
369407

370408
public function validate($value, $constraints = null, $groups = null)
409+
{
410+
}
411+
412+
public function doValidate($value, $constraints = null, $groups = null)
371413
{
372414
Assert::assertFalse($this->expectNoValidate, 'No validation calls have been expected.');
373415

@@ -381,11 +423,19 @@ public function validate($value, $constraints = null, $groups = null)
381423
}
382424

383425
public function validateProperty($object, $propertyName, $groups = null)
426+
{
427+
}
428+
429+
public function doValidateProperty($object, $propertyName, $groups = null)
384430
{
385431
return $this;
386432
}
387433

388434
public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null)
435+
{
436+
}
437+
438+
public function doValidatePropertyValue($objectOrClass, $propertyName, $value, $groups = null)
389439
{
390440
return $this;
391441
}
@@ -394,6 +444,10 @@ public function getViolations()
394444
{
395445
}
396446

447+
public function doGetViolations()
448+
{
449+
}
450+
397451
public function expectNoValidate()
398452
{
399453
$this->expectNoValidate = true;

0 commit comments

Comments
 (0)