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

PhpUnit 10 Compatibility Part 3 (Last) #3530

Merged
merged 8 commits into from
Apr 28, 2023
Merged

Conversation

oleibman
Copy link
Collaborator

Final changes for PhpUnit 10, including enabling it for testing. This finishes the work of PR #3523 and PR #3526.

The major remaining problem with PhpUnit 10 is that earlier releases converted notices and warnings to exceptions, and 10 does not. Not having the information provided by the messages seems risky to me. Fortunately, it appears that you can add an error handler to the test bootstrap for 10 and make it act like earlier versions; I have done so. In order to demonstrate the effectiveness of this handler, a new otherwise unused class Helper/Handler and tests for that class are added.

As part of the testing of this change, it became apparent that the fopen in OLE::getStream attempts to create a dynamic property $context in Shared/OLE/ChainedBlockStream, and that action is deprecated in Php8.2. Adding the property to the class eliminates that problem. No executable code is added, and this is the only change to source code.

There also seems to have been a change in assertXmlStringEqualsXmlString in PhpUnit 10. The only test which uses that method is Chart/Issue589Test, and both the places which use that method could just as easily and effectively use assertSame. They are changed to do so.

This is:

  • a bugfix
  • a new feature
  • refactoring
  • additional unit tests
  • tool compatibility

Checklist:

Why this change is needed?

Provide an explanation of why this change is needed, with links to any Issues (if appropriate).
If this is a bugfix or a new feature, and there are no existing Issues, then please also create an issue that will make it easier to track progress with this PR.

Final changes for PhpUnit 10, including enabling it for testing. This finishes the work of PR PHPOffice#3523 and PR PHPOffice#3526.

The major remaining problem with PhpUnit 10 is that earlier releases converted notices and warnings to exceptions, and 10 does not. Not having the information provided by the messages seems risky to me. Fortunately, it appears that you can add an error handler to the test bootstrap for 10 and make it act like earlier versions; I have done so. In order to demonstrate the effectiveness of this handler, a new otherwise unused class Helper/Handler and tests for that class are added.

As part of the testing of this change, it became apparent that the fopen in OLE::getStream attempts to create a dynamic property $context in Shared/OLE/ChainedBlockStream, and that action is deprecated in Php8.2. Adding the property to the class eliminates that problem. No executable code is added, and this is the only change to source code.

There also seems to have been a change in assertXmlStringEqualsXmlString in PhpUnit 10. The only test which uses that method is Chart/Issue589Test, and both the places which use that method could just as easily and effectively use assertSame. They are changed to do so.
Not supported in PhpUnit 10. I'm not at all sure that this is the correct solution for this problem.
Not sure how to test this locally. We'll see if it works on github.
Not sure why testDeprecated is not working in Github; it works locally. Disable it for now and continue to research.
6 new command line args to replace the 1 they got rid of.
Deprecated messages are suppressed by default setting for error_reporting. Switch that to E_ALL in bootstrap and restore original test.
Default configuration option caused deprecation messages to be suppressed. Change the option.
@dubox dubox mentioned this pull request Apr 23, 2023
11 tasks
@oleibman oleibman merged commit c874306 into PHPOffice:master Apr 28, 2023
@oleibman oleibman deleted the handler branch May 12, 2023 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant