doctrine / mongodb-odm

The Official PHP MongoDB ORM/ODM
https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/
MIT License
1.09k stars 502 forks source link

Normalize `assert*()` calls in tests #2441

Closed IonBazan closed 7 months ago

IonBazan commented 2 years ago

Improvement

Currently assert*() calls are inconsistent between tests:

This should be enforced by static analysis/code style.

hunomina commented 1 year ago

I'll have a look at this 😉

malarzm commented 1 year ago

@hunomina I've merged your PR up to 2.5.x branch - would you like to change all remaining calls there? We had few features added to 2.5.x that were not present on 2.4.x.

hunomina commented 1 year ago

Oh! Sure, I can have a look 😉

IonBazan commented 1 year ago

@hunomina I think you missed a few hidden spots where we still call them non-statically: https://github.com/doctrine/mongodb-odm/blob/5fcca6cc7e5e93bd6d2f3ee4a2f08ca9e1689939/tests/Doctrine/ODM/MongoDB/Tests/Events/PreUpdateEventArgsTest.php#L74-L110

and

https://github.com/doctrine/mongodb-odm/blob/5fcca6cc7e5e93bd6d2f3ee4a2f08ca9e1689939/tests/Doctrine/ODM/MongoDB/Tests/Events/LifecycleListenersTest.php#L240-L270

There are quite camouflaged so it's really hard to spot them but we will be able to remove the $phpunit property completely there.

Can you submit a PR fixing those for 2.4.x?

BTW these listeners could perhaps be potentially replaced by anonymous classes.

hunomina commented 1 year ago

I searched for occurrences using \$this->.*assert this time.

I could only find two of them. PR coming right up 😄

hunomina commented 1 year ago

There you go. I'll create another PR to fix 2.5.x 😉

IonBazan commented 7 months ago

I think we can close it here