Skip to content

Commit

Permalink
Integration tests: Implement some cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
acicovic committed Jan 21, 2025
1 parent 3eb17dd commit fc5c365
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions tests/Integration/CallUpdateMetadataEndpointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use Parsely\Parsely;
use Parsely\Tests\Integration\TestCase;
use WP_Post;

/**
* Integration Tests for calls to Parse.ly's Update Metadata Endpoint.
Expand Down Expand Up @@ -228,6 +229,8 @@ public function test_endpoint_calls_work_as_expected_with_custom_post_types(): v
);

self::assertTrue( self::$parsely->call_update_metadata_endpoint( $post_id ) );

unregister_post_type( 'test_cpt' );
}

/**
Expand Down Expand Up @@ -301,19 +304,34 @@ public function test_endpoint_calls_work_as_expected_with_custom_post_statuses()

self::assertFalse( self::$parsely->call_update_metadata_endpoint( $post_id ) );

// Add the "active" status to the list of trackable statuses.
add_filter(
'wp_parsely_trackable_statuses',
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter
function ( $statuses, $post ) {
$statuses[] = 'active';

return $statuses;
},
array( $this, 'add_active_status_to_trackable_post_statuses' ),
10,
2
);

self::assertTrue( self::$parsely->call_update_metadata_endpoint( $post_id ) );

remove_filter(
'wp_parsely_trackable_statuses',
array( $this, 'add_active_status_to_trackable_post_statuses' ),
10
);
}

/**
* Adds an "active" post status to the array of trackable post statuses.
*
* @since 3.18.0
*
* @param array<string> $statuses The array of trackable post statuses.
* @param WP_Post|int|null $post The post being checked.
* @return array<string> The updated array of trackable post statuses.
*/
public function add_active_status_to_trackable_post_statuses( array $statuses, $post ): array {
$statuses[] = 'active';

return $statuses;
}
}

0 comments on commit fc5c365

Please sign in to comment.