Skip to content

[DoctrineBridge] Deprecate internal test helpers in Test namespace #39696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 4, 2021

Conversation

wouterj
Copy link
Member

@wouterj wouterj commented Jan 3, 2021

Q A
Branch? 5.x
Bug fix? no
New feature? no
Deprecations? yes
Tickets -
License MIT
Doc PR -

These helper classes are only used internally in the DoctrineBridge and, as far as I can see, only make sense within the test suite of the DoctrineBridge. Having them in Test means they are covered by the BC promise, I think we can make our lives more easy by moving them to Tests.

Copy link
Member

@derrabus derrabus left a comment

Choose a reason for hiding this comment

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

Are those classes used by DoctrineBundle? If not, I'm 👍🏻 for internalizing them.

@wouterj
Copy link
Member Author

wouterj commented Jan 3, 2021

Are those classes used by DoctrineBundle?

Just double-checked, it's not used in DoctrineBundle.

@wouterj wouterj force-pushed the cleanup-test-namespace branch 2 times, most recently from a0c4c43 to b6132f3 Compare January 3, 2021 15:29
@wouterj wouterj force-pushed the cleanup-test-namespace branch 2 times, most recently from 2bf25db to 43518dd Compare January 3, 2021 15:45
@nicolas-grekas nicolas-grekas added this to the 5.x milestone Jan 3, 2021
@fabpot
Copy link
Member

fabpot commented Jan 4, 2021

Would it be better to do the inheritance the other way around: move all code to the new class and the old class would extend the new one with deprecation triggers? That way, in 6.0, it's just a matter of removing the old files (we would need to remove the final keyword on the new class but that's not an issue as code is internal anyway).

@wouterj
Copy link
Member Author

wouterj commented Jan 4, 2021

@fabpot that's what we normally do, but I don't think it works in this case. The Tests directory is excluded in dist, so we would extend from an undefined class in the deprecated one.

@fabpot fabpot force-pushed the cleanup-test-namespace branch from d5acfde to a174e6b Compare January 4, 2021 08:15
@fabpot
Copy link
Member

fabpot commented Jan 4, 2021

Thank you @wouterj.

@fabpot fabpot merged commit 670da4f into symfony:5.x Jan 4, 2021
@wouterj wouterj deleted the cleanup-test-namespace branch January 4, 2021 08:16
@dunglas
Copy link
Member

dunglas commented Feb 18, 2021

For the record, we use this helper in API Platform: https://github.com/api-platform/core/blob/main/src/Test/DoctrineOrmFilterTestCase.php#L62

If we're the only bundle using it, let's deprecate it (will find a way to do without this class, or we'll copy it), but I doubt that.

@fabpot fabpot mentioned this pull request Apr 18, 2021
@VincentLanglet
Copy link
Contributor

For the record, we use this helper in API Platform: https://github.com/api-platform/core/blob/main/src/Test/DoctrineOrmFilterTestCase.php#L62

If we're the only bundle using it, let's deprecate it (will find a way to do without this class, or we'll copy it), but I doubt that.

We also using it in SonataDoctrineORMAdminBundle

nicolas-grekas added a commit that referenced this pull request Sep 7, 2021
…ositoryFactory (derrabus)

This PR was merged into the 6.0 branch.

Discussion
----------

[DoctrineBridge] Remove DoctrineTestHelper and TestRepositoryFactory

| Q             | A
| ------------- | ---
| Branch?       | 6.0
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | Follows #39696
| License       | MIT
| Doc PR        | N/A

Commits
-------

71e8815 [DoctrineBridge] Remove DoctrineTestHelper and TestRepositoryFactory
@GPHemsley-RELX
Copy link

The above comments were never responded to.

What is the recommended way to mock a Doctrine EntityManager if not using DoctrineTestHelper?

See, for example:
#36462 (comment)

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.

8 participants