8000 bug #39070 [Validator] Remove IsinValidator's validator dependency (d… · symfony/symfony@13abe48 · GitHub
[go: up one dir, main page]

Skip to content

Commit 13abe48

Browse files
committed
bug #39070 [Validator] Remove IsinValidator's validator dependency (derrabus)
This PR was merged into the 5.2 branch. Discussion ---------- [Validator] Remove IsinValidator's validator dependency | Q | A | ------------- | --- | Branch? | 5.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #39069 | License | MIT | Doc PR | N/A Commits ------- 4cb7dec [Validator] Resolve IsinValidator's dependency on the validator.
2 parents cc130e1 + 4cb7dec commit 13abe48

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

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

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Symfony\Component\Validator\ConstraintValidator;
1616
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
1717
use Symfony\Component\Validator\Exception\UnexpectedValueException;
18-
use Symfony\Component\Validator\Validator\ValidatorInterface;
1918

2019
/**
2120
* @author Laurent Masforné <l.masforne@gmail.com>
@@ -24,16 +23,6 @@
2423
*/
2524
class IsinValidator extends ConstraintValidator
2625
{
27-
/**
28-
* @var ValidatorInterface
29-
*/
30-
private $validator;
31-
32-
public function __construct(ValidatorInterface $validator)
33-
{
34-
$this->validator = $validator;
35-
}
36-
3726
/**
3827
* {@inheritdoc}
3928
*/
@@ -87,6 +76,6 @@ private function isCorrectChecksum(string $input): bool
8776
}
8877
$number = implode('', $characters);
8978

90-
return 0 === $this->validator->validate($number, new Luhn())->count();
79+
return 0 === $this->context->getValidator()->validate($number, new Luhn())->count();
9180
}
9281
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@
44

55
use Symfony\Component\Validator\Constraints\Isin;
66
use Symfony\Component\Validator\Constraints\IsinValidator;
7+
use Symfony\Component\Validator\Constraints\Luhn;
78
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
8-
use Symfony\Component\Validator\ValidatorBuilder;
99

1010
class IsinValidatorTest extends ConstraintValidatorTestCase
1111
{
1212
protected function createValidator()
1313
{
14-
$validatorBuilder = new ValidatorBuilder();
15-
16-
return new IsinValidator($validatorBuilder->getValidator());
14+
return new IsinValidator();
1715
}
1816

1917
public function testNullIsValid()
@@ -36,6 +34,7 @@ public function testEmptyStringIsValid()
3634
public function testValidIsin($isin)
3735
{
3836
$this->validator->validate($isin, new Isin());
37+
$this->expectViolationsAt(0, $isin, new Luhn());
3938
$this->assertNoViolation();
4039
}
4140

@@ -103,6 +102,7 @@ public function getIsinWithInvalidPattern()
103102
*/
104103
public function testIsinWithValidFormatButIncorrectChecksum($isin)
105104
{
105+
$this->expectViolationsAt(0, $isin, new Luhn());
106106
$this->assertViolationRaised($isin, Isin::INVALID_CHECKSUM_ERROR);
107107
}
108108

0 commit comments

Comments
 (0)
0