Add code coverage report

This commit is contained in:
Ian Dunn 2022-09-13 11:34:51 -07:00
parent 0964167f12
commit 0e88966246
No known key found for this signature in database
GPG key ID: 99B971B50343CBCB
8 changed files with 111 additions and 367 deletions

View file

@ -24,6 +24,8 @@ add_shortcode( '5ftf_my_pledges', __NAMESPACE__ . '\render_my_pledges' );
/**
* Register the post type(s).
*
* @codeCoverageIgnore
*
* @return void
*/
function register_custom_post_type() {
@ -85,6 +87,8 @@ function register_custom_post_type() {
* wouldn't be scheduled.
*
* @see https://dotorg.trac.wordpress.org/changeset/15351/
*
* @codeCoverageIgnore
*/
function schedule_cron_jobs() {
if ( ! wp_next_scheduled( 'notify_inactive_contributors' ) ) {
@ -95,6 +99,8 @@ function schedule_cron_jobs() {
/**
* Add columns to the Contributors list table.
*
* @codeCoverageIgnore
*
* @param array $columns
*
* @return array
@ -113,6 +119,8 @@ function add_list_table_columns( $columns ) {
/**
* Render content in the custom columns added to the Contributors list table.
*
* @codeCoverageIgnore
*
* @param string $column
* @param int $post_id
*
@ -392,6 +400,8 @@ function get_contributor_user_ids( $contributor_posts ) {
/**
* Only show the My Pledges menu to users who are logged in.
*
* @codeCoverageIgnore
*
* @param array $menu_items
*
* @return array
@ -413,6 +423,8 @@ function hide_my_pledges_when_logged_out( $menu_items ) {
/**
* Render the My Pledges shortcode.
*
* @codeCoverageIgnore
*
* @return string
*/
function render_my_pledges() {
@ -586,6 +598,8 @@ function parse_contributors( $contributors, $pledge_id = null ) {
/**
* Send an email to inactive contributors.
*
* @codeCoverageIgnore
*/
function notify_inactive_contributors() : void {
$contributors = get_inactive_contributor_batch();

View file

@ -80,7 +80,7 @@ class Test_Auth extends WP_UnitTestCase {
}
/**
* @covers ::is_valid_authentication_token
* @covers WordPressDotOrg\FiveForTheFuture\Auth\is_valid_authentication_token
*/
public function test_valid_token_accepted() {
$verified = is_valid_authentication_token( self::$pledge->ID, self::$action, self::$token['value'] );
@ -88,7 +88,7 @@ class Test_Auth extends WP_UnitTestCase {
}
/**
* @covers ::is_valid_authentication_token
* @covers WordPressDotOrg\FiveForTheFuture\Auth\is_valid_authentication_token
* @dataProvider data_invalid_token_provider
*/
public function test_invalid_tokens_are_rejected( $token_to_validate ) {
@ -107,7 +107,7 @@ class Test_Auth extends WP_UnitTestCase {
* Note that data providers can't access fixtures.
* See https://phpunit.readthedocs.io/en/7.4/writing-tests-for-phpunit.html#data-providers.
*
* @covers ::is_valid_authentication_token
* @covers WordPressDotOrg\FiveForTheFuture\Auth\is_valid_authentication_token
*/
public function data_invalid_token_provider() {
return array(
@ -119,7 +119,7 @@ class Test_Auth extends WP_UnitTestCase {
}
/**
* @covers ::is_valid_authentication_token
* @covers WordPressDotOrg\FiveForTheFuture\Auth\is_valid_authentication_token
*/
public function test_expired_tokens_are_rejected() {
$expired_token = self::$token;
@ -137,7 +137,7 @@ class Test_Auth extends WP_UnitTestCase {
}
/**
* @covers ::is_valid_authentication_token
* @covers WordPressDotOrg\FiveForTheFuture\Auth\is_valid_authentication_token
*/
public function test_used_tokens_are_rejected() {
// The token should be deleted once it's used/verified for the first time.
@ -149,7 +149,7 @@ class Test_Auth extends WP_UnitTestCase {
}
/**
* @covers ::is_valid_authentication_token
* @covers WordPressDotOrg\FiveForTheFuture\Auth\is_valid_authentication_token
*/
public function test_valid_tokens_are_rejected_for_other_actions() {
// Generate new token on pledge.
@ -167,7 +167,7 @@ class Test_Auth extends WP_UnitTestCase {
}
/**
* @covers ::is_valid_authentication_token
* @covers WordPressDotOrg\FiveForTheFuture\Auth\is_valid_authentication_token
*/
public function test_valid_tokens_are_rejected_for_other_pledges() {
$new_pledge_id = self::factory()->post->create( array(
@ -190,7 +190,7 @@ class Test_Auth extends WP_UnitTestCase {
}
/**
* @covers ::is_valid_authentication_token
* @covers WordPressDotOrg\FiveForTheFuture\Auth\is_valid_authentication_token
*/
public function test_reusable_token_is_reusable() {
$action = 'manage_pledge';
@ -207,7 +207,7 @@ class Test_Auth extends WP_UnitTestCase {
}
/**
* @covers ::is_valid_authentication_token
* @covers WordPressDotOrg\FiveForTheFuture\Auth\is_valid_authentication_token
*/
public function test_expired_reusable_tokens_are_rejected() {
$action = 'manage_pledge';
@ -222,7 +222,7 @@ class Test_Auth extends WP_UnitTestCase {
}
/**
* @covers ::can_manage_pledge
* @covers WordPressDotOrg\FiveForTheFuture\Auth\can_manage_pledge
*/
public function test_user_with_token_can_manage_pledge() {
$action = 'manage_pledge';
@ -233,7 +233,7 @@ class Test_Auth extends WP_UnitTestCase {
}
/**
* @covers ::can_manage_pledge
* @covers WordPressDotOrg\FiveForTheFuture\Auth\can_manage_pledge
*/
public function test_user_without_token_cant_manage_pledge() {
$result = can_manage_pledge( self::$pledge->ID, '' );
@ -241,7 +241,7 @@ class Test_Auth extends WP_UnitTestCase {
}
/**
* @covers ::can_manage_pledge
* @covers WordPressDotOrg\FiveForTheFuture\Auth\can_manage_pledge
*/
public function test_logged_in_admin_can_manage_pledge() {
$user = self::factory()->user->create(
@ -256,7 +256,7 @@ class Test_Auth extends WP_UnitTestCase {
}
/**
* @covers ::can_manage_pledge
* @covers WordPressDotOrg\FiveForTheFuture\Auth\can_manage_pledge
*/
public function test_logged_in_subscriber_cant_manage_pledge() {
$user = self::factory()->user->create(

View file

@ -49,8 +49,11 @@ class Test_Contributor extends WP_UnitTestCase {
}
/**
* @covers ::remove_pledge_contributors
* @covers ::remove_contributors
* @covers WordPressDotOrg\FiveForTheFuture\Contributor\remove_pledge_contributors
* @covers WordPressDotOrg\FiveForTheFuture\Contributor\remove_contributor
* @covers WordPressDotOrg\FiveForTheFuture\Contributor\add_pledge_contributors
* @covers WordPressDotOrg\FiveForTheFuture\XProfile\get_contributor_user_data
* @covers WordPressDotOrg\FiveForTheFuture\Pledge\deactivate
*/
public function test_data_reset_once_no_active_sponsors() : void {
// Setup scenario where Jane is sponsored by two companies.
@ -113,8 +116,11 @@ class Test_Contributor extends WP_UnitTestCase {
}
/**
* @covers ::remove_pledge_contributors
* @covers ::remove_contributors
* @covers WordPressDotOrg\FiveForTheFuture\Contributor\remove_pledge_contributors
* @covers WordPressDotOrg\FiveForTheFuture\Contributor\remove_contributor
* @covers WordPressDotOrg\FiveForTheFuture\Contributor\add_pledge_contributors
* @covers WordPressDotOrg\FiveForTheFuture\XProfile\get_contributor_user_data
* @covers WordPressDotOrg\FiveForTheFuture\Pledge\deactivate
*/
public function test_data_not_reset_when_unconfirmed_sponsor() : void {
// Setup scenario where Jane was invited to join a company but didn't respond.
@ -153,7 +159,9 @@ class Test_Contributor extends WP_UnitTestCase {
}
/**
* @covers ::remove_contributors
* @covers WordPressDotOrg\FiveForTheFuture\Contributor\remove_contributor
* @covers WordPressDotOrg\FiveForTheFuture\Contributor\add_pledge_contributors
* @covers WordPressDotOrg\FiveForTheFuture\XProfile\get_contributor_user_data
*/
public function test_data_reset_when_single_contributor_removed_from_pledge() : void {
// Setup scenario where Jane and Ashish are sponsored by a company.
@ -206,7 +214,7 @@ class Test_Contributor extends WP_UnitTestCase {
}
/**
* @covers ::prune_unnotifiable_users
* @covers WordPressDotOrg\FiveForTheFuture\Contributor\prune_unnotifiable_users
*/
public function test_prune_unnotifiable_users() {
$contributors = array(

View file

@ -43,7 +43,7 @@ class Test_Stats extends WP_UnitTestCase {
}
/**
* @covers ::get_snapshot_data
* @covers WordPressDotOrg\FiveForTheFuture\Stats\get_snapshot_data
*/
public function test_get_snapshot() : void {
// Setup 2 company-sponsored contributors.