Skip to content

Conversation

@kasparsd
Copy link
Collaborator

@kasparsd kasparsd commented Sep 5, 2025

What?

Why?

How?

Testing Instructions

Screenshots or screencast

Changelog Entry

Added - New feature.
Changed - Existing functionality.
Deprecated - Soon-to-be removed feature.
Removed - Feature.
Fixed - Bug fix.
Security - Vulnerability.

@kasparsd
Copy link
Collaborator Author

kasparsd commented Sep 5, 2025

@dd32 I noticed that WP core has switched to Codecov for coverage reporting. Could we have this enabled for this repository as well?

"require-dev": {
"automattic/vipwpcs": "^3.0",
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"php-coveralls/php-coveralls": "^2.8",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This package doesn't support PHP 8.1 or later until php-coveralls/php-coveralls#359 is merged.

"lint-compat": "phpcs -p --standard=PHPCompatibilityWP --runtime-set testVersion 7.2- --extensions=php --ignore='tests/,dist/,includes/Yubico/,vendor/,node_modules/' .",
"lint-phpstan": "phpstan analyse --verbose --memory-limit=1G",
"test": "vendor/bin/phpunit",
"test": "phpunit --coverage-text",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This now prints a nice summary:

Code Coverage Report:       
  2025-09-05 08:44:35       
                            
 Summary:                   
  Classes:  8.33% (1/12)    
  Methods: 46.29% (81/175)  
  Lines:   58.21% (801/1376)

@Two.Factor::Two_Factor_Totp
  Methods:  76.19% (16/21)   Lines:  91.41% (117/128)
@Two_Factor::Two_Factor_Backup_Codes
  Methods:  76.92% (10/13)   Lines:  96.34% ( 79/ 82)
@Two_Factor::Two_Factor_Core
  Methods:  45.45% (30/66)   Lines:  59.79% (394/659)
@Two_Factor::Two_Factor_Dummy
  Methods: 100.00% ( 5/ 5)   Lines: 100.00% (  9/  9)
@Two_Factor::Two_Factor_Email
  Methods:  57.89% (11/19)   Lines:  64.38% ( 47/ 73)
@Two_Factor::Two_Factor_FIDO_U2F
  Methods:   6.67% ( 1/15)   Lines:  40.68% ( 48/118)
@Two_Factor::Two_Factor_Provider
  Methods:  54.55% ( 6/11)   Lines:  73.33% ( 22/ 30)
\u2flib_server::u2flib_server\U2F
  Methods:  18.18% ( 2/11)   Lines:  62.04% ( 85/137)

<include>

<filter>
<whitelist addUncoveredFilesFromWhitelist="false" processUncoveredFilesFromWhitelist="false">
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Converting to the new format supported by phpunit v9 and later.

This was referenced Sep 5, 2025
@kasparsd kasparsd merged commit 6dfe32b into master Sep 5, 2025
54 checks passed
@kasparsd kasparsd deleted the phpunit-coverage-linter branch September 5, 2025 08:51
@jeffpaul jeffpaul added this to the 0.15.0 milestone Sep 5, 2025
@dd32
Copy link
Member

dd32 commented Sep 8, 2025

@dd32 I noticed that WP core has switched to Codecov for coverage reporting. Could we have this enabled for this repository as well?

@kasparsd Sure, I've set it up with a repo secret per https://app.codecov.io/github/WordPress/two-factor here's the instructions it provided:

Install requirements in your terminal:
npm install --save-dev jest

In a GitHub Action, run tests and generate a coverage report:
npx jest --coverage

After tests run, this will upload your coverage report to Codecov:

- name: Upload coverage reports to Codecov
    uses: codecov/codecov-action@v5
    with:
      token: ${{ secrets.CODECOV_TOKEN }}
      slug: WordPress/two-factor

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