77use WP_Error ;
88
99class Event_Tests extends \WP_UnitTestCase {
10- function setUp (): void {
10+ public function setUp (): void {
1111 parent ::setUp ();
1212 Utils::clear_cron_table ();
1313 }
1414
15- function tearDown (): void {
15+ public function tearDown (): void {
1616 Utils::clear_cron_table ();
1717 parent ::tearDown ();
1818 }
1919
20- function test_run () {
20+ public function test_run () {
2121 $ called = 0 ;
2222 add_action ( 'test_run_event_action ' , function () use ( &$ called ) {
2323 $ called ++;
@@ -30,7 +30,7 @@ function test_run() {
3030 $ this ->assertEquals ( 1 , $ called , 'event callback was triggered once ' );
3131 }
3232
33- function test_complete () {
33+ public function test_complete () {
3434 // Mock up an event, but try to complete it before saving.
3535 $ event = new Event ();
3636 $ event ->set_action ( 'test_complete ' );
@@ -47,7 +47,7 @@ function test_complete() {
4747 $ this ->assertNotEquals ( Event::create_instance_hash ( [ 'test ' , 'args ' ] ), $ event ->get_instance (), 'the instance was updated/randomized ' );
4848 }
4949
50- function test_reschedule () {
50+ public function test_reschedule () {
5151 // Try to reschedule a non-recurring event.
5252 $ event = new Event ();
5353 $ event ->set_action ( 'test_reschedule ' );
@@ -70,10 +70,10 @@ function test_reschedule() {
7070 $ result = $ event ->reschedule ();
7171 $ this ->assertTrue ( $ result , 'event was successfully rescheduled ' );
7272 $ this ->assertEquals ( Events_Store::STATUS_PENDING , $ event ->get_status () );
73- $ this ->assertEquals ( time () + HOUR_IN_SECONDS , $ event ->get_timestamp () );
73+ $ this ->assertEqualsWithDelta ( time () + HOUR_IN_SECONDS , $ event ->get_timestamp (), 1 );
7474 }
7575
76- function test_exists () {
76+ public function test_exists () {
7777 $ event = new Event ();
7878 $ event ->set_action ( 'test_exists ' );
7979 $ event ->set_timestamp ( time () );
@@ -83,15 +83,15 @@ function test_exists() {
8383 $ this ->assertTrue ( $ event ->exists () );
8484 }
8585
86- function test_create_instance_hash () {
86+ public function test_create_instance_hash () {
8787 $ empty_args = Event::create_instance_hash ( [] );
8888 $ this ->assertEquals ( md5 ( serialize ( [] ) ), $ empty_args );
8989
9090 $ has_args = Event::create_instance_hash ( [ 'some ' , 'data ' ] );
9191 $ this ->assertEquals ( md5 ( serialize ( [ 'some ' , 'data ' ] ) ), $ has_args );
9292 }
9393
94- function test_get_wp_event_format () {
94+ public function test_get_wp_event_format () {
9595 $ event = new Event ();
9696 $ event ->set_action ( 'test_get_wp_event_format ' );
9797 $ event ->set_timestamp ( 123 );
@@ -117,7 +117,7 @@ function test_get_wp_event_format() {
117117 ], $ event ->get_wp_event_format () );
118118 }
119119
120- function test_get () {
120+ public function test_get () {
121121 $ test_event = new Event ();
122122 $ test_event ->set_action ( 'test_get_action ' );
123123 $ test_event ->set_timestamp ( 1637447875 );
@@ -132,7 +132,7 @@ function test_get() {
132132 $ this ->assertNull ( $ event , 'could not find event by ID ' );
133133 }
134134
135- function test_find () {
135+ public function test_find () {
136136 $ test_event = new Event ();
137137 $ test_event ->set_action ( 'test_find_action ' );
138138 $ test_event ->set_timestamp ( 1637447876 );
@@ -147,7 +147,7 @@ function test_find() {
147147 $ this ->assertNull ( $ event , 'could not find event by args ' );
148148 }
149149
150- function test_validate_props () {
150+ public function test_validate_props () {
151151 // Invalid status.
152152 $ this ->run_event_save_test ( [
153153 'creation ' => [
@@ -218,7 +218,7 @@ function test_validate_props() {
218218 }
219219
220220 // Run through various flows of event saving.
221- function test_event_save () {
221+ public function test_event_save () {
222222 // Create event w/ bare information to test the defaults.
223223 // Then update the timestamp.
224224 $ this ->run_event_save_test ( [
0 commit comments