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 8 fixes #3406

Merged
merged 8 commits into from Feb 8, 2021
Merged

PHPUnit 8 fixes #3406

merged 8 commits into from Feb 8, 2021

Conversation

dregad
Copy link
Contributor

@dregad dregad commented Feb 6, 2021

Fixing most of the PHPUnit errors on PHP8 in PR #3404

- Add comment to regroup editor/IDE and temp files
- Move config-related excludes together with other DokuWiki ones
The following files should not be checked in:
- phpunit.phar: per documentation [1], it is PHP version-specific
- PHPUnit's cache file
- data files generated during tests execution

[1]: https://www.dokuwiki.org/devel:unittesting
$INPUT is set to 'test2', but the $_POST checks for 'test'.
There are actually 2 distinct test cases of invalid methods:

1. Not following the definition in Api class's PHPDoc block
   - core methods begin by a 'dokuwiki' or 'wiki' followed by a . and
     the method name itself.
   - plugin methods are formed like 'plugin.<plugin name>.<method name>'
2. Method "type" does not begin with 'dokuwiki', 'wiki' or 'plugin'

A new check was added so both are now covered.

Test was modified to make use of PHPUnit expectException() method,
instead of relying on a try/catch block.
This error only occurs when PHPUnit runs both the `testScripts` and the
`test_Validity` suites [1], because all tests are running in the same
PHP process.

Adding an `if(!defined` check to avoid the problem.

[1]: ./phpunit.phar --filter 'testScripts|test_Validity'
@dregad dregad changed the title Phpunit8 PHPUnit 8 fixes Feb 6, 2021
@dregad
Copy link
Contributor Author

dregad commented Feb 6, 2021

Before

Tests: 1666, Assertions: 27000, Errors: 30, Failures: 2, Skipped: 102.

After

Tests: 1666, Assertions: 27130, Errors: 3, Failures: 1, Skipped: 101.

@splitbrain
Copy link
Collaborator

Awesome! Looks good except for the thing the Scrutinizer Inspections found in HTTPClient, something is wrong with the order in which $port is initialized now.

The variable ``$port`` seems only to be defined at a later point.
As such the call to ``isset()`` seems to always evaluate to ``false``.
@dregad
Copy link
Contributor Author

dregad commented Feb 6, 2021

except for the thing the Scrutinizer Inspections found in HTTPClient

Fixed.

@splitbrain splitbrain merged commit 7566f80 into dokuwiki:phpunit8 Feb 8, 2021
@dregad dregad deleted the phpunit8 branch February 8, 2021 09:19
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