diff --git a/src/Symfony/AbstractConstraintValidatorTestCase.php b/src/Symfony/AbstractConstraintValidatorTestCase.php index ca5f069..e634534 100644 --- a/src/Symfony/AbstractConstraintValidatorTestCase.php +++ b/src/Symfony/AbstractConstraintValidatorTestCase.php @@ -78,14 +78,19 @@ protected function initRootForm(): Form */ protected function assertHandlesIncorrectConstraintType(mixed $value = null): void { + $this->executionContext->expects(self::never())->method(self::anything()); + $this->violationBuilder->expects(self::never())->method(self::anything()); + $this->expectException(UnexpectedTypeException::class); $this->validator->validate($value, $this->createMock(Constraint::class)); } protected function expectNoViolations(): void { - $this->executionContext->expects(static::never())->method('buildViolation'); - $this->executionContext->expects(static::never())->method('addViolation'); + $this->executionContext->expects(self::never())->method('buildViolation'); + $this->executionContext->expects(self::never())->method('addViolation'); + + $this->violationBuilder->expects(self::never())->method(self::anything()); } /** @@ -96,7 +101,9 @@ protected function expectNoViolations(): void */ protected function expectViolation(string $message, array $parameters = []): void { - $this->executionContext->expects(static::once())->method('addViolation')->with($message, $parameters); + $this->executionContext->expects(self::once())->method('addViolation')->with($message, $parameters); + + $this->violationBuilder->expects(self::never())->method(self::anything()); } /** @@ -113,14 +120,14 @@ protected function expectViolationViaBuilder( ?string $atPath = null, mixed $invalidValue = self::IGNORE_INVALID_VALUE ): void { - $this->executionContext->expects(static::once())->method('buildViolation')->with($message, $parameters)->willReturn($this->violationBuilder); + $this->executionContext->expects(self::once())->method('buildViolation')->with($message, $parameters)->willReturn($this->violationBuilder); if ($atPath !== null) { - $this->violationBuilder->expects(static::once())->method('atPath')->with($atPath)->willReturnSelf(); + $this->violationBuilder->expects(self::once())->method('atPath')->with($atPath)->willReturnSelf(); } if ($invalidValue !== self::IGNORE_INVALID_VALUE) { - $this->violationBuilder->expects(static::once())->method('setInvalidValue')->with($invalidValue)->willReturnSelf(); + $this->violationBuilder->expects(self::once())->method('setInvalidValue')->with($invalidValue)->willReturnSelf(); } - $this->violationBuilder->expects(static::once())->method('addViolation'); + $this->violationBuilder->expects(self::once())->method('addViolation'); } /** @@ -145,7 +152,7 @@ protected function expectViolationViaBuilder( */ protected function expectBuildViolation(string $message, array $parameters = []): ConstraintViolationBuilderAssertion { - $this->executionContext->expects(static::once())->method('buildViolation')->with($message, $parameters)->willReturn($this->violationBuilder); + $this->executionContext->expects(self::once())->method('buildViolation')->with($message, $parameters)->willReturn($this->violationBuilder); return new ConstraintViolationBuilderAssertion($this->violationBuilder); }