From f6e4c04f992e384885f6977d2372c3b53882503f Mon Sep 17 00:00:00 2001 From: Joao Cardoso Date: Wed, 11 Feb 2026 08:33:51 +0100 Subject: [PATCH 1/8] Make all class properties mock perform expectations --- .../AbstractConstraintValidatorTestCase.php | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/Symfony/AbstractConstraintValidatorTestCase.php b/src/Symfony/AbstractConstraintValidatorTestCase.php index ca5f069..61597fd 100644 --- a/src/Symfony/AbstractConstraintValidatorTestCase.php +++ b/src/Symfony/AbstractConstraintValidatorTestCase.php @@ -80,12 +80,17 @@ protected function assertHandlesIncorrectConstraintType(mixed $value = null): vo { $this->expectException(UnexpectedTypeException::class); $this->validator->validate($value, $this->createMock(Constraint::class)); + + $this->executionContext->expects($this->never())->method(self::anything()); + $this->violationBuilder->expects($this->never())->method(self::anything()); } protected function expectNoViolations(): void { - $this->executionContext->expects(static::never())->method('buildViolation'); - $this->executionContext->expects(static::never())->method('addViolation'); + $this->executionContext->expects($this->never())->method('buildViolation'); + $this->executionContext->expects($this->never())->method('addViolation'); + + $this->violationBuilder->expects($this->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($this->once())->method('addViolation')->with($message, $parameters); + + $this->violationBuilder->expects($this->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($this->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($this->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($this->once())->method('setInvalidValue')->with($invalidValue)->willReturnSelf(); } - $this->violationBuilder->expects(static::once())->method('addViolation'); + $this->violationBuilder->expects($this->once())->method('addViolation'); } /** @@ -145,7 +152,9 @@ 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($this->once())->method('buildViolation')->with($message, $parameters)->willReturn($this->violationBuilder); + + $this->violationBuilder->expects($this->never())->method(self::anything()); return new ConstraintViolationBuilderAssertion($this->violationBuilder); } From 85676484b2bd6b15497215a11a87a4f5618e3a21 Mon Sep 17 00:00:00 2001 From: Joao Cardoso Date: Wed, 11 Feb 2026 08:40:07 +0100 Subject: [PATCH 2/8] Make all class properties mock perform expectations --- .../AbstractConstraintValidatorTestCase.php | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Symfony/AbstractConstraintValidatorTestCase.php b/src/Symfony/AbstractConstraintValidatorTestCase.php index 61597fd..b64dee7 100644 --- a/src/Symfony/AbstractConstraintValidatorTestCase.php +++ b/src/Symfony/AbstractConstraintValidatorTestCase.php @@ -81,16 +81,16 @@ protected function assertHandlesIncorrectConstraintType(mixed $value = null): vo $this->expectException(UnexpectedTypeException::class); $this->validator->validate($value, $this->createMock(Constraint::class)); - $this->executionContext->expects($this->never())->method(self::anything()); - $this->violationBuilder->expects($this->never())->method(self::anything()); + $this->executionContext->expects(static::never())->method(self::anything()); + $this->violationBuilder->expects(static::never())->method(self::anything()); } protected function expectNoViolations(): void { - $this->executionContext->expects($this->never())->method('buildViolation'); - $this->executionContext->expects($this->never())->method('addViolation'); + $this->executionContext->expects(static::never())->method('buildViolation'); + $this->executionContext->expects(static::never())->method('addViolation'); - $this->violationBuilder->expects($this->never())->method(self::anything()); + $this->violationBuilder->expects(static::never())->method(self::anything()); } /** @@ -101,9 +101,9 @@ protected function expectNoViolations(): void */ protected function expectViolation(string $message, array $parameters = []): void { - $this->executionContext->expects($this->once())->method('addViolation')->with($message, $parameters); + $this->executionContext->expects(static::once())->method('addViolation')->with($message, $parameters); - $this->violationBuilder->expects($this->never())->method(self::anything()); + $this->violationBuilder->expects(static::never())->method(self::anything()); } /** @@ -120,14 +120,14 @@ protected function expectViolationViaBuilder( ?string $atPath = null, mixed $invalidValue = self::IGNORE_INVALID_VALUE ): void { - $this->executionContext->expects($this->once())->method('buildViolation')->with($message, $parameters)->willReturn($this->violationBuilder); + $this->executionContext->expects(static::once())->method('buildViolation')->with($message, $parameters)->willReturn($this->violationBuilder); if ($atPath !== null) { - $this->violationBuilder->expects($this->once())->method('atPath')->with($atPath)->willReturnSelf(); + $this->violationBuilder->expects(static::once())->method('atPath')->with($atPath)->willReturnSelf(); } if ($invalidValue !== self::IGNORE_INVALID_VALUE) { - $this->violationBuilder->expects($this->once())->method('setInvalidValue')->with($invalidValue)->willReturnSelf(); + $this->violationBuilder->expects(static::once())->method('setInvalidValue')->with($invalidValue)->willReturnSelf(); } - $this->violationBuilder->expects($this->once())->method('addViolation'); + $this->violationBuilder->expects(static::once())->method('addViolation'); } /** @@ -152,9 +152,9 @@ protected function expectViolationViaBuilder( */ protected function expectBuildViolation(string $message, array $parameters = []): ConstraintViolationBuilderAssertion { - $this->executionContext->expects($this->once())->method('buildViolation')->with($message, $parameters)->willReturn($this->violationBuilder); + $this->executionContext->expects(static::once())->method('buildViolation')->with($message, $parameters)->willReturn($this->violationBuilder); - $this->violationBuilder->expects($this->never())->method(self::anything()); + $this->violationBuilder->expects(static::never())->method(self::anything()); return new ConstraintViolationBuilderAssertion($this->violationBuilder); } From 368be8f3323960a0c8450d645c5268e43b459336 Mon Sep 17 00:00:00 2001 From: Joao Cardoso Date: Wed, 11 Feb 2026 08:42:27 +0100 Subject: [PATCH 3/8] Make all class properties mock perform expectations --- src/Symfony/AbstractConstraintValidatorTestCase.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Symfony/AbstractConstraintValidatorTestCase.php b/src/Symfony/AbstractConstraintValidatorTestCase.php index b64dee7..e3070f8 100644 --- a/src/Symfony/AbstractConstraintValidatorTestCase.php +++ b/src/Symfony/AbstractConstraintValidatorTestCase.php @@ -154,8 +154,6 @@ protected function expectBuildViolation(string $message, array $parameters = []) { $this->executionContext->expects(static::once())->method('buildViolation')->with($message, $parameters)->willReturn($this->violationBuilder); - $this->violationBuilder->expects(static::never())->method(self::anything()); - return new ConstraintViolationBuilderAssertion($this->violationBuilder); } } From 37a5f82dea99f1a90b3ec8aa64aa9e3cbd00b874 Mon Sep 17 00:00:00 2001 From: Joao Cardoso Date: Wed, 11 Feb 2026 08:45:54 +0100 Subject: [PATCH 4/8] Make all class properties mock perform expectations --- src/Symfony/AbstractConstraintValidatorTestCase.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Symfony/AbstractConstraintValidatorTestCase.php b/src/Symfony/AbstractConstraintValidatorTestCase.php index e3070f8..1aae4e5 100644 --- a/src/Symfony/AbstractConstraintValidatorTestCase.php +++ b/src/Symfony/AbstractConstraintValidatorTestCase.php @@ -78,11 +78,12 @@ protected function initRootForm(): Form */ protected function assertHandlesIncorrectConstraintType(mixed $value = null): void { + $this->executionContext->expects(static::never())->method($this->anything()); + $this->violationBuilder->expects(static::never())->method($this->anything()); + $this->expectException(UnexpectedTypeException::class); $this->validator->validate($value, $this->createMock(Constraint::class)); - $this->executionContext->expects(static::never())->method(self::anything()); - $this->violationBuilder->expects(static::never())->method(self::anything()); } protected function expectNoViolations(): void @@ -90,7 +91,7 @@ protected function expectNoViolations(): void $this->executionContext->expects(static::never())->method('buildViolation'); $this->executionContext->expects(static::never())->method('addViolation'); - $this->violationBuilder->expects(static::never())->method(self::anything()); + $this->violationBuilder->expects(static::never())->method($this->anything()); } /** @@ -103,7 +104,7 @@ protected function expectViolation(string $message, array $parameters = []): voi { $this->executionContext->expects(static::once())->method('addViolation')->with($message, $parameters); - $this->violationBuilder->expects(static::never())->method(self::anything()); + $this->violationBuilder->expects(static::never())->method($this->anything()); } /** From 326ebf762a3f118b15f14ac9479954e4ccd76c7c Mon Sep 17 00:00:00 2001 From: Joao Cardoso Date: Wed, 11 Feb 2026 08:51:02 +0100 Subject: [PATCH 5/8] Make all class properties mock perform expectations --- .../AbstractConstraintValidatorTestCase.php | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Symfony/AbstractConstraintValidatorTestCase.php b/src/Symfony/AbstractConstraintValidatorTestCase.php index 1aae4e5..ccc570b 100644 --- a/src/Symfony/AbstractConstraintValidatorTestCase.php +++ b/src/Symfony/AbstractConstraintValidatorTestCase.php @@ -78,8 +78,8 @@ protected function initRootForm(): Form */ protected function assertHandlesIncorrectConstraintType(mixed $value = null): void { - $this->executionContext->expects(static::never())->method($this->anything()); - $this->violationBuilder->expects(static::never())->method($this->anything()); + $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)); @@ -88,10 +88,10 @@ protected function assertHandlesIncorrectConstraintType(mixed $value = null): vo 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(static::never())->method($this->anything()); + $this->violationBuilder->expects(self::never())->method(self::anything()); } /** @@ -102,9 +102,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(static::never())->method($this->anything()); + $this->violationBuilder->expects(self::never())->method(self::anything()); } /** @@ -121,14 +121,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'); } /** @@ -153,7 +153,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); } From 1e7effa1407aac95210ff13da7a6d24325bbccee Mon Sep 17 00:00:00 2001 From: Joao Cardoso Date: Wed, 11 Feb 2026 08:33:51 +0100 Subject: [PATCH 6/8] Make all class properties mock perform expectations --- .../AbstractConstraintValidatorTestCase.php | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) 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); } From 2b48668de8f1569048366377223bce0cd1dccf44 Mon Sep 17 00:00:00 2001 From: Joao Cardoso Date: Wed, 11 Feb 2026 08:54:15 +0100 Subject: [PATCH 7/8] Make all class properties mock perform expectations --- src/Symfony/AbstractConstraintValidatorTestCase.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Symfony/AbstractConstraintValidatorTestCase.php b/src/Symfony/AbstractConstraintValidatorTestCase.php index ccc570b..e634534 100644 --- a/src/Symfony/AbstractConstraintValidatorTestCase.php +++ b/src/Symfony/AbstractConstraintValidatorTestCase.php @@ -83,7 +83,6 @@ protected function assertHandlesIncorrectConstraintType(mixed $value = null): vo $this->expectException(UnexpectedTypeException::class); $this->validator->validate($value, $this->createMock(Constraint::class)); - } protected function expectNoViolations(): void From d884cf5e0437f5f19935da900fb00af0bc194372 Mon Sep 17 00:00:00 2001 From: Joao Cardoso Date: Wed, 11 Feb 2026 13:38:27 +0100 Subject: [PATCH 8/8] Make all class properties mock perform expectations --- src/Symfony/AbstractConstraintValidatorTestCase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/AbstractConstraintValidatorTestCase.php b/src/Symfony/AbstractConstraintValidatorTestCase.php index e634534..667291e 100644 --- a/src/Symfony/AbstractConstraintValidatorTestCase.php +++ b/src/Symfony/AbstractConstraintValidatorTestCase.php @@ -82,7 +82,7 @@ protected function assertHandlesIncorrectConstraintType(mixed $value = null): vo $this->violationBuilder->expects(self::never())->method(self::anything()); $this->expectException(UnexpectedTypeException::class); - $this->validator->validate($value, $this->createMock(Constraint::class)); + $this->validator->validate($value, static::createStub(Constraint::class)); } protected function expectNoViolations(): void