Skip to content
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

support PHPUnit 10, PHP 8.1+, cleanup #48

Merged
merged 1 commit into from Oct 23, 2023

Conversation

codemasher
Copy link
Contributor

So that's the cleanup PR mentioned in #47. It removes the random abstract classes and traits, updates to some modern PHPUnit features (e.g. data provider calls via attributes) and generally some "modern" PHP features such as typed properties.

composer.json Outdated Show resolved Hide resolved
Comment on lines 20 to 31
public function setUp():void{

if(!defined('REQUEST_FACTORY') || !class_exists(REQUEST_FACTORY)){
static::markTestSkipped('REQUEST_FACTORY class name not provided');
}

if(!defined('URI_FACTORY') || !class_exists(URI_FACTORY)){
static::markTestSkipped('URI_FACTORY class name not provided');
}

$this->requestFactory = new (REQUEST_FACTORY);
$this->uriFactory = new (URI_FACTORY);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This change is out of scope with supporting PHPUnit 10. Please revert it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The scope of this change is given in the OP.

Copy link
Collaborator

Choose a reason for hiding this comment

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

random abstract classes and traits

These are not "random", they are design decisions that have downstream impacts. Changing this package's API has consequences.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, so I checked the most popular dependents for this library and all except one are using it as a stand-alone test suite without any changes. The Slim framework is the only one that extends the test classes and because of the "design decision" it has to unnecessarily re-implement several methods that are only found in the finalized classes here. Since you want to increment the major version you should take the opportunity to amend bad design decisions. What i can do is to rename the classes back to "*TestCase" so that libraries that extend them won't break - so even with out changes after an upgrade, their tests will still run and the old methods are ignored.

Copy link
Collaborator

Choose a reason for hiding this comment

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

There are two separate concerns that need to be separated:

  1. Support PHPUnit 10 #47 wasn't a complete switch to PHPUnit 10. I merged it and reduced the scope to be PHP 8.0+ and PHPUnit 10.0+ and released it as v2.0.0. Obviously that was not quite sufficient, given that PHPUnit 10 requires PHP 8.1. So one change should be just finalizing the PHPUnit 10.x upgrade, with as few code changes as possible, so that we can release v2.0.1.
  2. This PR shows that we could make some code/API changes that would improve the test cases, and I am absolutely for that. But such changes would be represent version 3.x, because this package follows semantic versioning. Those changes need to be a separate PR that downstream users can review and have input on.

I am happy to review and merge fixes for both (1) and (2) but they need to be separate PRs.

Comment on lines 20 to 24
if(!defined('RESPONSE_FACTORY') || !class_exists(RESPONSE_FACTORY)){
static::markTestSkipped('RESPONSE_FACTORY class name not provided');
}

$this->responseFactory = new (RESPONSE_FACTORY);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This change is out of scope. Please revert it. Same goes for the rest of this PR.

The only changes should be to composer.json and anything that is necessary for PHPUnit to not give warnings about deprecations.

@codemasher
Copy link
Contributor Author

codemasher commented Oct 22, 2023

Ok, I've changed the PR to the requested changes that should have been discussed and made in #47:

  • full PHPUnit 10 support, PHP 8.1+, no changes to the original v0.x API
  • call data providers via attributes
  • static calls to PHPUnit assert methods
  • additional class_exist checks when calling a class provided via PHPUnit constant
  • instance classes from expression (new (REQUEST_FACTORY))
  • added array keys in data providers for improved PHPUnit output
  • added function/constant imports

If you don't mind I'll add another commit with the changes that were supposed to be in this PR, aka, API changes.

Copy link
Collaborator

@shadowhand shadowhand left a comment

Choose a reason for hiding this comment

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

Excellent clean up, thank you!

@shadowhand shadowhand merged commit 45648c6 into http-interop:main Oct 23, 2023
@shadowhand
Copy link
Collaborator

If you don't mind I'll add another commit with the changes that were supposed to be in this PR, aka, API changes.

As a separate PR please.

@codemasher
Copy link
Contributor Author

Good. Better tag it right now because there are already people waiting for it.

@codemasher
Copy link
Contributor Author

A small oversight on my end, i forgot a class_exists check over here:

if (!defined('URI_FACTORY')) {

codemasher added a commit to codemasher/http-factory-tests that referenced this pull request Oct 23, 2023
shadowhand added a commit that referenced this pull request Oct 23, 2023
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.

None yet

2 participants