Skip to content

Conversation

@xabbuh
Copy link
Member

@xabbuh xabbuh commented Dec 12, 2025

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues part of #62669
License MIT

$metadata = $this->getMockBuilder(ClassMetadata::class)->setConstructorArgs([''])->onlyMethods(['addPropertyConstraint'])->getMock();
$this->validator->expects($this->any())->method('getMetadataFor')->willReturn($metadata);
$this->validator->expects($this->any())->method('validate')->willReturn(new ConstraintViolationList());
$this->validator = (new ValidatorBuilder())->getValidator();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the validator is protected, someone could add expections $this->validator->method(...) when using the trait.

So is this change considered as a BC break ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I won't consider this a BC break as the type of the property is ValidatorInterface. In other places where we communicated the type to be MockObject I kept it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would keeping the mock be problematic? Symfony is widely used enough for someone to be affected by this ;)

parent::setUp();

$this->dispatcher = $this->createMock(EventDispatcherInterface::class);
$this->dispatcher = new EventDispatcher();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, the dispatcher is protected so someone could have added expectation on the dispatcher in his tests

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants