Skip to content

#[AllowMockObjectsWithoutExpectations] incorrectly added #9650

@philbates35

Description

@philbates35

Bug Report

Subject Details
Rector version 2.3.6 (invoke vendor/bin/rector --version)

Any phpunit test case that extends \Symfony\Component\Validator\Test\ConstraintValidatorTestCase (symfony/validator 7.4.5), is having the AllowMockObjectsWithoutExpectations attribute added to it, but as per symfony/symfony#62669 and symfony/symfony#62745, since symfony/validator 7.4.3, its replaced all mocks that have no expectations with stubs so generates no warnings.

The fact that there are no phpunit warnings when runninng these tests, makes me think that this this is fixed on the symfony side and rector is flagging this as a false positive. I'm not sure exactly what it is about ConstraintValidatorTestCase that makes rector think that it still needs to add the AllowMockObjectsWithoutExpectations attribute though.

Minimal PHP Code Causing Issue

Install symfony/validator 7.4.5, write any custom test that extends \Symfony\Component\Validator\Test\ConstraintValidatorTestCase, run rector on it with the phpunit rules enabled, and you'll see that AllowMockObjectsWithoutExpectations is added to your test class.

Expected Behaviour

AllowMockObjectsWithoutExpectations attribute should not be added automatically to all tests that extend \Symfony\Component\Validator\Test\ConstraintValidatorTestCase.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions