Skip to content

Conversation

@chq81
Copy link

@chq81 chq81 commented Mar 2, 2020

@martin-helmich I added support for phpunit 9.

@martin-helmich
Copy link
Owner

martin-helmich commented Mar 2, 2020 via email

],
"require": {
"php": "^7.2",
"php": "^7.2 || ^7.3",
Copy link
Owner

Choose a reason for hiding this comment

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

This is not necessary; ^7.2 already translates to >= 7.2 && < 8.0

Copy link
Author

Choose a reason for hiding this comment

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

You are right. I am used to gracefully update dependencies in libraries due to backwards compatibility, but this is not necessary here.

Copy link
Author

Choose a reason for hiding this comment

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

You are right. I am used to gracefully update dependencies in libraries due to backwards compatibility, but this is not necessary here.

Upon further inspection, I do think it is necessary as with this notation we still allow users with PHP 7.2 to make use of this package with PHPUnit 8, from 7.3 PHPUnit 9 is needed (as it is the minimum requirement).

composer.json Outdated
},
"conflict": {
"phpunit/phpunit": "<8.0 || >= 9.0"
"phpunit/phpunit": "<8.0"
Copy link
Owner

Choose a reason for hiding this comment

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

This was originally a safe-guard against this package being used with (future) versions of PHPUnit that it was not tested against. Even if we now support PHPUnit 9, the same argument can still be made for the next upcoming major versions.

Let's make this future-proof:

Suggested change
"phpunit/phpunit": "<8.0"
"phpunit/phpunit": "<8.0 || >= 10.0"

Copy link
Author

Choose a reason for hiding this comment

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

I will do that.

},
"autoload-dev": {
"files": [
"vendor/phpunit/phpunit/src/Framework/Assert/Functions.php",
Copy link
Owner

Choose a reason for hiding this comment

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

The functional interface is still alive and well in PHPUnit 9. I don't see the need for removing this include and rewriting the tests in the later files. Can you share your thoughts on why this change was necessary?

Copy link
Author

Choose a reason for hiding this comment

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

The functional interface is still alive and well in PHPUnit 9. I don't see the need for removing this include and rewriting the tests in the later files. Can you share your thoughts on why this change was necessary?

I removed the autoloading as the file was autoloaded twice and so it threw a redeclaration exception. I now imported the functions in the unit test suites to make use of the functional interface. I hope this is fine for you.

@chq81
Copy link
Author

chq81 commented Mar 3, 2020

@martin-helmich As I already mentioned, we do not need to manually autoload the functions of PHPUnit anymore as they are now namespaced. This unfortunately leads to the problem that it is imho not possible to keep the next version backwards-compatible with PHPUnit 8, as I need to change the namespaces when using the functional interface. Should I get rid of PHPUnit 8 in this PR and only keep PHPUnit 9 (which also would mean to drop support of PHP 7.2 from here on, as PHPUnit 9 requires PHP 7.3)?

@chq81 chq81 requested a review from martin-helmich March 3, 2020 09:54
@chq81
Copy link
Author

chq81 commented Mar 9, 2020

@martin-helmich Did you find the time to look at my comments? Would be great to get this sorted.

@chq81
Copy link
Author

chq81 commented Mar 24, 2020

@martin-helmich Ping :)

@martin-helmich
Copy link
Owner

Oh sorry, I kind of lost track of this one. I'll have another look at this ASAP (and also try to think of something regarding backwards-compatibility).

@martinssipenko
Copy link
Contributor

This is a blocker for upgrading https://github.com/martin-helmich/phpunit-psr7-assert. Perhaps there is a better way, as this disallows to upgrade PHPUnit which has a new major every year.

@chq81
Copy link
Author

chq81 commented Mar 25, 2020

@martin-helmich We could tag this version with the new namespaces as a new major version (4.0). Everything related to PHPUnit 8 will be a minor version release in 3.x. In https://github.com/martin-helmich/phpunit-psr7-assert, we do the same, introducing a new major release version for PHPUnit 9.

@martin-helmich
Copy link
Owner

So! Finally getting to this. I've forked this pull request into my own branch in #20 so that I could put some of my own changes on top before merging.

When commenting, I did not realize that PHPUnit's functional interface is now namespaced, which essentially requires a breaking change -- thanks for pointing that out. I've decided to forego using PHPUnit's functional assertions (so I've reverted aa56581) to keep compatibility with PHPUnit 8 and 9.

@chq81 chq81 deleted the phpunit9-support branch March 30, 2020 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants