Skip to content

Conversation

@aristath
Copy link
Member

No description provided.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 30, 2025

Test on Playground
Test this pull request on the Playground
or download the zip

This was a big one...
The script was prompting for user input when the test database already exists, causing CI to fail. This commit adds a check for CI environment ( variable) or non-interactive shell (! -t 0) and automatically proceeds with database recreation in those cases.

Fixes the Code Coverage Check failure on PR #700.
The coverage extraction was running PHPUnit twice - once for the actual test with coverage, and once to try to extract the percentage. The second run didn't have the proper test environment, resulting in empty output.

Fixed by capturing the output from the first test run using 'tee' and then parsing it in the summary step.

Fixes the NaN% issue in PR coverage reports.
Changes:
1. Extract coverage percentage from clover XML file instead of re-running tests
   - More reliable as it uses the actual coverage data
   - Parses statements/coveredstatements from coverage.xml

2. Update existing coverage comments instead of creating new ones
   - Finds existing bot comments with 'Code Coverage Report'
   - Updates the comment if found, creates new one if not
   - Reduces PR comment spam

Fixes NaN% issue and addresses comment duplication.
The coverage.xml file wasn't being generated in the expected location, causing the coverage extraction to fail and report 0%. Using github.workspace ensures the file is written to the correct location.
Adding debug output to:
- List all coverage files in both locations
- Show first 50 lines of coverage.xml
- Display extracted LINES and COVERED values
- Try alternative attribute names (elements/coveredelements)

This will help identify why coverage is showing 0%.
The 'composer test -- --coverage-clover=...' wasn't passing the arguments correctly to PHPUnit, causing coverage.xml not to be generated.

Changed to call vendor/bin/phpunit directly with all required flags including --dont-report-useless-tests from the composer script.
The coverage configuration was pointing to a non-existent 'src' directory, causing PHPUnit to not generate any coverage data. Changed to 'classes' which is the actual source code directory.

This was the root cause of 0% coverage reporting.
aristath and others added 30 commits November 5, 2025 08:54
The tests were catching WPAjaxDieStopException but wp_send_json_error()
actually throws WPAjaxDieContinueException.

Fixed in:
- test-class-ajax-security-base.php (2 occurrences)
- test-class-ajax-security-aioseo.php (1 occurrence)
- test-class-ajax-security-yoast.php (1 occurrence)

This fixes the 4 test errors:
- Ajax_Security_Base_Test::test_verify_nonce_or_fail_invalid
- Ajax_Security_Base_Test::test_verify_capability_or_fail_non_admin
- Ajax_Security_AIOSEO_Test::test_verify_aioseo_active_or_fail_not_active
- Ajax_Security_Yoast_Test::test_verify_yoast_active_or_fail_not_active

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
…ion-with-traits

Reduce code duplication using traits
…ctive-task-load

Dont enqueue assets or add popover if interactive task is not published
…grid-as-dependency

Dont enqueue grid script on WP Dashboard page
…omment-workflow

Improve version handling in zip file
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.

4 participants