Codeception / Stub

Flexible Stub wrapper for PHPUnit's Mock Builder
MIT License
295 stars 17 forks source link

Reversed MockObject_Generator condition BC break #5

Closed dereuromark closed 6 years ago

dereuromark commented 6 years ago

https://github.com/Codeception/Stub/pull/4 has introduced a sudden BC break and all our tests to now fail hard.

Cannot declare class PHPUnit\Framework\MockObject\Generator, because the name is already in use

The !class_exists('PHPUnit\Framework\MockObject\Generator') must be kept to avoid redeclare of such a shim method! Especially in a patch release. We are now forced to lock down to 1.0.2 everywhere, as do all others most likely.

Naktibalda commented 6 years ago

What version of PhpUnit have you got installed?

dereuromark commented 6 years ago

Codeception PHP Testing Framework v2.3.9 Powered by PHPUnit 6.5.8 by Sebastian Bergmann and contributors.

Naktibalda commented 6 years ago

Thanks,

I reverted this change and released a new version.

dereuromark commented 6 years ago

Thank you for the quick revert/fix!

Naktibalda commented 6 years ago

@dereuromark Is there a particular reason why you are still using Codeception 2.3 ?

The root cause of your issue was that Codeception 2.3 creates the same aliases as Codeception/Stub in its shim.php file.

I am thinking about reintroducing my change and adding conflict to composer.json

"conflicts": {
  "codeception/codeception": "<2.4.0"
}

Or I could bump a major version and update Codeception 2.4 to use Stub 2.0.

dereuromark commented 6 years ago

You introduced other small regressions with the already discussed shim changes a while back. Thus, in order to continue working, we had to lock down the versions here.

Naktibalda commented 6 years ago

What regressions? I don't see any issues reported by you.

Please raise an issue if something is preventing you from using Codeception 2.4

dereuromark commented 6 years ago

It has to do with all the aliases dropped - https://github.com/Codeception/Codeception/compare/2.3.9...2.4.0#diff-b38cfe53d6f105ad2685aa4bc6f020deL19 You can sure make a new major and constraint to it, this way it is a bit less error prone and less unexpected to break. Pulling a patch shouldnt kill the whole testing suite :)

Naktibalda commented 6 years ago

Ah, you relied on Codeception providing aliases for PHPUnit_Framework_ classes. It shouldn't be too hard to update your code to use namespaced PHPUnit\ classes.