Skip to content

Commit aaa0e99

Browse files
Apply suggestions from code review
Co-authored-by: Weston Ruter <westonruter@gmail.com>
1 parent 5d44692 commit aaa0e99

1 file changed

Lines changed: 22 additions & 22 deletions

File tree

tests/phpunit/tests/rest-api/rest-sync-server.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ public function test_sync_rooms_are_isolated() {
767767
/**
768768
* @ticket 64696
769769
*/
770-
public function test_sync_empty_room_cursor_is_zero() {
770+
public function test_sync_empty_room_cursor_is_zero(): void {
771771
wp_set_current_user( self::$editor_id );
772772

773773
$response = $this->dispatch_sync( array( $this->build_room( $this->get_post_room() ) ) );
@@ -779,7 +779,7 @@ public function test_sync_empty_room_cursor_is_zero() {
779779
/**
780780
* @ticket 64696
781781
*/
782-
public function test_sync_cursor_advances_monotonically() {
782+
public function test_sync_cursor_advances_monotonically(): void {
783783
wp_set_current_user( self::$editor_id );
784784

785785
$room = $this->get_post_room();
@@ -810,7 +810,7 @@ public function test_sync_cursor_advances_monotonically() {
810810
/**
811811
* @ticket 64696
812812
*/
813-
public function test_sync_cursor_prevents_re_delivery() {
813+
public function test_sync_cursor_prevents_re_delivery(): void {
814814
wp_set_current_user( self::$editor_id );
815815

816816
$room = $this->get_post_room();
@@ -855,7 +855,7 @@ public function test_sync_cursor_prevents_re_delivery() {
855855
/**
856856
* @ticket 64696
857857
*/
858-
public function test_sync_operations_do_not_affect_posts_last_changed() {
858+
public function test_sync_operations_do_not_affect_posts_last_changed(): void {
859859
wp_set_current_user( self::$editor_id );
860860

861861
// Prime the posts last changed cache.
@@ -892,7 +892,7 @@ public function test_sync_operations_do_not_affect_posts_last_changed() {
892892
/**
893893
* @ticket 64696
894894
*/
895-
public function test_sync_compaction_does_not_lose_concurrent_updates() {
895+
public function test_sync_compaction_does_not_lose_concurrent_updates(): void {
896896
wp_set_current_user( self::$editor_id );
897897

898898
$room = $this->get_post_room();
@@ -958,7 +958,7 @@ public function test_sync_compaction_does_not_lose_concurrent_updates() {
958958
/**
959959
* @ticket 64696
960960
*/
961-
public function test_sync_compaction_reduces_total_updates() {
961+
public function test_sync_compaction_reduces_total_updates(): void {
962962
wp_set_current_user( self::$editor_id );
963963

964964
$room = $this->get_post_room();
@@ -1009,13 +1009,13 @@ public function test_sync_compaction_reduces_total_updates() {
10091009
/**
10101010
* @ticket 64696
10111011
*/
1012-
public function test_sync_storage_filter_is_applied() {
1013-
$filter_called = false;
1012+
public function test_sync_storage_filter_is_applied(): void {
1013+
$filtered_storage = null;
10141014

10151015
add_filter(
10161016
'wp_sync_storage',
1017-
static function ( $storage ) use ( &$filter_called ) {
1018-
$filter_called = true;
1017+
static function ( WP_Sync_Storage $storage ) use ( &$filtered_storage ): WP_Sync_Storage {
1018+
$filtered_storage = $storage;
10191019
return $storage;
10201020
}
10211021
);
@@ -1024,7 +1024,7 @@ static function ( $storage ) use ( &$filter_called ) {
10241024
$server = rest_get_server();
10251025
do_action( 'rest_api_init', $server );
10261026

1027-
$this->assertTrue( $filter_called, 'The wp_sync_storage filter should be applied during route registration.' );
1027+
$this->assertInstanceOf( WP_Sync_Storage::class, $filtered_storage, 'The wp_sync_storage filter should be applied during route registration.' );
10281028
}
10291029

10301030
/*
@@ -1034,10 +1034,10 @@ static function ( $storage ) use ( &$filter_called ) {
10341034
/**
10351035
* Inserts a row directly into the sync_updates table with a given age.
10361036
*
1037-
* @param int $age_in_seconds How old the row should be.
1038-
* @param string $label A label stored in the update_value for identification.
1037+
* @param positive-int $age_in_seconds How old the row should be.
1038+
* @param string $label A label stored in the update_value for identification.
10391039
*/
1040-
private function insert_sync_row( $age_in_seconds, $label = 'test' ) {
1040+
private function insert_sync_row( int $age_in_seconds, string $label = 'test' ): void {
10411041
global $wpdb;
10421042

10431043
$wpdb->insert(
@@ -1059,9 +1059,9 @@ private function insert_sync_row( $age_in_seconds, $label = 'test' ) {
10591059
/**
10601060
* Returns the number of rows in the sync_updates table.
10611061
*
1062-
* @return int Row count.
1062+
* @return positive-int Row count.
10631063
*/
1064-
private function get_sync_row_count() {
1064+
private function get_sync_row_count(): int {
10651065
global $wpdb;
10661066

10671067
return (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->sync_updates}" );
@@ -1070,7 +1070,7 @@ private function get_sync_row_count() {
10701070
/**
10711071
* @ticket 64696
10721072
*/
1073-
public function test_cron_cleanup_deletes_old_rows() {
1073+
public function test_cron_cleanup_deletes_old_rows(): void {
10741074
$this->insert_sync_row( 8 * DAY_IN_SECONDS );
10751075

10761076
$this->assertSame( 1, $this->get_sync_row_count() );
@@ -1083,7 +1083,7 @@ public function test_cron_cleanup_deletes_old_rows() {
10831083
/**
10841084
* @ticket 64696
10851085
*/
1086-
public function test_cron_cleanup_preserves_recent_rows() {
1086+
public function test_cron_cleanup_preserves_recent_rows(): void {
10871087
$this->insert_sync_row( DAY_IN_SECONDS );
10881088

10891089
wp_delete_old_sync_updates();
@@ -1094,7 +1094,7 @@ public function test_cron_cleanup_preserves_recent_rows() {
10941094
/**
10951095
* @ticket 64696
10961096
*/
1097-
public function test_cron_cleanup_boundary_at_exactly_seven_days() {
1097+
public function test_cron_cleanup_boundary_at_exactly_seven_days(): void {
10981098
$this->insert_sync_row( WEEK_IN_SECONDS + 1, 'expired' );
10991099
$this->insert_sync_row( WEEK_IN_SECONDS - 1, 'just-inside' );
11001100

@@ -1110,7 +1110,7 @@ public function test_cron_cleanup_boundary_at_exactly_seven_days() {
11101110
/**
11111111
* @ticket 64696
11121112
*/
1113-
public function test_cron_cleanup_selectively_deletes_mixed_rows() {
1113+
public function test_cron_cleanup_selectively_deletes_mixed_rows(): void {
11141114
// 3 expired rows.
11151115
$this->insert_sync_row( 10 * DAY_IN_SECONDS );
11161116
$this->insert_sync_row( 10 * DAY_IN_SECONDS );
@@ -1130,7 +1130,7 @@ public function test_cron_cleanup_selectively_deletes_mixed_rows() {
11301130
/**
11311131
* @ticket 64696
11321132
*/
1133-
public function test_cron_cleanup_hook_is_registered() {
1133+
public function test_cron_cleanup_hook_is_registered(): void {
11341134
$this->assertSame(
11351135
10,
11361136
has_action( 'wp_delete_old_sync_updates', 'wp_delete_old_sync_updates' ),
@@ -1145,7 +1145,7 @@ public function test_cron_cleanup_hook_is_registered() {
11451145
/**
11461146
* @ticket 64696
11471147
*/
1148-
public function test_sync_routes_not_registered_when_db_version_is_old() {
1148+
public function test_sync_routes_not_registered_when_db_version_is_old(): void {
11491149
update_option( 'db_version', 61697 );
11501150

11511151
// Reset the global REST server so rest_get_server() builds a fresh instance.

0 commit comments

Comments
 (0)