@@ -74,7 +74,6 @@ static function ( array $properties ) use ( $property_name ): array {
74
74
*
75
75
* @covers OD_REST_URL_Metrics_Store_Endpoint::get_registration_args
76
76
* @covers OD_REST_URL_Metrics_Store_Endpoint::handle_rest_request
77
- * @covers OD_REST_URL_Metrics_Store_Endpoint::trigger_page_cache_invalidation
78
77
* @covers OD_Strict_URL_Metric::set_additional_properties_to_false
79
78
* @covers OD_URL_Metric_Store_Request_Context::__construct
80
79
* @covers OD_URL_Metric_Store_Request_Context::__get
@@ -144,7 +143,7 @@ function ( OD_URL_Metric_Store_Request_Context $context ) use ( &$stored_context
144
143
145
144
$ this ->assertInstanceOf ( OD_URL_Metric_Store_Request_Context::class, $ stored_context );
146
145
147
- // Now check that trigger_page_cache_invalidation () cleaned caches as expected.
146
+ // Now check that od_handle_trigger_page_cache_invalidation () cleaned caches as expected.
148
147
$ this ->assertSame ( $ url_metrics [0 ]->jsonSerialize (), $ stored_context ->url_metric ->jsonSerialize () );
149
148
if ( isset ( $ valid_params ['cache_purge_post_id ' ] ) ) {
150
149
$ cache_purge_post_id = $ stored_context ->request ->get_param ( 'cache_purge_post_id ' );
@@ -784,80 +783,6 @@ static function () use ( $breakpoint_width ): array {
784
783
$ this ->assertSame ( 403 , $ response ->get_status (), 'Response: ' . wp_json_encode ( $ response ->get_data () ) );
785
784
}
786
785
787
- /**
788
- * Test trigger_page_cache_invalidation().
789
- *
790
- * @covers OD_REST_URL_Metrics_Store_Endpoint::trigger_page_cache_invalidation
791
- */
792
- public function test_trigger_page_cache_invalidation (): void {
793
- $ cache_purge_post_id = self ::factory ()->post ->create ();
794
-
795
- $ all_hook_callback_args = array ();
796
- add_action (
797
- 'all ' ,
798
- static function ( string $ hook , ...$ args ) use ( &$ all_hook_callback_args ): void {
799
- $ all_hook_callback_args [ $ hook ][] = $ args ;
800
- },
801
- 10 ,
802
- PHP_INT_MAX
803
- );
804
-
805
- $ url_metric_endpoint = new OD_REST_URL_Metrics_Store_Endpoint ();
806
- $ url_metric_endpoint ->trigger_page_cache_invalidation ( $ cache_purge_post_id );
807
-
808
- $ this ->assertArrayHasKey ( 'clean_post_cache ' , $ all_hook_callback_args );
809
- $ found = false ;
810
- foreach ( $ all_hook_callback_args ['clean_post_cache ' ] as $ args ) {
811
- if ( $ args [0 ] === $ cache_purge_post_id ) {
812
- $ this ->assertInstanceOf ( WP_Post::class, $ args [1 ] );
813
- $ this ->assertSame ( $ cache_purge_post_id , $ args [1 ]->ID );
814
- $ found = true ;
815
- }
816
- }
817
- $ this ->assertTrue ( $ found , 'Expected clean_post_cache to have been fired for the post queried object. ' );
818
-
819
- $ this ->assertArrayHasKey ( 'transition_post_status ' , $ all_hook_callback_args );
820
- $ found = false ;
821
- foreach ( $ all_hook_callback_args ['transition_post_status ' ] as $ args ) {
822
- $ this ->assertInstanceOf ( WP_Post::class, $ args [2 ] );
823
- if ( $ args [2 ]->ID === $ cache_purge_post_id ) {
824
- $ this ->assertSame ( $ args [2 ]->post_status , $ args [0 ] );
825
- $ this ->assertSame ( $ args [2 ]->post_status , $ args [1 ] );
826
- $ found = true ;
827
- }
828
- }
829
- $ this ->assertTrue ( $ found , 'Expected transition_post_status to have been fired for the post queried object. ' );
830
-
831
- $ this ->assertArrayHasKey ( 'save_post ' , $ all_hook_callback_args );
832
- $ found = false ;
833
- foreach ( $ all_hook_callback_args ['save_post ' ] as $ args ) {
834
- if ( $ args [0 ] === $ cache_purge_post_id ) {
835
- $ this ->assertInstanceOf ( WP_Post::class, $ args [1 ] );
836
- $ this ->assertSame ( $ cache_purge_post_id , $ args [1 ]->ID );
837
- $ found = true ;
838
- }
839
- }
840
- $ this ->assertTrue ( $ found , 'Expected save_post to have been fired for the post queried object. ' );
841
- }
842
-
843
- /**
844
- * Test trigger_page_cache_invalidation() for an invalid post.
845
- *
846
- * @covers OD_REST_URL_Metrics_Store_Endpoint::trigger_page_cache_invalidation
847
- * @covers ::od_trigger_page_cache_invalidation_callback
848
- */
849
- public function test_trigger_page_cache_invalidation_invalid_post_id (): void {
850
- wp_delete_post ( 1 , true );
851
- $ before_clean_post_cache_count = did_action ( 'clean_post_cache ' );
852
- $ before_transition_post_status_count = did_action ( 'transition_post_status ' );
853
- $ before_save_post_count = did_action ( 'save_post ' );
854
- $ url_metric_endpoint = new OD_REST_URL_Metrics_Store_Endpoint ();
855
- $ url_metric_endpoint ->trigger_page_cache_invalidation ( 1 );
856
- $ this ->assertSame ( $ before_clean_post_cache_count , did_action ( 'clean_post_cache ' ) );
857
- $ this ->assertSame ( $ before_transition_post_status_count , did_action ( 'transition_post_status ' ) );
858
- $ this ->assertSame ( $ before_save_post_count , did_action ( 'save_post ' ) );
859
- }
860
-
861
786
/**
862
787
* Populate URL Metrics.
863
788
*
0 commit comments