Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions src/Symfony/Component/Validator/Constraints/IsinValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
use Symfony\Component\Validator\Validator\ValidatorInterface;

/**
* @author Laurent Masforné <[email protected]>
Expand All @@ -24,16 +23,6 @@
*/
class IsinValidator extends ConstraintValidator
{
/**
* @var ValidatorInterface
*/
private $validator;

public function __construct(ValidatorInterface $validator)
{
$this->validator = $validator;
}

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -87,6 +76,6 @@ private function isCorrectChecksum(string $input): bool
}
$number = implode('', $characters);

return 0 === $this->validator->validate($number, new Luhn())->count();
return 0 === $this->context->getValidator()->validate($number, new Luhn())->count();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@

use Symfony\Component\Validator\Constraints\Isin;
use Symfony\Component\Validator\Constraints\IsinValidator;
use Symfony\Component\Validator\Constraints\Luhn;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
use Symfony\Component\Validator\ValidatorBuilder;

class IsinValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
{
$validatorBuilder = new ValidatorBuilder();

return new IsinValidator($validatorBuilder->getValidator());
return new IsinValidator();
}

public function testNullIsValid()
Expand All @@ -36,6 +34,7 @@ public function testEmptyStringIsValid()
public function testValidIsin($isin)
{
$this->validator->validate($isin, new Isin());
$this->expectViolationsAt(0, $isin, new Luhn());
$this->assertNoViolation();
}

Expand Down Expand Up @@ -103,6 +102,7 @@ public function getIsinWithInvalidPattern()
*/
public function testIsinWithValidFormatButIncorrectChecksum($isin)
{
$this->expectViolationsAt(0, $isin, new Luhn());
$this->assertViolationRaised($isin, Isin::INVALID_CHECKSUM_ERROR);
}

Expand Down