Completed
Pull Request — develop (#1630)
by
unknown
01:13
created
tests/phpunit/procedural_api/wc_get_scheduled_actions_Test.php 2 patches
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -4,124 +4,124 @@
 block discarded – undo
4 4
  * Class as_get_scheduled_actions_Test
5 5
  */
6 6
 class as_get_scheduled_actions_Test extends ActionScheduler_UnitTestCase {
7
-	private $hooks  = array();
8
-	private $args   = array();
9
-	private $groups = array();
7
+    private $hooks  = array();
8
+    private $args   = array();
9
+    private $groups = array();
10 10
 
11
-	public function setUp() {
12
-		parent::setUp();
11
+    public function setUp() {
12
+        parent::setUp();
13 13
 
14
-		$store = ActionScheduler::store();
14
+        $store = ActionScheduler::store();
15 15
 
16
-		for ( $i = 0; $i < 10; $i++ ) {
17
-			$this->hooks[ $i ]  = md5( rand() );
18
-			$this->args[ $i ]   = md5( rand() );
19
-			$this->groups[ $i ] = md5( rand() );
20
-		}
16
+        for ( $i = 0; $i < 10; $i++ ) {
17
+            $this->hooks[ $i ]  = md5( rand() );
18
+            $this->args[ $i ]   = md5( rand() );
19
+            $this->groups[ $i ] = md5( rand() );
20
+        }
21 21
 
22
-		for ( $i = 0; $i < 10; $i++ ) {
23
-			for ( $j = 0; $j < 10; $j++ ) {
24
-				$schedule = new ActionScheduler_SimpleSchedule( as_get_datetime_object( $j - 3 . 'days' ) );
25
-				$group    = $this->groups[ ( $i + $j ) % 10 ];
26
-				$action   = new ActionScheduler_Action( $this->hooks[ $i ], array( $this->args[ $j ] ), $schedule, $group );
27
-				$store->save_action( $action );
28
-			}
29
-		}
30
-	}
22
+        for ( $i = 0; $i < 10; $i++ ) {
23
+            for ( $j = 0; $j < 10; $j++ ) {
24
+                $schedule = new ActionScheduler_SimpleSchedule( as_get_datetime_object( $j - 3 . 'days' ) );
25
+                $group    = $this->groups[ ( $i + $j ) % 10 ];
26
+                $action   = new ActionScheduler_Action( $this->hooks[ $i ], array( $this->args[ $j ] ), $schedule, $group );
27
+                $store->save_action( $action );
28
+            }
29
+        }
30
+    }
31 31
 
32
-	public function test_date_queries() {
33
-		$actions = as_get_scheduled_actions(
34
-			array(
35
-				'date'     => as_get_datetime_object( gmdate( 'Y-m-d 00:00:00' ) ),
36
-				'per_page' => -1,
37
-			),
38
-			'ids'
39
-		);
40
-		$this->assertCount( 30, $actions );
32
+    public function test_date_queries() {
33
+        $actions = as_get_scheduled_actions(
34
+            array(
35
+                'date'     => as_get_datetime_object( gmdate( 'Y-m-d 00:00:00' ) ),
36
+                'per_page' => -1,
37
+            ),
38
+            'ids'
39
+        );
40
+        $this->assertCount( 30, $actions );
41 41
 
42
-		$actions = as_get_scheduled_actions(
43
-			array(
44
-				'date'         => as_get_datetime_object( gmdate( 'Y-m-d 00:00:00' ) ),
45
-				'date_compare' => '>=',
46
-				'per_page'     => -1,
47
-			),
48
-			'ids'
49
-		);
50
-		$this->assertCount( 70, $actions );
51
-	}
42
+        $actions = as_get_scheduled_actions(
43
+            array(
44
+                'date'         => as_get_datetime_object( gmdate( 'Y-m-d 00:00:00' ) ),
45
+                'date_compare' => '>=',
46
+                'per_page'     => -1,
47
+            ),
48
+            'ids'
49
+        );
50
+        $this->assertCount( 70, $actions );
51
+    }
52 52
 
53
-	public function test_hook_queries() {
54
-		$actions = as_get_scheduled_actions(
55
-			array(
56
-				'hook'     => $this->hooks[2],
57
-				'per_page' => -1,
58
-			),
59
-			'ids'
60
-		);
61
-		$this->assertCount( 10, $actions );
53
+    public function test_hook_queries() {
54
+        $actions = as_get_scheduled_actions(
55
+            array(
56
+                'hook'     => $this->hooks[2],
57
+                'per_page' => -1,
58
+            ),
59
+            'ids'
60
+        );
61
+        $this->assertCount( 10, $actions );
62 62
 
63
-		$actions = as_get_scheduled_actions(
64
-			array(
65
-				'hook'     => $this->hooks[2],
66
-				'date'     => as_get_datetime_object( gmdate( 'Y-m-d 00:00:00' ) ),
67
-				'per_page' => -1,
68
-			),
69
-			'ids'
70
-		);
71
-		$this->assertCount( 3, $actions );
72
-	}
63
+        $actions = as_get_scheduled_actions(
64
+            array(
65
+                'hook'     => $this->hooks[2],
66
+                'date'     => as_get_datetime_object( gmdate( 'Y-m-d 00:00:00' ) ),
67
+                'per_page' => -1,
68
+            ),
69
+            'ids'
70
+        );
71
+        $this->assertCount( 3, $actions );
72
+    }
73 73
 
74
-	public function test_args_queries() {
75
-		$actions = as_get_scheduled_actions(
76
-			array(
77
-				'args'     => array( $this->args[5] ),
78
-				'per_page' => -1,
79
-			),
80
-			'ids'
81
-		);
82
-		$this->assertCount( 10, $actions );
74
+    public function test_args_queries() {
75
+        $actions = as_get_scheduled_actions(
76
+            array(
77
+                'args'     => array( $this->args[5] ),
78
+                'per_page' => -1,
79
+            ),
80
+            'ids'
81
+        );
82
+        $this->assertCount( 10, $actions );
83 83
 
84
-		$actions = as_get_scheduled_actions(
85
-			array(
86
-				'args'     => array( $this->args[5] ),
87
-				'hook'     => $this->hooks[3],
88
-				'per_page' => -1,
89
-			),
90
-			'ids'
91
-		);
92
-		$this->assertCount( 1, $actions );
84
+        $actions = as_get_scheduled_actions(
85
+            array(
86
+                'args'     => array( $this->args[5] ),
87
+                'hook'     => $this->hooks[3],
88
+                'per_page' => -1,
89
+            ),
90
+            'ids'
91
+        );
92
+        $this->assertCount( 1, $actions );
93 93
 
94
-		$actions = as_get_scheduled_actions(
95
-			array(
96
-				'args'     => array( $this->args[5] ),
97
-				'hook'     => $this->hooks[3],
98
-				'date'     => as_get_datetime_object( gmdate( 'Y-m-d 00:00:00' ) ),
99
-				'per_page' => -1,
100
-			),
101
-			'ids'
102
-		);
103
-		$this->assertCount( 0, $actions );
104
-	}
94
+        $actions = as_get_scheduled_actions(
95
+            array(
96
+                'args'     => array( $this->args[5] ),
97
+                'hook'     => $this->hooks[3],
98
+                'date'     => as_get_datetime_object( gmdate( 'Y-m-d 00:00:00' ) ),
99
+                'per_page' => -1,
100
+            ),
101
+            'ids'
102
+        );
103
+        $this->assertCount( 0, $actions );
104
+    }
105 105
 
106
-	public function test_group_queries() {
107
-		$actions = as_get_scheduled_actions(
108
-			array(
109
-				'group'    => $this->groups[1],
110
-				'per_page' => -1,
111
-			),
112
-			'ids'
113
-		);
114
-		$this->assertCount( 10, $actions );
106
+    public function test_group_queries() {
107
+        $actions = as_get_scheduled_actions(
108
+            array(
109
+                'group'    => $this->groups[1],
110
+                'per_page' => -1,
111
+            ),
112
+            'ids'
113
+        );
114
+        $this->assertCount( 10, $actions );
115 115
 
116
-		$actions = as_get_scheduled_actions(
117
-			array(
118
-				'group'    => $this->groups[1],
119
-				'hook'     => $this->hooks[9],
120
-				'per_page' => -1,
121
-			),
122
-			'ids'
123
-		);
124
-		$this->assertCount( 1, $actions );
125
-	}
116
+        $actions = as_get_scheduled_actions(
117
+            array(
118
+                'group'    => $this->groups[1],
119
+                'hook'     => $this->hooks[9],
120
+                'per_page' => -1,
121
+            ),
122
+            'ids'
123
+        );
124
+        $this->assertCount( 1, $actions );
125
+    }
126 126
 }
127 127
 
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -13,18 +13,18 @@  discard block
 block discarded – undo
13 13
 
14 14
 		$store = ActionScheduler::store();
15 15
 
16
-		for ( $i = 0; $i < 10; $i++ ) {
17
-			$this->hooks[ $i ]  = md5( rand() );
18
-			$this->args[ $i ]   = md5( rand() );
19
-			$this->groups[ $i ] = md5( rand() );
16
+		for ($i = 0; $i < 10; $i++) {
17
+			$this->hooks[$i]  = md5(rand());
18
+			$this->args[$i]   = md5(rand());
19
+			$this->groups[$i] = md5(rand());
20 20
 		}
21 21
 
22
-		for ( $i = 0; $i < 10; $i++ ) {
23
-			for ( $j = 0; $j < 10; $j++ ) {
24
-				$schedule = new ActionScheduler_SimpleSchedule( as_get_datetime_object( $j - 3 . 'days' ) );
25
-				$group    = $this->groups[ ( $i + $j ) % 10 ];
26
-				$action   = new ActionScheduler_Action( $this->hooks[ $i ], array( $this->args[ $j ] ), $schedule, $group );
27
-				$store->save_action( $action );
22
+		for ($i = 0; $i < 10; $i++) {
23
+			for ($j = 0; $j < 10; $j++) {
24
+				$schedule = new ActionScheduler_SimpleSchedule(as_get_datetime_object($j - 3.'days'));
25
+				$group    = $this->groups[($i + $j) % 10];
26
+				$action   = new ActionScheduler_Action($this->hooks[$i], array($this->args[$j]), $schedule, $group);
27
+				$store->save_action($action);
28 28
 			}
29 29
 		}
30 30
 	}
@@ -32,22 +32,22 @@  discard block
 block discarded – undo
32 32
 	public function test_date_queries() {
33 33
 		$actions = as_get_scheduled_actions(
34 34
 			array(
35
-				'date'     => as_get_datetime_object( gmdate( 'Y-m-d 00:00:00' ) ),
35
+				'date'     => as_get_datetime_object(gmdate('Y-m-d 00:00:00')),
36 36
 				'per_page' => -1,
37 37
 			),
38 38
 			'ids'
39 39
 		);
40
-		$this->assertCount( 30, $actions );
40
+		$this->assertCount(30, $actions);
41 41
 
42 42
 		$actions = as_get_scheduled_actions(
43 43
 			array(
44
-				'date'         => as_get_datetime_object( gmdate( 'Y-m-d 00:00:00' ) ),
44
+				'date'         => as_get_datetime_object(gmdate('Y-m-d 00:00:00')),
45 45
 				'date_compare' => '>=',
46 46
 				'per_page'     => -1,
47 47
 			),
48 48
 			'ids'
49 49
 		);
50
-		$this->assertCount( 70, $actions );
50
+		$this->assertCount(70, $actions);
51 51
 	}
52 52
 
53 53
 	public function test_hook_queries() {
@@ -58,49 +58,49 @@  discard block
 block discarded – undo
58 58
 			),
59 59
 			'ids'
60 60
 		);
61
-		$this->assertCount( 10, $actions );
61
+		$this->assertCount(10, $actions);
62 62
 
63 63
 		$actions = as_get_scheduled_actions(
64 64
 			array(
65 65
 				'hook'     => $this->hooks[2],
66
-				'date'     => as_get_datetime_object( gmdate( 'Y-m-d 00:00:00' ) ),
66
+				'date'     => as_get_datetime_object(gmdate('Y-m-d 00:00:00')),
67 67
 				'per_page' => -1,
68 68
 			),
69 69
 			'ids'
70 70
 		);
71
-		$this->assertCount( 3, $actions );
71
+		$this->assertCount(3, $actions);
72 72
 	}
73 73
 
74 74
 	public function test_args_queries() {
75 75
 		$actions = as_get_scheduled_actions(
76 76
 			array(
77
-				'args'     => array( $this->args[5] ),
77
+				'args'     => array($this->args[5]),
78 78
 				'per_page' => -1,
79 79
 			),
80 80
 			'ids'
81 81
 		);
82
-		$this->assertCount( 10, $actions );
82
+		$this->assertCount(10, $actions);
83 83
 
84 84
 		$actions = as_get_scheduled_actions(
85 85
 			array(
86
-				'args'     => array( $this->args[5] ),
86
+				'args'     => array($this->args[5]),
87 87
 				'hook'     => $this->hooks[3],
88 88
 				'per_page' => -1,
89 89
 			),
90 90
 			'ids'
91 91
 		);
92
-		$this->assertCount( 1, $actions );
92
+		$this->assertCount(1, $actions);
93 93
 
94 94
 		$actions = as_get_scheduled_actions(
95 95
 			array(
96
-				'args'     => array( $this->args[5] ),
96
+				'args'     => array($this->args[5]),
97 97
 				'hook'     => $this->hooks[3],
98
-				'date'     => as_get_datetime_object( gmdate( 'Y-m-d 00:00:00' ) ),
98
+				'date'     => as_get_datetime_object(gmdate('Y-m-d 00:00:00')),
99 99
 				'per_page' => -1,
100 100
 			),
101 101
 			'ids'
102 102
 		);
103
-		$this->assertCount( 0, $actions );
103
+		$this->assertCount(0, $actions);
104 104
 	}
105 105
 
106 106
 	public function test_group_queries() {
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 			),
112 112
 			'ids'
113 113
 		);
114
-		$this->assertCount( 10, $actions );
114
+		$this->assertCount(10, $actions);
115 115
 
116 116
 		$actions = as_get_scheduled_actions(
117 117
 			array(
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 			),
122 122
 			'ids'
123 123
 		);
124
-		$this->assertCount( 1, $actions );
124
+		$this->assertCount(1, $actions);
125 125
 	}
126 126
 }
127 127
 
Please login to merge, or discard this patch.
ext/action-scheduler/tests/phpunit/procedural_api/procedural_api_Test.php 2 patches
Indentation   +312 added lines, -312 removed lines patch added patch discarded remove patch
@@ -5,373 +5,373 @@
 block discarded – undo
5 5
  */
6 6
 class Procedural_API_Test extends ActionScheduler_UnitTestCase {
7 7
 
8
-	// phpcs:disable Squiz.Commenting.FunctionComment.Missing, Squiz.Commenting.FunctionComment.MissingParamTag
9
-	public function test_schedule_action() {
10
-		$time      = time();
11
-		$hook      = md5( rand() );
12
-		$action_id = as_schedule_single_action( $time, $hook );
13
-
14
-		$store  = ActionScheduler::store();
15
-		$action = $store->fetch_action( $action_id );
16
-		$this->assertEquals( $time, $action->get_schedule()->get_date()->getTimestamp() );
17
-		$this->assertEquals( $hook, $action->get_hook() );
18
-	}
19
-
20
-	public function test_recurring_action() {
21
-		$time      = time();
22
-		$hook      = md5( rand() );
23
-		$action_id = as_schedule_recurring_action( $time, HOUR_IN_SECONDS, $hook );
24
-
25
-		$store  = ActionScheduler::store();
26
-		$action = $store->fetch_action( $action_id );
27
-		$this->assertEquals( $time, $action->get_schedule()->get_date()->getTimestamp() );
28
-		$this->assertEquals( $time + HOUR_IN_SECONDS + 2, $action->get_schedule()->get_next( as_get_datetime_object( $time + 2 ) )->getTimestamp() );
29
-		$this->assertEquals( $hook, $action->get_hook() );
30
-	}
31
-
32
-	public function test_cron_schedule() {
33
-		$time      = as_get_datetime_object( '2014-01-01' );
34
-		$hook      = md5( rand() );
35
-		$action_id = as_schedule_cron_action( $time->getTimestamp(), '0 0 10 10 *', $hook );
36
-
37
-		$store         = ActionScheduler::store();
38
-		$action        = $store->fetch_action( $action_id );
39
-		$expected_date = as_get_datetime_object( '2014-10-10' );
40
-		$this->assertEquals( $expected_date->getTimestamp(), $action->get_schedule()->get_date()->getTimestamp() );
41
-		$this->assertEquals( $hook, $action->get_hook() );
42
-
43
-		$expected_date = as_get_datetime_object( '2015-10-10' );
44
-		$this->assertEquals( $expected_date->getTimestamp(), $action->get_schedule()->get_next( as_get_datetime_object( '2015-01-02' ) )->getTimestamp() );
45
-	}
46
-
47
-	public function test_get_next() {
48
-		$time = as_get_datetime_object( 'tomorrow' );
49
-		$hook = md5( rand() );
50
-		as_schedule_recurring_action( $time->getTimestamp(), HOUR_IN_SECONDS, $hook );
51
-
52
-		$next = as_next_scheduled_action( $hook );
53
-
54
-		$this->assertEquals( $time->getTimestamp(), $next );
55
-	}
56
-
57
-	public function test_get_next_async() {
58
-		$hook      = md5( rand() );
59
-		$action_id = as_enqueue_async_action( $hook );
60
-
61
-		$next = as_next_scheduled_action( $hook );
62
-
63
-		$this->assertTrue( $next );
64
-
65
-		$store = ActionScheduler::store();
66
-
67
-		// Completed async actions should still return false.
68
-		$store->mark_complete( $action_id );
69
-		$next = as_next_scheduled_action( $hook );
70
-		$this->assertFalse( $next );
71
-
72
-		// Failed async actions should still return false.
73
-		$store->mark_failure( $action_id );
74
-		$next = as_next_scheduled_action( $hook );
75
-		$this->assertFalse( $next );
76
-
77
-		// Cancelled async actions should still return false.
78
-		$store->cancel_action( $action_id );
79
-		$next = as_next_scheduled_action( $hook );
80
-		$this->assertFalse( $next );
81
-	}
82
-
83
-	public function provider_time_hook_args_group() {
84
-		$time  = time() + 60 * 2;
85
-		$hook  = md5( rand() );
86
-		$args  = array( rand(), rand() );
87
-		$group = 'test_group';
88
-
89
-		return array(
90
-
91
-			// Test with no args or group.
92
-			array(
93
-				'time'  => $time,
94
-				'hook'  => $hook,
95
-				'args'  => array(),
96
-				'group' => '',
97
-			),
98
-
99
-			// Test with args but no group.
100
-			array(
101
-				'time'  => $time,
102
-				'hook'  => $hook,
103
-				'args'  => $args,
104
-				'group' => '',
105
-			),
106
-
107
-			// Test with group but no args.
108
-			array(
109
-				'time'  => $time,
110
-				'hook'  => $hook,
111
-				'args'  => array(),
112
-				'group' => $group,
113
-			),
114
-
115
-			// Test with args & group.
116
-			array(
117
-				'time'  => $time,
118
-				'hook'  => $hook,
119
-				'args'  => $args,
120
-				'group' => $group,
121
-			),
122
-		);
123
-	}
8
+    // phpcs:disable Squiz.Commenting.FunctionComment.Missing, Squiz.Commenting.FunctionComment.MissingParamTag
9
+    public function test_schedule_action() {
10
+        $time      = time();
11
+        $hook      = md5( rand() );
12
+        $action_id = as_schedule_single_action( $time, $hook );
13
+
14
+        $store  = ActionScheduler::store();
15
+        $action = $store->fetch_action( $action_id );
16
+        $this->assertEquals( $time, $action->get_schedule()->get_date()->getTimestamp() );
17
+        $this->assertEquals( $hook, $action->get_hook() );
18
+    }
19
+
20
+    public function test_recurring_action() {
21
+        $time      = time();
22
+        $hook      = md5( rand() );
23
+        $action_id = as_schedule_recurring_action( $time, HOUR_IN_SECONDS, $hook );
24
+
25
+        $store  = ActionScheduler::store();
26
+        $action = $store->fetch_action( $action_id );
27
+        $this->assertEquals( $time, $action->get_schedule()->get_date()->getTimestamp() );
28
+        $this->assertEquals( $time + HOUR_IN_SECONDS + 2, $action->get_schedule()->get_next( as_get_datetime_object( $time + 2 ) )->getTimestamp() );
29
+        $this->assertEquals( $hook, $action->get_hook() );
30
+    }
31
+
32
+    public function test_cron_schedule() {
33
+        $time      = as_get_datetime_object( '2014-01-01' );
34
+        $hook      = md5( rand() );
35
+        $action_id = as_schedule_cron_action( $time->getTimestamp(), '0 0 10 10 *', $hook );
36
+
37
+        $store         = ActionScheduler::store();
38
+        $action        = $store->fetch_action( $action_id );
39
+        $expected_date = as_get_datetime_object( '2014-10-10' );
40
+        $this->assertEquals( $expected_date->getTimestamp(), $action->get_schedule()->get_date()->getTimestamp() );
41
+        $this->assertEquals( $hook, $action->get_hook() );
42
+
43
+        $expected_date = as_get_datetime_object( '2015-10-10' );
44
+        $this->assertEquals( $expected_date->getTimestamp(), $action->get_schedule()->get_next( as_get_datetime_object( '2015-01-02' ) )->getTimestamp() );
45
+    }
46
+
47
+    public function test_get_next() {
48
+        $time = as_get_datetime_object( 'tomorrow' );
49
+        $hook = md5( rand() );
50
+        as_schedule_recurring_action( $time->getTimestamp(), HOUR_IN_SECONDS, $hook );
51
+
52
+        $next = as_next_scheduled_action( $hook );
53
+
54
+        $this->assertEquals( $time->getTimestamp(), $next );
55
+    }
56
+
57
+    public function test_get_next_async() {
58
+        $hook      = md5( rand() );
59
+        $action_id = as_enqueue_async_action( $hook );
60
+
61
+        $next = as_next_scheduled_action( $hook );
62
+
63
+        $this->assertTrue( $next );
64
+
65
+        $store = ActionScheduler::store();
66
+
67
+        // Completed async actions should still return false.
68
+        $store->mark_complete( $action_id );
69
+        $next = as_next_scheduled_action( $hook );
70
+        $this->assertFalse( $next );
71
+
72
+        // Failed async actions should still return false.
73
+        $store->mark_failure( $action_id );
74
+        $next = as_next_scheduled_action( $hook );
75
+        $this->assertFalse( $next );
76
+
77
+        // Cancelled async actions should still return false.
78
+        $store->cancel_action( $action_id );
79
+        $next = as_next_scheduled_action( $hook );
80
+        $this->assertFalse( $next );
81
+    }
82
+
83
+    public function provider_time_hook_args_group() {
84
+        $time  = time() + 60 * 2;
85
+        $hook  = md5( rand() );
86
+        $args  = array( rand(), rand() );
87
+        $group = 'test_group';
88
+
89
+        return array(
90
+
91
+            // Test with no args or group.
92
+            array(
93
+                'time'  => $time,
94
+                'hook'  => $hook,
95
+                'args'  => array(),
96
+                'group' => '',
97
+            ),
98
+
99
+            // Test with args but no group.
100
+            array(
101
+                'time'  => $time,
102
+                'hook'  => $hook,
103
+                'args'  => $args,
104
+                'group' => '',
105
+            ),
106
+
107
+            // Test with group but no args.
108
+            array(
109
+                'time'  => $time,
110
+                'hook'  => $hook,
111
+                'args'  => array(),
112
+                'group' => $group,
113
+            ),
114
+
115
+            // Test with args & group.
116
+            array(
117
+                'time'  => $time,
118
+                'hook'  => $hook,
119
+                'args'  => $args,
120
+                'group' => $group,
121
+            ),
122
+        );
123
+    }
124 124
 
125
-	/**
126
-	 * @dataProvider provider_time_hook_args_group
127
-	 */
128
-	public function test_unschedule( $time, $hook, $args, $group ) {
125
+    /**
126
+     * @dataProvider provider_time_hook_args_group
127
+     */
128
+    public function test_unschedule( $time, $hook, $args, $group ) {
129 129
 
130
-		$action_id_unscheduled = as_schedule_single_action( $time, $hook, $args, $group );
131
-		$action_scheduled_time = $time + 1;
132
-		$action_id_scheduled   = as_schedule_single_action( $action_scheduled_time, $hook, $args, $group );
130
+        $action_id_unscheduled = as_schedule_single_action( $time, $hook, $args, $group );
131
+        $action_scheduled_time = $time + 1;
132
+        $action_id_scheduled   = as_schedule_single_action( $action_scheduled_time, $hook, $args, $group );
133 133
 
134
-		as_unschedule_action( $hook, $args, $group );
134
+        as_unschedule_action( $hook, $args, $group );
135 135
 
136
-		$next = as_next_scheduled_action( $hook, $args, $group );
137
-		$this->assertEquals( $action_scheduled_time, $next );
136
+        $next = as_next_scheduled_action( $hook, $args, $group );
137
+        $this->assertEquals( $action_scheduled_time, $next );
138 138
 
139
-		$store              = ActionScheduler::store();
140
-		$unscheduled_action = $store->fetch_action( $action_id_unscheduled );
139
+        $store              = ActionScheduler::store();
140
+        $unscheduled_action = $store->fetch_action( $action_id_unscheduled );
141 141
 
142
-		// Make sure the next scheduled action is unscheduled.
143
-		$this->assertEquals( $hook, $unscheduled_action->get_hook() );
144
-		$this->assertEquals( as_get_datetime_object( $time ), $unscheduled_action->get_schedule()->get_date() );
145
-		$this->assertEquals( ActionScheduler_Store::STATUS_CANCELED, $store->get_status( $action_id_unscheduled ) );
146
-		$this->assertNull( $unscheduled_action->get_schedule()->get_next( as_get_datetime_object() ) );
142
+        // Make sure the next scheduled action is unscheduled.
143
+        $this->assertEquals( $hook, $unscheduled_action->get_hook() );
144
+        $this->assertEquals( as_get_datetime_object( $time ), $unscheduled_action->get_schedule()->get_date() );
145
+        $this->assertEquals( ActionScheduler_Store::STATUS_CANCELED, $store->get_status( $action_id_unscheduled ) );
146
+        $this->assertNull( $unscheduled_action->get_schedule()->get_next( as_get_datetime_object() ) );
147 147
 
148
-		// Make sure other scheduled actions are not unscheduled.
149
-		$this->assertEquals( ActionScheduler_Store::STATUS_PENDING, $store->get_status( $action_id_scheduled ) );
150
-		$scheduled_action = $store->fetch_action( $action_id_scheduled );
148
+        // Make sure other scheduled actions are not unscheduled.
149
+        $this->assertEquals( ActionScheduler_Store::STATUS_PENDING, $store->get_status( $action_id_scheduled ) );
150
+        $scheduled_action = $store->fetch_action( $action_id_scheduled );
151 151
 
152
-		$this->assertEquals( $hook, $scheduled_action->get_hook() );
153
-		$this->assertEquals( $action_scheduled_time, $scheduled_action->get_schedule()->get_date()->getTimestamp() );
154
-	}
152
+        $this->assertEquals( $hook, $scheduled_action->get_hook() );
153
+        $this->assertEquals( $action_scheduled_time, $scheduled_action->get_schedule()->get_date()->getTimestamp() );
154
+    }
155 155
 
156
-	/**
157
-	 * @dataProvider provider_time_hook_args_group
158
-	 */
159
-	public function test_unschedule_all( $time, $hook, $args, $group ) {
156
+    /**
157
+     * @dataProvider provider_time_hook_args_group
158
+     */
159
+    public function test_unschedule_all( $time, $hook, $args, $group ) {
160 160
 
161
-		$hook       = md5( $hook );
162
-		$action_ids = array();
161
+        $hook       = md5( $hook );
162
+        $action_ids = array();
163 163
 
164
-		for ( $i = 0; $i < 3; $i++ ) {
165
-			$action_ids[] = as_schedule_single_action( $time, $hook, $args, $group );
166
-		}
164
+        for ( $i = 0; $i < 3; $i++ ) {
165
+            $action_ids[] = as_schedule_single_action( $time, $hook, $args, $group );
166
+        }
167 167
 
168
-		as_unschedule_all_actions( $hook, $args, $group );
168
+        as_unschedule_all_actions( $hook, $args, $group );
169 169
 
170
-		$next = as_next_scheduled_action( $hook );
171
-		$this->assertFalse( $next );
170
+        $next = as_next_scheduled_action( $hook );
171
+        $this->assertFalse( $next );
172 172
 
173
-		$after = as_get_datetime_object( $time );
174
-		$after->modify( '+1 minute' );
173
+        $after = as_get_datetime_object( $time );
174
+        $after->modify( '+1 minute' );
175 175
 
176
-		$store = ActionScheduler::store();
176
+        $store = ActionScheduler::store();
177 177
 
178
-		foreach ( $action_ids as $action_id ) {
179
-			$action = $store->fetch_action( $action_id );
178
+        foreach ( $action_ids as $action_id ) {
179
+            $action = $store->fetch_action( $action_id );
180 180
 
181
-			$this->assertEquals( $hook, $action->get_hook() );
182
-			$this->assertEquals( as_get_datetime_object( $time ), $action->get_schedule()->get_date() );
183
-			$this->assertEquals( ActionScheduler_Store::STATUS_CANCELED, $store->get_status( $action_id ) );
184
-			$this->assertNull( $action->get_schedule()->get_next( $after ) );
185
-		}
186
-	}
181
+            $this->assertEquals( $hook, $action->get_hook() );
182
+            $this->assertEquals( as_get_datetime_object( $time ), $action->get_schedule()->get_date() );
183
+            $this->assertEquals( ActionScheduler_Store::STATUS_CANCELED, $store->get_status( $action_id ) );
184
+            $this->assertNull( $action->get_schedule()->get_next( $after ) );
185
+        }
186
+    }
187 187
 
188
-	public function test_as_get_datetime_object_default() {
188
+    public function test_as_get_datetime_object_default() {
189 189
 
190
-		$utc_now = new ActionScheduler_DateTime( null, new DateTimeZone( 'UTC' ) );
191
-		$as_now  = as_get_datetime_object();
190
+        $utc_now = new ActionScheduler_DateTime( null, new DateTimeZone( 'UTC' ) );
191
+        $as_now  = as_get_datetime_object();
192 192
 
193
-		// Don't want to use 'U' as timestamps will always be in UTC.
194
-		$this->assertEquals( $utc_now->format( 'Y-m-d H:i:s' ), $as_now->format( 'Y-m-d H:i:s' ) );
195
-	}
193
+        // Don't want to use 'U' as timestamps will always be in UTC.
194
+        $this->assertEquals( $utc_now->format( 'Y-m-d H:i:s' ), $as_now->format( 'Y-m-d H:i:s' ) );
195
+    }
196 196
 
197
-	public function test_as_get_datetime_object_relative() {
197
+    public function test_as_get_datetime_object_relative() {
198 198
 
199
-		$utc_tomorrow = new ActionScheduler_DateTime( 'tomorrow', new DateTimeZone( 'UTC' ) );
200
-		$as_tomorrow  = as_get_datetime_object( 'tomorrow' );
199
+        $utc_tomorrow = new ActionScheduler_DateTime( 'tomorrow', new DateTimeZone( 'UTC' ) );
200
+        $as_tomorrow  = as_get_datetime_object( 'tomorrow' );
201 201
 
202
-		$this->assertEquals( $utc_tomorrow->format( 'Y-m-d H:i:s' ), $as_tomorrow->format( 'Y-m-d H:i:s' ) );
202
+        $this->assertEquals( $utc_tomorrow->format( 'Y-m-d H:i:s' ), $as_tomorrow->format( 'Y-m-d H:i:s' ) );
203 203
 
204
-		$utc_tomorrow = new ActionScheduler_DateTime( 'yesterday', new DateTimeZone( 'UTC' ) );
205
-		$as_tomorrow  = as_get_datetime_object( 'yesterday' );
204
+        $utc_tomorrow = new ActionScheduler_DateTime( 'yesterday', new DateTimeZone( 'UTC' ) );
205
+        $as_tomorrow  = as_get_datetime_object( 'yesterday' );
206 206
 
207
-		$this->assertEquals( $utc_tomorrow->format( 'Y-m-d H:i:s' ), $as_tomorrow->format( 'Y-m-d H:i:s' ) );
208
-	}
207
+        $this->assertEquals( $utc_tomorrow->format( 'Y-m-d H:i:s' ), $as_tomorrow->format( 'Y-m-d H:i:s' ) );
208
+    }
209 209
 
210
-	public function test_as_get_datetime_object_fixed() {
210
+    public function test_as_get_datetime_object_fixed() {
211 211
 
212
-		$utc_tomorrow = new ActionScheduler_DateTime( '29 February 2016', new DateTimeZone( 'UTC' ) );
213
-		$as_tomorrow  = as_get_datetime_object( '29 February 2016' );
212
+        $utc_tomorrow = new ActionScheduler_DateTime( '29 February 2016', new DateTimeZone( 'UTC' ) );
213
+        $as_tomorrow  = as_get_datetime_object( '29 February 2016' );
214 214
 
215
-		$this->assertEquals( $utc_tomorrow->format( 'Y-m-d H:i:s' ), $as_tomorrow->format( 'Y-m-d H:i:s' ) );
215
+        $this->assertEquals( $utc_tomorrow->format( 'Y-m-d H:i:s' ), $as_tomorrow->format( 'Y-m-d H:i:s' ) );
216 216
 
217
-		$utc_tomorrow = new ActionScheduler_DateTime( '1st January 2024', new DateTimeZone( 'UTC' ) );
218
-		$as_tomorrow  = as_get_datetime_object( '1st January 2024' );
217
+        $utc_tomorrow = new ActionScheduler_DateTime( '1st January 2024', new DateTimeZone( 'UTC' ) );
218
+        $as_tomorrow  = as_get_datetime_object( '1st January 2024' );
219 219
 
220
-		$this->assertEquals( $utc_tomorrow->format( 'Y-m-d H:i:s' ), $as_tomorrow->format( 'Y-m-d H:i:s' ) );
221
-	}
220
+        $this->assertEquals( $utc_tomorrow->format( 'Y-m-d H:i:s' ), $as_tomorrow->format( 'Y-m-d H:i:s' ) );
221
+    }
222 222
 
223
-	public function test_as_get_datetime_object_timezone() {
223
+    public function test_as_get_datetime_object_timezone() {
224 224
 
225
-		$timezone_au      = 'Australia/Brisbane';
226
-		$timezone_default = date_default_timezone_get();
225
+        $timezone_au      = 'Australia/Brisbane';
226
+        $timezone_default = date_default_timezone_get();
227 227
 
228
-		// phpcs:ignore
229
-		date_default_timezone_set( $timezone_au );
228
+        // phpcs:ignore
229
+        date_default_timezone_set( $timezone_au );
230 230
 
231
-		$au_now = new ActionScheduler_DateTime( null );
232
-		$as_now = as_get_datetime_object();
231
+        $au_now = new ActionScheduler_DateTime( null );
232
+        $as_now = as_get_datetime_object();
233 233
 
234
-		// Make sure they're for the same time.
235
-		$this->assertEquals( $au_now->getTimestamp(), $as_now->getTimestamp() );
234
+        // Make sure they're for the same time.
235
+        $this->assertEquals( $au_now->getTimestamp(), $as_now->getTimestamp() );
236 236
 
237
-		// But not in the same timezone, as $as_now should be using UTC.
238
-		$this->assertNotEquals( $au_now->format( 'Y-m-d H:i:s' ), $as_now->format( 'Y-m-d H:i:s' ) );
237
+        // But not in the same timezone, as $as_now should be using UTC.
238
+        $this->assertNotEquals( $au_now->format( 'Y-m-d H:i:s' ), $as_now->format( 'Y-m-d H:i:s' ) );
239 239
 
240
-		$au_now    = new ActionScheduler_DateTime( null );
241
-		$as_au_now = as_get_datetime_object();
240
+        $au_now    = new ActionScheduler_DateTime( null );
241
+        $as_au_now = as_get_datetime_object();
242 242
 
243
-		$this->assertEquals( $au_now->getTimestamp(), $as_now->getTimestamp(), '', 2 );
243
+        $this->assertEquals( $au_now->getTimestamp(), $as_now->getTimestamp(), '', 2 );
244 244
 
245
-		// But not in the same timezone, as $as_now should be using UTC.
246
-		$this->assertNotEquals( $au_now->format( 'Y-m-d H:i:s' ), $as_now->format( 'Y-m-d H:i:s' ) );
245
+        // But not in the same timezone, as $as_now should be using UTC.
246
+        $this->assertNotEquals( $au_now->format( 'Y-m-d H:i:s' ), $as_now->format( 'Y-m-d H:i:s' ) );
247 247
 
248
-		// phpcs:ignore
249
-		date_default_timezone_set( $timezone_default );
250
-	}
248
+        // phpcs:ignore
249
+        date_default_timezone_set( $timezone_default );
250
+    }
251 251
 
252
-	public function test_as_get_datetime_object_type() {
253
-		$f   = 'Y-m-d H:i:s';
254
-		$now = as_get_datetime_object();
255
-		$this->assertInstanceOf( 'ActionScheduler_DateTime', $now );
252
+    public function test_as_get_datetime_object_type() {
253
+        $f   = 'Y-m-d H:i:s';
254
+        $now = as_get_datetime_object();
255
+        $this->assertInstanceOf( 'ActionScheduler_DateTime', $now );
256 256
 
257
-		$datetime    = new DateTime( 'now', new DateTimeZone( 'UTC' ) );
258
-		$as_datetime = as_get_datetime_object( $datetime );
259
-		$this->assertEquals( $datetime->format( $f ), $as_datetime->format( $f ) );
260
-	}
257
+        $datetime    = new DateTime( 'now', new DateTimeZone( 'UTC' ) );
258
+        $as_datetime = as_get_datetime_object( $datetime );
259
+        $this->assertEquals( $datetime->format( $f ), $as_datetime->format( $f ) );
260
+    }
261 261
 
262
-	public function test_as_has_scheduled_action() {
263
-		$store = ActionScheduler::store();
262
+    public function test_as_has_scheduled_action() {
263
+        $store = ActionScheduler::store();
264 264
 
265
-		$time      = as_get_datetime_object( 'tomorrow' );
266
-		$action_id = as_schedule_single_action( $time->getTimestamp(), 'hook_1' );
265
+        $time      = as_get_datetime_object( 'tomorrow' );
266
+        $action_id = as_schedule_single_action( $time->getTimestamp(), 'hook_1' );
267 267
 
268
-		$this->assertTrue( as_has_scheduled_action( 'hook_1' ) );
269
-		$this->assertFalse( as_has_scheduled_action( 'hook_2' ) );
268
+        $this->assertTrue( as_has_scheduled_action( 'hook_1' ) );
269
+        $this->assertFalse( as_has_scheduled_action( 'hook_2' ) );
270 270
 
271
-		// Go to in-progress.
272
-		$store->log_execution( $action_id );
273
-		$this->assertTrue( as_has_scheduled_action( 'hook_1' ) );
271
+        // Go to in-progress.
272
+        $store->log_execution( $action_id );
273
+        $this->assertTrue( as_has_scheduled_action( 'hook_1' ) );
274 274
 
275
-		// Go to complete.
276
-		$store->mark_complete( $action_id );
277
-		$this->assertFalse( as_has_scheduled_action( 'hook_1' ) );
275
+        // Go to complete.
276
+        $store->mark_complete( $action_id );
277
+        $this->assertFalse( as_has_scheduled_action( 'hook_1' ) );
278 278
 
279
-		// Go to failed.
280
-		$store->mark_failure( $action_id );
281
-		$this->assertFalse( as_has_scheduled_action( 'hook_1' ) );
282
-	}
279
+        // Go to failed.
280
+        $store->mark_failure( $action_id );
281
+        $this->assertFalse( as_has_scheduled_action( 'hook_1' ) );
282
+    }
283 283
 
284
-	public function test_as_has_scheduled_action_with_args() {
285
-		as_schedule_single_action( time(), 'hook_1', array( 'a' ) );
284
+    public function test_as_has_scheduled_action_with_args() {
285
+        as_schedule_single_action( time(), 'hook_1', array( 'a' ) );
286 286
 
287
-		$this->assertTrue( as_has_scheduled_action( 'hook_1' ) );
288
-		$this->assertFalse( as_has_scheduled_action( 'hook_1', array( 'b' ) ) );
287
+        $this->assertTrue( as_has_scheduled_action( 'hook_1' ) );
288
+        $this->assertFalse( as_has_scheduled_action( 'hook_1', array( 'b' ) ) );
289 289
 
290
-		// Test for any args.
291
-		$this->assertTrue( as_has_scheduled_action( 'hook_1', array( 'a' ) ) );
292
-	}
290
+        // Test for any args.
291
+        $this->assertTrue( as_has_scheduled_action( 'hook_1', array( 'a' ) ) );
292
+    }
293 293
 
294
-	public function test_as_has_scheduled_action_with_group() {
295
-		as_schedule_single_action( time(), 'hook_1', array(), 'group_1' );
294
+    public function test_as_has_scheduled_action_with_group() {
295
+        as_schedule_single_action( time(), 'hook_1', array(), 'group_1' );
296 296
 
297
-		$this->assertTrue( as_has_scheduled_action( 'hook_1', null, 'group_1' ) );
298
-		$this->assertTrue( as_has_scheduled_action( 'hook_1', array(), 'group_1' ) );
299
-	}
300
-	// phpcs:enable
297
+        $this->assertTrue( as_has_scheduled_action( 'hook_1', null, 'group_1' ) );
298
+        $this->assertTrue( as_has_scheduled_action( 'hook_1', array(), 'group_1' ) );
299
+    }
300
+    // phpcs:enable
301 301
 
302
-	/**
303
-	 * Test as_enqueue_async_action with unique param.
304
-	 */
305
-	public function test_as_enqueue_async_action_unique() {
306
-		$this->set_action_scheduler_store( new ActionScheduler_DBStore() );
302
+    /**
303
+     * Test as_enqueue_async_action with unique param.
304
+     */
305
+    public function test_as_enqueue_async_action_unique() {
306
+        $this->set_action_scheduler_store( new ActionScheduler_DBStore() );
307 307
 
308
-		$action_id = as_enqueue_async_action( 'hook_1', array( 'a' ), 'dummy', true );
309
-		$this->assertValidAction( $action_id );
308
+        $action_id = as_enqueue_async_action( 'hook_1', array( 'a' ), 'dummy', true );
309
+        $this->assertValidAction( $action_id );
310 310
 
311
-		$action_id_duplicate = as_enqueue_async_action( 'hook_1', array( 'a' ), 'dummy', true );
312
-		$this->assertSame( 0, $action_id_duplicate );
313
-	}
311
+        $action_id_duplicate = as_enqueue_async_action( 'hook_1', array( 'a' ), 'dummy', true );
312
+        $this->assertSame( 0, $action_id_duplicate );
313
+    }
314 314
 
315
-	/**
316
-	 * Test as_schedule_single_action with unique param.
317
-	 */
318
-	public function test_as_schedule_single_action_unique() {
319
-		$this->set_action_scheduler_store( new ActionScheduler_DBStore() );
320
-
321
-		$action_id = as_schedule_single_action( time(), 'hook_1', array( 'a' ), 'dummy', true );
322
-		$this->assertValidAction( $action_id );
323
-
324
-		$action_id_duplicate = as_schedule_single_action( time(), 'hook_1', array( 'a' ), 'dummy', true );
325
-		$this->assertSame( 0, $action_id_duplicate );
326
-	}
327
-
328
-	/**
329
-	 * Test as_schedule_recurring_action with unique param.
330
-	 */
331
-	public function test_as_schedule_recurring_action_unique() {
332
-		$this->set_action_scheduler_store( new ActionScheduler_DBStore() );
333
-
334
-		$action_id = as_schedule_recurring_action( time(), MINUTE_IN_SECONDS, 'hook_1', array( 'a' ), 'dummy', true );
335
-		$this->assertValidAction( $action_id );
336
-
337
-		$action_id_duplicate = as_schedule_recurring_action( time(), MINUTE_IN_SECONDS, 'hook_1', array( 'a' ), 'dummy', true );
338
-		$this->assertSame( 0, $action_id_duplicate );
339
-	}
340
-
341
-	/**
342
-	 * Test as_schedule_cron with unique param.
343
-	 */
344
-	public function test_as_schedule_cron_action() {
345
-		$this->set_action_scheduler_store( new ActionScheduler_DBStore() );
346
-
347
-		$action_id = as_schedule_cron_action( time(), '0 0 * * *', 'hook_1', array( 'a' ), 'dummy', true );
348
-		$this->assertValidAction( $action_id );
349
-
350
-		$action_id_duplicate = as_schedule_cron_action( time(), '0 0 * * *', 'hook_1', array( 'a' ), 'dummy', true );
351
-		$this->assertSame( 0, $action_id_duplicate );
352
-	}
353
-
354
-	/**
355
-	 * Helper method to set actions scheduler store.
356
-	 *
357
-	 * @param ActionScheduler_Store $store Store instance to set.
358
-	 */
359
-	private function set_action_scheduler_store( $store ) {
360
-		$store_factory_setter        = function () use ( $store ) {
361
-			self::$store = $store;
362
-		};
363
-		$binded_store_factory_setter = Closure::bind( $store_factory_setter, null, ActionScheduler_Store::class );
364
-		$binded_store_factory_setter();
365
-	}
366
-
367
-	/**
368
-	 * Helper method to assert valid action.
369
-	 *
370
-	 * @param int $action_id Action ID to assert.
371
-	 */
372
-	private function assertValidAction( $action_id ) {
373
-		$this->assertNotEquals( 0, $action_id );
374
-		$action = ActionScheduler::store()->fetch_action( $action_id );
375
-		$this->assertInstanceOf( 'ActionScheduler_Action', $action );
376
-	}
315
+    /**
316
+     * Test as_schedule_single_action with unique param.
317
+     */
318
+    public function test_as_schedule_single_action_unique() {
319
+        $this->set_action_scheduler_store( new ActionScheduler_DBStore() );
320
+
321
+        $action_id = as_schedule_single_action( time(), 'hook_1', array( 'a' ), 'dummy', true );
322
+        $this->assertValidAction( $action_id );
323
+
324
+        $action_id_duplicate = as_schedule_single_action( time(), 'hook_1', array( 'a' ), 'dummy', true );
325
+        $this->assertSame( 0, $action_id_duplicate );
326
+    }
327
+
328
+    /**
329
+     * Test as_schedule_recurring_action with unique param.
330
+     */
331
+    public function test_as_schedule_recurring_action_unique() {
332
+        $this->set_action_scheduler_store( new ActionScheduler_DBStore() );
333
+
334
+        $action_id = as_schedule_recurring_action( time(), MINUTE_IN_SECONDS, 'hook_1', array( 'a' ), 'dummy', true );
335
+        $this->assertValidAction( $action_id );
336
+
337
+        $action_id_duplicate = as_schedule_recurring_action( time(), MINUTE_IN_SECONDS, 'hook_1', array( 'a' ), 'dummy', true );
338
+        $this->assertSame( 0, $action_id_duplicate );
339
+    }
340
+
341
+    /**
342
+     * Test as_schedule_cron with unique param.
343
+     */
344
+    public function test_as_schedule_cron_action() {
345
+        $this->set_action_scheduler_store( new ActionScheduler_DBStore() );
346
+
347
+        $action_id = as_schedule_cron_action( time(), '0 0 * * *', 'hook_1', array( 'a' ), 'dummy', true );
348
+        $this->assertValidAction( $action_id );
349
+
350
+        $action_id_duplicate = as_schedule_cron_action( time(), '0 0 * * *', 'hook_1', array( 'a' ), 'dummy', true );
351
+        $this->assertSame( 0, $action_id_duplicate );
352
+    }
353
+
354
+    /**
355
+     * Helper method to set actions scheduler store.
356
+     *
357
+     * @param ActionScheduler_Store $store Store instance to set.
358
+     */
359
+    private function set_action_scheduler_store( $store ) {
360
+        $store_factory_setter        = function () use ( $store ) {
361
+            self::$store = $store;
362
+        };
363
+        $binded_store_factory_setter = Closure::bind( $store_factory_setter, null, ActionScheduler_Store::class );
364
+        $binded_store_factory_setter();
365
+    }
366
+
367
+    /**
368
+     * Helper method to assert valid action.
369
+     *
370
+     * @param int $action_id Action ID to assert.
371
+     */
372
+    private function assertValidAction( $action_id ) {
373
+        $this->assertNotEquals( 0, $action_id );
374
+        $action = ActionScheduler::store()->fetch_action( $action_id );
375
+        $this->assertInstanceOf( 'ActionScheduler_Action', $action );
376
+    }
377 377
 }
Please login to merge, or discard this patch.
Spacing   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -8,82 +8,82 @@  discard block
 block discarded – undo
8 8
 	// phpcs:disable Squiz.Commenting.FunctionComment.Missing, Squiz.Commenting.FunctionComment.MissingParamTag
9 9
 	public function test_schedule_action() {
10 10
 		$time      = time();
11
-		$hook      = md5( rand() );
12
-		$action_id = as_schedule_single_action( $time, $hook );
11
+		$hook      = md5(rand());
12
+		$action_id = as_schedule_single_action($time, $hook);
13 13
 
14 14
 		$store  = ActionScheduler::store();
15
-		$action = $store->fetch_action( $action_id );
16
-		$this->assertEquals( $time, $action->get_schedule()->get_date()->getTimestamp() );
17
-		$this->assertEquals( $hook, $action->get_hook() );
15
+		$action = $store->fetch_action($action_id);
16
+		$this->assertEquals($time, $action->get_schedule()->get_date()->getTimestamp());
17
+		$this->assertEquals($hook, $action->get_hook());
18 18
 	}
19 19
 
20 20
 	public function test_recurring_action() {
21 21
 		$time      = time();
22
-		$hook      = md5( rand() );
23
-		$action_id = as_schedule_recurring_action( $time, HOUR_IN_SECONDS, $hook );
22
+		$hook      = md5(rand());
23
+		$action_id = as_schedule_recurring_action($time, HOUR_IN_SECONDS, $hook);
24 24
 
25 25
 		$store  = ActionScheduler::store();
26
-		$action = $store->fetch_action( $action_id );
27
-		$this->assertEquals( $time, $action->get_schedule()->get_date()->getTimestamp() );
28
-		$this->assertEquals( $time + HOUR_IN_SECONDS + 2, $action->get_schedule()->get_next( as_get_datetime_object( $time + 2 ) )->getTimestamp() );
29
-		$this->assertEquals( $hook, $action->get_hook() );
26
+		$action = $store->fetch_action($action_id);
27
+		$this->assertEquals($time, $action->get_schedule()->get_date()->getTimestamp());
28
+		$this->assertEquals($time + HOUR_IN_SECONDS + 2, $action->get_schedule()->get_next(as_get_datetime_object($time + 2))->getTimestamp());
29
+		$this->assertEquals($hook, $action->get_hook());
30 30
 	}
31 31
 
32 32
 	public function test_cron_schedule() {
33
-		$time      = as_get_datetime_object( '2014-01-01' );
34
-		$hook      = md5( rand() );
35
-		$action_id = as_schedule_cron_action( $time->getTimestamp(), '0 0 10 10 *', $hook );
33
+		$time      = as_get_datetime_object('2014-01-01');
34
+		$hook      = md5(rand());
35
+		$action_id = as_schedule_cron_action($time->getTimestamp(), '0 0 10 10 *', $hook);
36 36
 
37 37
 		$store         = ActionScheduler::store();
38
-		$action        = $store->fetch_action( $action_id );
39
-		$expected_date = as_get_datetime_object( '2014-10-10' );
40
-		$this->assertEquals( $expected_date->getTimestamp(), $action->get_schedule()->get_date()->getTimestamp() );
41
-		$this->assertEquals( $hook, $action->get_hook() );
38
+		$action        = $store->fetch_action($action_id);
39
+		$expected_date = as_get_datetime_object('2014-10-10');
40
+		$this->assertEquals($expected_date->getTimestamp(), $action->get_schedule()->get_date()->getTimestamp());
41
+		$this->assertEquals($hook, $action->get_hook());
42 42
 
43
-		$expected_date = as_get_datetime_object( '2015-10-10' );
44
-		$this->assertEquals( $expected_date->getTimestamp(), $action->get_schedule()->get_next( as_get_datetime_object( '2015-01-02' ) )->getTimestamp() );
43
+		$expected_date = as_get_datetime_object('2015-10-10');
44
+		$this->assertEquals($expected_date->getTimestamp(), $action->get_schedule()->get_next(as_get_datetime_object('2015-01-02'))->getTimestamp());
45 45
 	}
46 46
 
47 47
 	public function test_get_next() {
48
-		$time = as_get_datetime_object( 'tomorrow' );
49
-		$hook = md5( rand() );
50
-		as_schedule_recurring_action( $time->getTimestamp(), HOUR_IN_SECONDS, $hook );
48
+		$time = as_get_datetime_object('tomorrow');
49
+		$hook = md5(rand());
50
+		as_schedule_recurring_action($time->getTimestamp(), HOUR_IN_SECONDS, $hook);
51 51
 
52
-		$next = as_next_scheduled_action( $hook );
52
+		$next = as_next_scheduled_action($hook);
53 53
 
54
-		$this->assertEquals( $time->getTimestamp(), $next );
54
+		$this->assertEquals($time->getTimestamp(), $next);
55 55
 	}
56 56
 
57 57
 	public function test_get_next_async() {
58
-		$hook      = md5( rand() );
59
-		$action_id = as_enqueue_async_action( $hook );
58
+		$hook      = md5(rand());
59
+		$action_id = as_enqueue_async_action($hook);
60 60
 
61
-		$next = as_next_scheduled_action( $hook );
61
+		$next = as_next_scheduled_action($hook);
62 62
 
63
-		$this->assertTrue( $next );
63
+		$this->assertTrue($next);
64 64
 
65 65
 		$store = ActionScheduler::store();
66 66
 
67 67
 		// Completed async actions should still return false.
68
-		$store->mark_complete( $action_id );
69
-		$next = as_next_scheduled_action( $hook );
70
-		$this->assertFalse( $next );
68
+		$store->mark_complete($action_id);
69
+		$next = as_next_scheduled_action($hook);
70
+		$this->assertFalse($next);
71 71
 
72 72
 		// Failed async actions should still return false.
73
-		$store->mark_failure( $action_id );
74
-		$next = as_next_scheduled_action( $hook );
75
-		$this->assertFalse( $next );
73
+		$store->mark_failure($action_id);
74
+		$next = as_next_scheduled_action($hook);
75
+		$this->assertFalse($next);
76 76
 
77 77
 		// Cancelled async actions should still return false.
78
-		$store->cancel_action( $action_id );
79
-		$next = as_next_scheduled_action( $hook );
80
-		$this->assertFalse( $next );
78
+		$store->cancel_action($action_id);
79
+		$next = as_next_scheduled_action($hook);
80
+		$this->assertFalse($next);
81 81
 	}
82 82
 
83 83
 	public function provider_time_hook_args_group() {
84 84
 		$time  = time() + 60 * 2;
85
-		$hook  = md5( rand() );
86
-		$args  = array( rand(), rand() );
85
+		$hook  = md5(rand());
86
+		$args  = array(rand(), rand());
87 87
 		$group = 'test_group';
88 88
 
89 89
 		return array(
@@ -125,99 +125,99 @@  discard block
 block discarded – undo
125 125
 	/**
126 126
 	 * @dataProvider provider_time_hook_args_group
127 127
 	 */
128
-	public function test_unschedule( $time, $hook, $args, $group ) {
128
+	public function test_unschedule($time, $hook, $args, $group) {
129 129
 
130
-		$action_id_unscheduled = as_schedule_single_action( $time, $hook, $args, $group );
130
+		$action_id_unscheduled = as_schedule_single_action($time, $hook, $args, $group);
131 131
 		$action_scheduled_time = $time + 1;
132
-		$action_id_scheduled   = as_schedule_single_action( $action_scheduled_time, $hook, $args, $group );
132
+		$action_id_scheduled   = as_schedule_single_action($action_scheduled_time, $hook, $args, $group);
133 133
 
134
-		as_unschedule_action( $hook, $args, $group );
134
+		as_unschedule_action($hook, $args, $group);
135 135
 
136
-		$next = as_next_scheduled_action( $hook, $args, $group );
137
-		$this->assertEquals( $action_scheduled_time, $next );
136
+		$next = as_next_scheduled_action($hook, $args, $group);
137
+		$this->assertEquals($action_scheduled_time, $next);
138 138
 
139 139
 		$store              = ActionScheduler::store();
140
-		$unscheduled_action = $store->fetch_action( $action_id_unscheduled );
140
+		$unscheduled_action = $store->fetch_action($action_id_unscheduled);
141 141
 
142 142
 		// Make sure the next scheduled action is unscheduled.
143
-		$this->assertEquals( $hook, $unscheduled_action->get_hook() );
144
-		$this->assertEquals( as_get_datetime_object( $time ), $unscheduled_action->get_schedule()->get_date() );
145
-		$this->assertEquals( ActionScheduler_Store::STATUS_CANCELED, $store->get_status( $action_id_unscheduled ) );
146
-		$this->assertNull( $unscheduled_action->get_schedule()->get_next( as_get_datetime_object() ) );
143
+		$this->assertEquals($hook, $unscheduled_action->get_hook());
144
+		$this->assertEquals(as_get_datetime_object($time), $unscheduled_action->get_schedule()->get_date());
145
+		$this->assertEquals(ActionScheduler_Store::STATUS_CANCELED, $store->get_status($action_id_unscheduled));
146
+		$this->assertNull($unscheduled_action->get_schedule()->get_next(as_get_datetime_object()));
147 147
 
148 148
 		// Make sure other scheduled actions are not unscheduled.
149
-		$this->assertEquals( ActionScheduler_Store::STATUS_PENDING, $store->get_status( $action_id_scheduled ) );
150
-		$scheduled_action = $store->fetch_action( $action_id_scheduled );
149
+		$this->assertEquals(ActionScheduler_Store::STATUS_PENDING, $store->get_status($action_id_scheduled));
150
+		$scheduled_action = $store->fetch_action($action_id_scheduled);
151 151
 
152
-		$this->assertEquals( $hook, $scheduled_action->get_hook() );
153
-		$this->assertEquals( $action_scheduled_time, $scheduled_action->get_schedule()->get_date()->getTimestamp() );
152
+		$this->assertEquals($hook, $scheduled_action->get_hook());
153
+		$this->assertEquals($action_scheduled_time, $scheduled_action->get_schedule()->get_date()->getTimestamp());
154 154
 	}
155 155
 
156 156
 	/**
157 157
 	 * @dataProvider provider_time_hook_args_group
158 158
 	 */
159
-	public function test_unschedule_all( $time, $hook, $args, $group ) {
159
+	public function test_unschedule_all($time, $hook, $args, $group) {
160 160
 
161
-		$hook       = md5( $hook );
161
+		$hook       = md5($hook);
162 162
 		$action_ids = array();
163 163
 
164
-		for ( $i = 0; $i < 3; $i++ ) {
165
-			$action_ids[] = as_schedule_single_action( $time, $hook, $args, $group );
164
+		for ($i = 0; $i < 3; $i++) {
165
+			$action_ids[] = as_schedule_single_action($time, $hook, $args, $group);
166 166
 		}
167 167
 
168
-		as_unschedule_all_actions( $hook, $args, $group );
168
+		as_unschedule_all_actions($hook, $args, $group);
169 169
 
170
-		$next = as_next_scheduled_action( $hook );
171
-		$this->assertFalse( $next );
170
+		$next = as_next_scheduled_action($hook);
171
+		$this->assertFalse($next);
172 172
 
173
-		$after = as_get_datetime_object( $time );
174
-		$after->modify( '+1 minute' );
173
+		$after = as_get_datetime_object($time);
174
+		$after->modify('+1 minute');
175 175
 
176 176
 		$store = ActionScheduler::store();
177 177
 
178
-		foreach ( $action_ids as $action_id ) {
179
-			$action = $store->fetch_action( $action_id );
178
+		foreach ($action_ids as $action_id) {
179
+			$action = $store->fetch_action($action_id);
180 180
 
181
-			$this->assertEquals( $hook, $action->get_hook() );
182
-			$this->assertEquals( as_get_datetime_object( $time ), $action->get_schedule()->get_date() );
183
-			$this->assertEquals( ActionScheduler_Store::STATUS_CANCELED, $store->get_status( $action_id ) );
184
-			$this->assertNull( $action->get_schedule()->get_next( $after ) );
181
+			$this->assertEquals($hook, $action->get_hook());
182
+			$this->assertEquals(as_get_datetime_object($time), $action->get_schedule()->get_date());
183
+			$this->assertEquals(ActionScheduler_Store::STATUS_CANCELED, $store->get_status($action_id));
184
+			$this->assertNull($action->get_schedule()->get_next($after));
185 185
 		}
186 186
 	}
187 187
 
188 188
 	public function test_as_get_datetime_object_default() {
189 189
 
190
-		$utc_now = new ActionScheduler_DateTime( null, new DateTimeZone( 'UTC' ) );
190
+		$utc_now = new ActionScheduler_DateTime(null, new DateTimeZone('UTC'));
191 191
 		$as_now  = as_get_datetime_object();
192 192
 
193 193
 		// Don't want to use 'U' as timestamps will always be in UTC.
194
-		$this->assertEquals( $utc_now->format( 'Y-m-d H:i:s' ), $as_now->format( 'Y-m-d H:i:s' ) );
194
+		$this->assertEquals($utc_now->format('Y-m-d H:i:s'), $as_now->format('Y-m-d H:i:s'));
195 195
 	}
196 196
 
197 197
 	public function test_as_get_datetime_object_relative() {
198 198
 
199
-		$utc_tomorrow = new ActionScheduler_DateTime( 'tomorrow', new DateTimeZone( 'UTC' ) );
200
-		$as_tomorrow  = as_get_datetime_object( 'tomorrow' );
199
+		$utc_tomorrow = new ActionScheduler_DateTime('tomorrow', new DateTimeZone('UTC'));
200
+		$as_tomorrow  = as_get_datetime_object('tomorrow');
201 201
 
202
-		$this->assertEquals( $utc_tomorrow->format( 'Y-m-d H:i:s' ), $as_tomorrow->format( 'Y-m-d H:i:s' ) );
202
+		$this->assertEquals($utc_tomorrow->format('Y-m-d H:i:s'), $as_tomorrow->format('Y-m-d H:i:s'));
203 203
 
204
-		$utc_tomorrow = new ActionScheduler_DateTime( 'yesterday', new DateTimeZone( 'UTC' ) );
205
-		$as_tomorrow  = as_get_datetime_object( 'yesterday' );
204
+		$utc_tomorrow = new ActionScheduler_DateTime('yesterday', new DateTimeZone('UTC'));
205
+		$as_tomorrow  = as_get_datetime_object('yesterday');
206 206
 
207
-		$this->assertEquals( $utc_tomorrow->format( 'Y-m-d H:i:s' ), $as_tomorrow->format( 'Y-m-d H:i:s' ) );
207
+		$this->assertEquals($utc_tomorrow->format('Y-m-d H:i:s'), $as_tomorrow->format('Y-m-d H:i:s'));
208 208
 	}
209 209
 
210 210
 	public function test_as_get_datetime_object_fixed() {
211 211
 
212
-		$utc_tomorrow = new ActionScheduler_DateTime( '29 February 2016', new DateTimeZone( 'UTC' ) );
213
-		$as_tomorrow  = as_get_datetime_object( '29 February 2016' );
212
+		$utc_tomorrow = new ActionScheduler_DateTime('29 February 2016', new DateTimeZone('UTC'));
213
+		$as_tomorrow  = as_get_datetime_object('29 February 2016');
214 214
 
215
-		$this->assertEquals( $utc_tomorrow->format( 'Y-m-d H:i:s' ), $as_tomorrow->format( 'Y-m-d H:i:s' ) );
215
+		$this->assertEquals($utc_tomorrow->format('Y-m-d H:i:s'), $as_tomorrow->format('Y-m-d H:i:s'));
216 216
 
217
-		$utc_tomorrow = new ActionScheduler_DateTime( '1st January 2024', new DateTimeZone( 'UTC' ) );
218
-		$as_tomorrow  = as_get_datetime_object( '1st January 2024' );
217
+		$utc_tomorrow = new ActionScheduler_DateTime('1st January 2024', new DateTimeZone('UTC'));
218
+		$as_tomorrow  = as_get_datetime_object('1st January 2024');
219 219
 
220
-		$this->assertEquals( $utc_tomorrow->format( 'Y-m-d H:i:s' ), $as_tomorrow->format( 'Y-m-d H:i:s' ) );
220
+		$this->assertEquals($utc_tomorrow->format('Y-m-d H:i:s'), $as_tomorrow->format('Y-m-d H:i:s'));
221 221
 	}
222 222
 
223 223
 	public function test_as_get_datetime_object_timezone() {
@@ -226,76 +226,76 @@  discard block
 block discarded – undo
226 226
 		$timezone_default = date_default_timezone_get();
227 227
 
228 228
 		// phpcs:ignore
229
-		date_default_timezone_set( $timezone_au );
229
+		date_default_timezone_set($timezone_au);
230 230
 
231
-		$au_now = new ActionScheduler_DateTime( null );
231
+		$au_now = new ActionScheduler_DateTime(null);
232 232
 		$as_now = as_get_datetime_object();
233 233
 
234 234
 		// Make sure they're for the same time.
235
-		$this->assertEquals( $au_now->getTimestamp(), $as_now->getTimestamp() );
235
+		$this->assertEquals($au_now->getTimestamp(), $as_now->getTimestamp());
236 236
 
237 237
 		// But not in the same timezone, as $as_now should be using UTC.
238
-		$this->assertNotEquals( $au_now->format( 'Y-m-d H:i:s' ), $as_now->format( 'Y-m-d H:i:s' ) );
238
+		$this->assertNotEquals($au_now->format('Y-m-d H:i:s'), $as_now->format('Y-m-d H:i:s'));
239 239
 
240
-		$au_now    = new ActionScheduler_DateTime( null );
240
+		$au_now    = new ActionScheduler_DateTime(null);
241 241
 		$as_au_now = as_get_datetime_object();
242 242
 
243
-		$this->assertEquals( $au_now->getTimestamp(), $as_now->getTimestamp(), '', 2 );
243
+		$this->assertEquals($au_now->getTimestamp(), $as_now->getTimestamp(), '', 2);
244 244
 
245 245
 		// But not in the same timezone, as $as_now should be using UTC.
246
-		$this->assertNotEquals( $au_now->format( 'Y-m-d H:i:s' ), $as_now->format( 'Y-m-d H:i:s' ) );
246
+		$this->assertNotEquals($au_now->format('Y-m-d H:i:s'), $as_now->format('Y-m-d H:i:s'));
247 247
 
248 248
 		// phpcs:ignore
249
-		date_default_timezone_set( $timezone_default );
249
+		date_default_timezone_set($timezone_default);
250 250
 	}
251 251
 
252 252
 	public function test_as_get_datetime_object_type() {
253 253
 		$f   = 'Y-m-d H:i:s';
254 254
 		$now = as_get_datetime_object();
255
-		$this->assertInstanceOf( 'ActionScheduler_DateTime', $now );
255
+		$this->assertInstanceOf('ActionScheduler_DateTime', $now);
256 256
 
257
-		$datetime    = new DateTime( 'now', new DateTimeZone( 'UTC' ) );
258
-		$as_datetime = as_get_datetime_object( $datetime );
259
-		$this->assertEquals( $datetime->format( $f ), $as_datetime->format( $f ) );
257
+		$datetime    = new DateTime('now', new DateTimeZone('UTC'));
258
+		$as_datetime = as_get_datetime_object($datetime);
259
+		$this->assertEquals($datetime->format($f), $as_datetime->format($f));
260 260
 	}
261 261
 
262 262
 	public function test_as_has_scheduled_action() {
263 263
 		$store = ActionScheduler::store();
264 264
 
265
-		$time      = as_get_datetime_object( 'tomorrow' );
266
-		$action_id = as_schedule_single_action( $time->getTimestamp(), 'hook_1' );
265
+		$time      = as_get_datetime_object('tomorrow');
266
+		$action_id = as_schedule_single_action($time->getTimestamp(), 'hook_1');
267 267
 
268
-		$this->assertTrue( as_has_scheduled_action( 'hook_1' ) );
269
-		$this->assertFalse( as_has_scheduled_action( 'hook_2' ) );
268
+		$this->assertTrue(as_has_scheduled_action('hook_1'));
269
+		$this->assertFalse(as_has_scheduled_action('hook_2'));
270 270
 
271 271
 		// Go to in-progress.
272
-		$store->log_execution( $action_id );
273
-		$this->assertTrue( as_has_scheduled_action( 'hook_1' ) );
272
+		$store->log_execution($action_id);
273
+		$this->assertTrue(as_has_scheduled_action('hook_1'));
274 274
 
275 275
 		// Go to complete.
276
-		$store->mark_complete( $action_id );
277
-		$this->assertFalse( as_has_scheduled_action( 'hook_1' ) );
276
+		$store->mark_complete($action_id);
277
+		$this->assertFalse(as_has_scheduled_action('hook_1'));
278 278
 
279 279
 		// Go to failed.
280
-		$store->mark_failure( $action_id );
281
-		$this->assertFalse( as_has_scheduled_action( 'hook_1' ) );
280
+		$store->mark_failure($action_id);
281
+		$this->assertFalse(as_has_scheduled_action('hook_1'));
282 282
 	}
283 283
 
284 284
 	public function test_as_has_scheduled_action_with_args() {
285
-		as_schedule_single_action( time(), 'hook_1', array( 'a' ) );
285
+		as_schedule_single_action(time(), 'hook_1', array('a'));
286 286
 
287
-		$this->assertTrue( as_has_scheduled_action( 'hook_1' ) );
288
-		$this->assertFalse( as_has_scheduled_action( 'hook_1', array( 'b' ) ) );
287
+		$this->assertTrue(as_has_scheduled_action('hook_1'));
288
+		$this->assertFalse(as_has_scheduled_action('hook_1', array('b')));
289 289
 
290 290
 		// Test for any args.
291
-		$this->assertTrue( as_has_scheduled_action( 'hook_1', array( 'a' ) ) );
291
+		$this->assertTrue(as_has_scheduled_action('hook_1', array('a')));
292 292
 	}
293 293
 
294 294
 	public function test_as_has_scheduled_action_with_group() {
295
-		as_schedule_single_action( time(), 'hook_1', array(), 'group_1' );
295
+		as_schedule_single_action(time(), 'hook_1', array(), 'group_1');
296 296
 
297
-		$this->assertTrue( as_has_scheduled_action( 'hook_1', null, 'group_1' ) );
298
-		$this->assertTrue( as_has_scheduled_action( 'hook_1', array(), 'group_1' ) );
297
+		$this->assertTrue(as_has_scheduled_action('hook_1', null, 'group_1'));
298
+		$this->assertTrue(as_has_scheduled_action('hook_1', array(), 'group_1'));
299 299
 	}
300 300
 	// phpcs:enable
301 301
 
@@ -303,52 +303,52 @@  discard block
 block discarded – undo
303 303
 	 * Test as_enqueue_async_action with unique param.
304 304
 	 */
305 305
 	public function test_as_enqueue_async_action_unique() {
306
-		$this->set_action_scheduler_store( new ActionScheduler_DBStore() );
306
+		$this->set_action_scheduler_store(new ActionScheduler_DBStore());
307 307
 
308
-		$action_id = as_enqueue_async_action( 'hook_1', array( 'a' ), 'dummy', true );
309
-		$this->assertValidAction( $action_id );
308
+		$action_id = as_enqueue_async_action('hook_1', array('a'), 'dummy', true);
309
+		$this->assertValidAction($action_id);
310 310
 
311
-		$action_id_duplicate = as_enqueue_async_action( 'hook_1', array( 'a' ), 'dummy', true );
312
-		$this->assertSame( 0, $action_id_duplicate );
311
+		$action_id_duplicate = as_enqueue_async_action('hook_1', array('a'), 'dummy', true);
312
+		$this->assertSame(0, $action_id_duplicate);
313 313
 	}
314 314
 
315 315
 	/**
316 316
 	 * Test as_schedule_single_action with unique param.
317 317
 	 */
318 318
 	public function test_as_schedule_single_action_unique() {
319
-		$this->set_action_scheduler_store( new ActionScheduler_DBStore() );
319
+		$this->set_action_scheduler_store(new ActionScheduler_DBStore());
320 320
 
321
-		$action_id = as_schedule_single_action( time(), 'hook_1', array( 'a' ), 'dummy', true );
322
-		$this->assertValidAction( $action_id );
321
+		$action_id = as_schedule_single_action(time(), 'hook_1', array('a'), 'dummy', true);
322
+		$this->assertValidAction($action_id);
323 323
 
324
-		$action_id_duplicate = as_schedule_single_action( time(), 'hook_1', array( 'a' ), 'dummy', true );
325
-		$this->assertSame( 0, $action_id_duplicate );
324
+		$action_id_duplicate = as_schedule_single_action(time(), 'hook_1', array('a'), 'dummy', true);
325
+		$this->assertSame(0, $action_id_duplicate);
326 326
 	}
327 327
 
328 328
 	/**
329 329
 	 * Test as_schedule_recurring_action with unique param.
330 330
 	 */
331 331
 	public function test_as_schedule_recurring_action_unique() {
332
-		$this->set_action_scheduler_store( new ActionScheduler_DBStore() );
332
+		$this->set_action_scheduler_store(new ActionScheduler_DBStore());
333 333
 
334
-		$action_id = as_schedule_recurring_action( time(), MINUTE_IN_SECONDS, 'hook_1', array( 'a' ), 'dummy', true );
335
-		$this->assertValidAction( $action_id );
334
+		$action_id = as_schedule_recurring_action(time(), MINUTE_IN_SECONDS, 'hook_1', array('a'), 'dummy', true);
335
+		$this->assertValidAction($action_id);
336 336
 
337
-		$action_id_duplicate = as_schedule_recurring_action( time(), MINUTE_IN_SECONDS, 'hook_1', array( 'a' ), 'dummy', true );
338
-		$this->assertSame( 0, $action_id_duplicate );
337
+		$action_id_duplicate = as_schedule_recurring_action(time(), MINUTE_IN_SECONDS, 'hook_1', array('a'), 'dummy', true);
338
+		$this->assertSame(0, $action_id_duplicate);
339 339
 	}
340 340
 
341 341
 	/**
342 342
 	 * Test as_schedule_cron with unique param.
343 343
 	 */
344 344
 	public function test_as_schedule_cron_action() {
345
-		$this->set_action_scheduler_store( new ActionScheduler_DBStore() );
345
+		$this->set_action_scheduler_store(new ActionScheduler_DBStore());
346 346
 
347
-		$action_id = as_schedule_cron_action( time(), '0 0 * * *', 'hook_1', array( 'a' ), 'dummy', true );
348
-		$this->assertValidAction( $action_id );
347
+		$action_id = as_schedule_cron_action(time(), '0 0 * * *', 'hook_1', array('a'), 'dummy', true);
348
+		$this->assertValidAction($action_id);
349 349
 
350
-		$action_id_duplicate = as_schedule_cron_action( time(), '0 0 * * *', 'hook_1', array( 'a' ), 'dummy', true );
351
-		$this->assertSame( 0, $action_id_duplicate );
350
+		$action_id_duplicate = as_schedule_cron_action(time(), '0 0 * * *', 'hook_1', array('a'), 'dummy', true);
351
+		$this->assertSame(0, $action_id_duplicate);
352 352
 	}
353 353
 
354 354
 	/**
@@ -356,11 +356,11 @@  discard block
 block discarded – undo
356 356
 	 *
357 357
 	 * @param ActionScheduler_Store $store Store instance to set.
358 358
 	 */
359
-	private function set_action_scheduler_store( $store ) {
360
-		$store_factory_setter        = function () use ( $store ) {
359
+	private function set_action_scheduler_store($store) {
360
+		$store_factory_setter        = function() use ($store) {
361 361
 			self::$store = $store;
362 362
 		};
363
-		$binded_store_factory_setter = Closure::bind( $store_factory_setter, null, ActionScheduler_Store::class );
363
+		$binded_store_factory_setter = Closure::bind($store_factory_setter, null, ActionScheduler_Store::class);
364 364
 		$binded_store_factory_setter();
365 365
 	}
366 366
 
@@ -369,9 +369,9 @@  discard block
 block discarded – undo
369 369
 	 *
370 370
 	 * @param int $action_id Action ID to assert.
371 371
 	 */
372
-	private function assertValidAction( $action_id ) {
373
-		$this->assertNotEquals( 0, $action_id );
374
-		$action = ActionScheduler::store()->fetch_action( $action_id );
375
-		$this->assertInstanceOf( 'ActionScheduler_Action', $action );
372
+	private function assertValidAction($action_id) {
373
+		$this->assertNotEquals(0, $action_id);
374
+		$action = ActionScheduler::store()->fetch_action($action_id);
375
+		$this->assertInstanceOf('ActionScheduler_Action', $action);
376 376
 	}
377 377
 }
Please login to merge, or discard this patch.
action-scheduler/tests/phpunit/versioning/ActionScheduler_Versions_Test.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -4,40 +4,40 @@
 block discarded – undo
4 4
  * Class ActionScheduler_Versions_Test
5 5
  */
6 6
 class ActionScheduler_Versions_Test extends ActionScheduler_UnitTestCase {
7
-	public function test_register_version() {
8
-		$versions = new ActionScheduler_Versions();
9
-		$versions->register( '1.0-dev', 'callback_1_dot_0_dev' );
10
-		$versions->register( '1.0', 'callback_1_dot_0' );
7
+    public function test_register_version() {
8
+        $versions = new ActionScheduler_Versions();
9
+        $versions->register( '1.0-dev', 'callback_1_dot_0_dev' );
10
+        $versions->register( '1.0', 'callback_1_dot_0' );
11 11
 
12
-		$registered = $versions->get_versions();
12
+        $registered = $versions->get_versions();
13 13
 
14
-		$this->assertArrayHasKey( '1.0-dev', $registered );
15
-		$this->assertArrayHasKey( '1.0', $registered );
16
-		$this->assertCount( 2, $registered );
14
+        $this->assertArrayHasKey( '1.0-dev', $registered );
15
+        $this->assertArrayHasKey( '1.0', $registered );
16
+        $this->assertCount( 2, $registered );
17 17
 
18
-		$this->assertEquals( 'callback_1_dot_0_dev', $registered['1.0-dev'] );
19
-	}
18
+        $this->assertEquals( 'callback_1_dot_0_dev', $registered['1.0-dev'] );
19
+    }
20 20
 
21
-	public function test_duplicate_version() {
22
-		$versions = new ActionScheduler_Versions();
23
-		$versions->register( '1.0', 'callback_1_dot_0_a' );
24
-		$versions->register( '1.0', 'callback_1_dot_0_b' );
21
+    public function test_duplicate_version() {
22
+        $versions = new ActionScheduler_Versions();
23
+        $versions->register( '1.0', 'callback_1_dot_0_a' );
24
+        $versions->register( '1.0', 'callback_1_dot_0_b' );
25 25
 
26
-		$registered = $versions->get_versions();
26
+        $registered = $versions->get_versions();
27 27
 
28
-		$this->assertArrayHasKey( '1.0', $registered );
29
-		$this->assertCount( 1, $registered );
30
-	}
28
+        $this->assertArrayHasKey( '1.0', $registered );
29
+        $this->assertCount( 1, $registered );
30
+    }
31 31
 
32
-	public function test_latest_version() {
33
-		$versions = new ActionScheduler_Versions();
34
-		$this->assertEquals( '__return_null', $versions->latest_version_callback() );
35
-		$versions->register( '1.2', 'callback_1_dot_2' );
36
-		$versions->register( '1.3', 'callback_1_dot_3' );
37
-		$versions->register( '1.0', 'callback_1_dot_0' );
32
+    public function test_latest_version() {
33
+        $versions = new ActionScheduler_Versions();
34
+        $this->assertEquals( '__return_null', $versions->latest_version_callback() );
35
+        $versions->register( '1.2', 'callback_1_dot_2' );
36
+        $versions->register( '1.3', 'callback_1_dot_3' );
37
+        $versions->register( '1.0', 'callback_1_dot_0' );
38 38
 
39
-		$this->assertSame( '1.3', $versions->latest_version() );
40
-		$this->assertEquals( 'callback_1_dot_3', $versions->latest_version_callback() );
41
-	}
39
+        $this->assertSame( '1.3', $versions->latest_version() );
40
+        $this->assertEquals( 'callback_1_dot_3', $versions->latest_version_callback() );
41
+    }
42 42
 }
43 43
 
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -6,38 +6,38 @@
 block discarded – undo
6 6
 class ActionScheduler_Versions_Test extends ActionScheduler_UnitTestCase {
7 7
 	public function test_register_version() {
8 8
 		$versions = new ActionScheduler_Versions();
9
-		$versions->register( '1.0-dev', 'callback_1_dot_0_dev' );
10
-		$versions->register( '1.0', 'callback_1_dot_0' );
9
+		$versions->register('1.0-dev', 'callback_1_dot_0_dev');
10
+		$versions->register('1.0', 'callback_1_dot_0');
11 11
 
12 12
 		$registered = $versions->get_versions();
13 13
 
14
-		$this->assertArrayHasKey( '1.0-dev', $registered );
15
-		$this->assertArrayHasKey( '1.0', $registered );
16
-		$this->assertCount( 2, $registered );
14
+		$this->assertArrayHasKey('1.0-dev', $registered);
15
+		$this->assertArrayHasKey('1.0', $registered);
16
+		$this->assertCount(2, $registered);
17 17
 
18
-		$this->assertEquals( 'callback_1_dot_0_dev', $registered['1.0-dev'] );
18
+		$this->assertEquals('callback_1_dot_0_dev', $registered['1.0-dev']);
19 19
 	}
20 20
 
21 21
 	public function test_duplicate_version() {
22 22
 		$versions = new ActionScheduler_Versions();
23
-		$versions->register( '1.0', 'callback_1_dot_0_a' );
24
-		$versions->register( '1.0', 'callback_1_dot_0_b' );
23
+		$versions->register('1.0', 'callback_1_dot_0_a');
24
+		$versions->register('1.0', 'callback_1_dot_0_b');
25 25
 
26 26
 		$registered = $versions->get_versions();
27 27
 
28
-		$this->assertArrayHasKey( '1.0', $registered );
29
-		$this->assertCount( 1, $registered );
28
+		$this->assertArrayHasKey('1.0', $registered);
29
+		$this->assertCount(1, $registered);
30 30
 	}
31 31
 
32 32
 	public function test_latest_version() {
33 33
 		$versions = new ActionScheduler_Versions();
34
-		$this->assertEquals( '__return_null', $versions->latest_version_callback() );
35
-		$versions->register( '1.2', 'callback_1_dot_2' );
36
-		$versions->register( '1.3', 'callback_1_dot_3' );
37
-		$versions->register( '1.0', 'callback_1_dot_0' );
34
+		$this->assertEquals('__return_null', $versions->latest_version_callback());
35
+		$versions->register('1.2', 'callback_1_dot_2');
36
+		$versions->register('1.3', 'callback_1_dot_3');
37
+		$versions->register('1.0', 'callback_1_dot_0');
38 38
 
39
-		$this->assertSame( '1.3', $versions->latest_version() );
40
-		$this->assertEquals( 'callback_1_dot_3', $versions->latest_version_callback() );
39
+		$this->assertSame('1.3', $versions->latest_version());
40
+		$this->assertEquals('callback_1_dot_3', $versions->latest_version_callback());
41 41
 	}
42 42
 }
43 43
 
Please login to merge, or discard this patch.
action-scheduler/tests/phpunit/logging/ActionScheduler_DBLogger_Test.php 2 patches
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -7,131 +7,131 @@
 block discarded – undo
7 7
  * @group tables
8 8
  */
9 9
 class ActionScheduler_DBLogger_Test extends ActionScheduler_UnitTestCase {
10
-	public function test_default_logger() {
11
-		$logger = ActionScheduler::logger();
12
-		$this->assertInstanceOf( 'ActionScheduler_Logger', $logger );
13
-		$this->assertInstanceOf( ActionScheduler_DBLogger::class, $logger );
14
-	}
15
-
16
-	public function test_add_log_entry() {
17
-		$action_id = as_schedule_single_action( time(), __METHOD__ );
18
-		$logger    = ActionScheduler::logger();
19
-		$message   = 'Logging that something happened';
20
-		$log_id    = $logger->log( $action_id, $message );
21
-		$entry     = $logger->get_entry( $log_id );
22
-
23
-		$this->assertEquals( $action_id, $entry->get_action_id() );
24
-		$this->assertEquals( $message, $entry->get_message() );
25
-	}
26
-
27
-	public function test_storage_logs() {
28
-		$action_id = as_schedule_single_action( time(), __METHOD__ );
29
-		$logger    = ActionScheduler::logger();
30
-		$logs      = $logger->get_logs( $action_id );
31
-		$expected  = new ActionScheduler_LogEntry( $action_id, 'action created' );
32
-		$this->assertCount( 1, $logs );
33
-		$this->assertEquals( $expected->get_action_id(), $logs[0]->get_action_id() );
34
-		$this->assertEquals( $expected->get_message(), $logs[0]->get_message() );
35
-	}
36
-
37
-	public function test_execution_logs() {
38
-		$action_id = as_schedule_single_action( time(), ActionScheduler_Callbacks::HOOK_WITH_CALLBACK );
39
-		$logger    = ActionScheduler::logger();
40
-		$started   = new ActionScheduler_LogEntry( $action_id, 'action started via Unit Tests' );
41
-		$finished  = new ActionScheduler_LogEntry( $action_id, 'action complete via Unit Tests' );
42
-
43
-		$runner = ActionScheduler_Mocker::get_queue_runner();
44
-		$runner->run( 'Unit Tests' );
45
-
46
-		// Expect 3 logs with the correct action ID.
47
-		$logs = $logger->get_logs( $action_id );
48
-		$this->assertCount( 3, $logs );
49
-		foreach ( $logs as $log ) {
50
-			$this->assertEquals( $action_id, $log->get_action_id() );
51
-		}
52
-
53
-		// Expect created, then started, then completed.
54
-		$this->assertEquals( 'action created', $logs[0]->get_message() );
55
-		$this->assertEquals( $started->get_message(), $logs[1]->get_message() );
56
-		$this->assertEquals( $finished->get_message(), $logs[2]->get_message() );
57
-	}
58
-
59
-	public function test_failed_execution_logs() {
60
-		$hook = __METHOD__;
61
-		add_action( $hook, array( $this, '_a_hook_callback_that_throws_an_exception' ) );
62
-		$action_id = as_schedule_single_action( time(), $hook );
63
-		$logger    = ActionScheduler::logger();
64
-		$started   = new ActionScheduler_LogEntry( $action_id, 'action started via Unit Tests' );
65
-		$finished  = new ActionScheduler_LogEntry( $action_id, 'action complete via Unit Tests' );
66
-		$failed    = new ActionScheduler_LogEntry( $action_id, 'action failed via Unit Tests: Execution failed' );
67
-
68
-		$runner = ActionScheduler_Mocker::get_queue_runner();
69
-		$runner->run( 'Unit Tests' );
70
-
71
-		// Expect 3 logs with the correct action ID.
72
-		$logs = $logger->get_logs( $action_id );
73
-		$this->assertCount( 3, $logs );
74
-		foreach ( $logs as $log ) {
75
-			$this->assertEquals( $action_id, $log->get_action_id() );
76
-			$this->assertNotEquals( $finished->get_message(), $log->get_message() );
77
-		}
78
-
79
-		// Expect created, then started, then failed.
80
-		$this->assertEquals( 'action created', $logs[0]->get_message() );
81
-		$this->assertEquals( $started->get_message(), $logs[1]->get_message() );
82
-		$this->assertEquals( $failed->get_message(), $logs[2]->get_message() );
83
-	}
84
-
85
-	public function test_fatal_error_log() {
86
-		$action_id = as_schedule_single_action( time(), __METHOD__ );
87
-		$logger    = ActionScheduler::logger();
88
-		do_action(
89
-			'action_scheduler_unexpected_shutdown',
90
-			$action_id,
91
-			array(
92
-				'type'    => E_ERROR,
93
-				'message' => 'Test error',
94
-				'file'    => __FILE__,
95
-				'line'    => __LINE__,
96
-			)
97
-		);
98
-
99
-		$logs      = $logger->get_logs( $action_id );
100
-		$found_log = false;
101
-		foreach ( $logs as $l ) {
102
-			if ( strpos( $l->get_message(), 'unexpected shutdown' ) === 0 ) {
103
-				$found_log = true;
104
-			}
105
-		}
106
-		$this->assertTrue( $found_log, 'Unexpected shutdown log not found' );
107
-	}
108
-
109
-	public function test_canceled_action_log() {
110
-		$action_id = as_schedule_single_action( time(), __METHOD__ );
111
-		as_unschedule_action( __METHOD__ );
112
-		$logger   = ActionScheduler::logger();
113
-		$logs     = $logger->get_logs( $action_id );
114
-		$expected = new ActionScheduler_LogEntry( $action_id, 'action canceled' );
115
-		$this->assertEquals( $expected->get_message(), end( $logs )->get_message() );
116
-	}
117
-
118
-	public function test_deleted_action_cleanup() {
119
-		$time      = as_get_datetime_object( '-10 minutes' );
120
-		$schedule  = new \ActionScheduler_SimpleSchedule( $time );
121
-		$action    = new \ActionScheduler_Action( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK, array(), $schedule );
122
-		$store     = new ActionScheduler_DBStore();
123
-		$action_id = $store->save_action( $action );
124
-
125
-		$logger = new ActionScheduler_DBLogger();
126
-		$logs   = $logger->get_logs( $action_id );
127
-		$this->assertNotEmpty( $logs );
128
-
129
-		$store->delete_action( $action_id );
130
-		$logs = $logger->get_logs( $action_id );
131
-		$this->assertEmpty( $logs );
132
-	}
133
-
134
-	public function _a_hook_callback_that_throws_an_exception() {
135
-		throw new \RuntimeException( 'Execution failed' );
136
-	}
10
+    public function test_default_logger() {
11
+        $logger = ActionScheduler::logger();
12
+        $this->assertInstanceOf( 'ActionScheduler_Logger', $logger );
13
+        $this->assertInstanceOf( ActionScheduler_DBLogger::class, $logger );
14
+    }
15
+
16
+    public function test_add_log_entry() {
17
+        $action_id = as_schedule_single_action( time(), __METHOD__ );
18
+        $logger    = ActionScheduler::logger();
19
+        $message   = 'Logging that something happened';
20
+        $log_id    = $logger->log( $action_id, $message );
21
+        $entry     = $logger->get_entry( $log_id );
22
+
23
+        $this->assertEquals( $action_id, $entry->get_action_id() );
24
+        $this->assertEquals( $message, $entry->get_message() );
25
+    }
26
+
27
+    public function test_storage_logs() {
28
+        $action_id = as_schedule_single_action( time(), __METHOD__ );
29
+        $logger    = ActionScheduler::logger();
30
+        $logs      = $logger->get_logs( $action_id );
31
+        $expected  = new ActionScheduler_LogEntry( $action_id, 'action created' );
32
+        $this->assertCount( 1, $logs );
33
+        $this->assertEquals( $expected->get_action_id(), $logs[0]->get_action_id() );
34
+        $this->assertEquals( $expected->get_message(), $logs[0]->get_message() );
35
+    }
36
+
37
+    public function test_execution_logs() {
38
+        $action_id = as_schedule_single_action( time(), ActionScheduler_Callbacks::HOOK_WITH_CALLBACK );
39
+        $logger    = ActionScheduler::logger();
40
+        $started   = new ActionScheduler_LogEntry( $action_id, 'action started via Unit Tests' );
41
+        $finished  = new ActionScheduler_LogEntry( $action_id, 'action complete via Unit Tests' );
42
+
43
+        $runner = ActionScheduler_Mocker::get_queue_runner();
44
+        $runner->run( 'Unit Tests' );
45
+
46
+        // Expect 3 logs with the correct action ID.
47
+        $logs = $logger->get_logs( $action_id );
48
+        $this->assertCount( 3, $logs );
49
+        foreach ( $logs as $log ) {
50
+            $this->assertEquals( $action_id, $log->get_action_id() );
51
+        }
52
+
53
+        // Expect created, then started, then completed.
54
+        $this->assertEquals( 'action created', $logs[0]->get_message() );
55
+        $this->assertEquals( $started->get_message(), $logs[1]->get_message() );
56
+        $this->assertEquals( $finished->get_message(), $logs[2]->get_message() );
57
+    }
58
+
59
+    public function test_failed_execution_logs() {
60
+        $hook = __METHOD__;
61
+        add_action( $hook, array( $this, '_a_hook_callback_that_throws_an_exception' ) );
62
+        $action_id = as_schedule_single_action( time(), $hook );
63
+        $logger    = ActionScheduler::logger();
64
+        $started   = new ActionScheduler_LogEntry( $action_id, 'action started via Unit Tests' );
65
+        $finished  = new ActionScheduler_LogEntry( $action_id, 'action complete via Unit Tests' );
66
+        $failed    = new ActionScheduler_LogEntry( $action_id, 'action failed via Unit Tests: Execution failed' );
67
+
68
+        $runner = ActionScheduler_Mocker::get_queue_runner();
69
+        $runner->run( 'Unit Tests' );
70
+
71
+        // Expect 3 logs with the correct action ID.
72
+        $logs = $logger->get_logs( $action_id );
73
+        $this->assertCount( 3, $logs );
74
+        foreach ( $logs as $log ) {
75
+            $this->assertEquals( $action_id, $log->get_action_id() );
76
+            $this->assertNotEquals( $finished->get_message(), $log->get_message() );
77
+        }
78
+
79
+        // Expect created, then started, then failed.
80
+        $this->assertEquals( 'action created', $logs[0]->get_message() );
81
+        $this->assertEquals( $started->get_message(), $logs[1]->get_message() );
82
+        $this->assertEquals( $failed->get_message(), $logs[2]->get_message() );
83
+    }
84
+
85
+    public function test_fatal_error_log() {
86
+        $action_id = as_schedule_single_action( time(), __METHOD__ );
87
+        $logger    = ActionScheduler::logger();
88
+        do_action(
89
+            'action_scheduler_unexpected_shutdown',
90
+            $action_id,
91
+            array(
92
+                'type'    => E_ERROR,
93
+                'message' => 'Test error',
94
+                'file'    => __FILE__,
95
+                'line'    => __LINE__,
96
+            )
97
+        );
98
+
99
+        $logs      = $logger->get_logs( $action_id );
100
+        $found_log = false;
101
+        foreach ( $logs as $l ) {
102
+            if ( strpos( $l->get_message(), 'unexpected shutdown' ) === 0 ) {
103
+                $found_log = true;
104
+            }
105
+        }
106
+        $this->assertTrue( $found_log, 'Unexpected shutdown log not found' );
107
+    }
108
+
109
+    public function test_canceled_action_log() {
110
+        $action_id = as_schedule_single_action( time(), __METHOD__ );
111
+        as_unschedule_action( __METHOD__ );
112
+        $logger   = ActionScheduler::logger();
113
+        $logs     = $logger->get_logs( $action_id );
114
+        $expected = new ActionScheduler_LogEntry( $action_id, 'action canceled' );
115
+        $this->assertEquals( $expected->get_message(), end( $logs )->get_message() );
116
+    }
117
+
118
+    public function test_deleted_action_cleanup() {
119
+        $time      = as_get_datetime_object( '-10 minutes' );
120
+        $schedule  = new \ActionScheduler_SimpleSchedule( $time );
121
+        $action    = new \ActionScheduler_Action( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK, array(), $schedule );
122
+        $store     = new ActionScheduler_DBStore();
123
+        $action_id = $store->save_action( $action );
124
+
125
+        $logger = new ActionScheduler_DBLogger();
126
+        $logs   = $logger->get_logs( $action_id );
127
+        $this->assertNotEmpty( $logs );
128
+
129
+        $store->delete_action( $action_id );
130
+        $logs = $logger->get_logs( $action_id );
131
+        $this->assertEmpty( $logs );
132
+    }
133
+
134
+    public function _a_hook_callback_that_throws_an_exception() {
135
+        throw new \RuntimeException( 'Execution failed' );
136
+    }
137 137
 }
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -9,81 +9,81 @@  discard block
 block discarded – undo
9 9
 class ActionScheduler_DBLogger_Test extends ActionScheduler_UnitTestCase {
10 10
 	public function test_default_logger() {
11 11
 		$logger = ActionScheduler::logger();
12
-		$this->assertInstanceOf( 'ActionScheduler_Logger', $logger );
13
-		$this->assertInstanceOf( ActionScheduler_DBLogger::class, $logger );
12
+		$this->assertInstanceOf('ActionScheduler_Logger', $logger);
13
+		$this->assertInstanceOf(ActionScheduler_DBLogger::class, $logger);
14 14
 	}
15 15
 
16 16
 	public function test_add_log_entry() {
17
-		$action_id = as_schedule_single_action( time(), __METHOD__ );
17
+		$action_id = as_schedule_single_action(time(), __METHOD__);
18 18
 		$logger    = ActionScheduler::logger();
19 19
 		$message   = 'Logging that something happened';
20
-		$log_id    = $logger->log( $action_id, $message );
21
-		$entry     = $logger->get_entry( $log_id );
20
+		$log_id    = $logger->log($action_id, $message);
21
+		$entry     = $logger->get_entry($log_id);
22 22
 
23
-		$this->assertEquals( $action_id, $entry->get_action_id() );
24
-		$this->assertEquals( $message, $entry->get_message() );
23
+		$this->assertEquals($action_id, $entry->get_action_id());
24
+		$this->assertEquals($message, $entry->get_message());
25 25
 	}
26 26
 
27 27
 	public function test_storage_logs() {
28
-		$action_id = as_schedule_single_action( time(), __METHOD__ );
28
+		$action_id = as_schedule_single_action(time(), __METHOD__);
29 29
 		$logger    = ActionScheduler::logger();
30
-		$logs      = $logger->get_logs( $action_id );
31
-		$expected  = new ActionScheduler_LogEntry( $action_id, 'action created' );
32
-		$this->assertCount( 1, $logs );
33
-		$this->assertEquals( $expected->get_action_id(), $logs[0]->get_action_id() );
34
-		$this->assertEquals( $expected->get_message(), $logs[0]->get_message() );
30
+		$logs      = $logger->get_logs($action_id);
31
+		$expected  = new ActionScheduler_LogEntry($action_id, 'action created');
32
+		$this->assertCount(1, $logs);
33
+		$this->assertEquals($expected->get_action_id(), $logs[0]->get_action_id());
34
+		$this->assertEquals($expected->get_message(), $logs[0]->get_message());
35 35
 	}
36 36
 
37 37
 	public function test_execution_logs() {
38
-		$action_id = as_schedule_single_action( time(), ActionScheduler_Callbacks::HOOK_WITH_CALLBACK );
38
+		$action_id = as_schedule_single_action(time(), ActionScheduler_Callbacks::HOOK_WITH_CALLBACK);
39 39
 		$logger    = ActionScheduler::logger();
40
-		$started   = new ActionScheduler_LogEntry( $action_id, 'action started via Unit Tests' );
41
-		$finished  = new ActionScheduler_LogEntry( $action_id, 'action complete via Unit Tests' );
40
+		$started   = new ActionScheduler_LogEntry($action_id, 'action started via Unit Tests');
41
+		$finished  = new ActionScheduler_LogEntry($action_id, 'action complete via Unit Tests');
42 42
 
43 43
 		$runner = ActionScheduler_Mocker::get_queue_runner();
44
-		$runner->run( 'Unit Tests' );
44
+		$runner->run('Unit Tests');
45 45
 
46 46
 		// Expect 3 logs with the correct action ID.
47
-		$logs = $logger->get_logs( $action_id );
48
-		$this->assertCount( 3, $logs );
49
-		foreach ( $logs as $log ) {
50
-			$this->assertEquals( $action_id, $log->get_action_id() );
47
+		$logs = $logger->get_logs($action_id);
48
+		$this->assertCount(3, $logs);
49
+		foreach ($logs as $log) {
50
+			$this->assertEquals($action_id, $log->get_action_id());
51 51
 		}
52 52
 
53 53
 		// Expect created, then started, then completed.
54
-		$this->assertEquals( 'action created', $logs[0]->get_message() );
55
-		$this->assertEquals( $started->get_message(), $logs[1]->get_message() );
56
-		$this->assertEquals( $finished->get_message(), $logs[2]->get_message() );
54
+		$this->assertEquals('action created', $logs[0]->get_message());
55
+		$this->assertEquals($started->get_message(), $logs[1]->get_message());
56
+		$this->assertEquals($finished->get_message(), $logs[2]->get_message());
57 57
 	}
58 58
 
59 59
 	public function test_failed_execution_logs() {
60 60
 		$hook = __METHOD__;
61
-		add_action( $hook, array( $this, '_a_hook_callback_that_throws_an_exception' ) );
62
-		$action_id = as_schedule_single_action( time(), $hook );
61
+		add_action($hook, array($this, '_a_hook_callback_that_throws_an_exception'));
62
+		$action_id = as_schedule_single_action(time(), $hook);
63 63
 		$logger    = ActionScheduler::logger();
64
-		$started   = new ActionScheduler_LogEntry( $action_id, 'action started via Unit Tests' );
65
-		$finished  = new ActionScheduler_LogEntry( $action_id, 'action complete via Unit Tests' );
66
-		$failed    = new ActionScheduler_LogEntry( $action_id, 'action failed via Unit Tests: Execution failed' );
64
+		$started   = new ActionScheduler_LogEntry($action_id, 'action started via Unit Tests');
65
+		$finished  = new ActionScheduler_LogEntry($action_id, 'action complete via Unit Tests');
66
+		$failed    = new ActionScheduler_LogEntry($action_id, 'action failed via Unit Tests: Execution failed');
67 67
 
68 68
 		$runner = ActionScheduler_Mocker::get_queue_runner();
69
-		$runner->run( 'Unit Tests' );
69
+		$runner->run('Unit Tests');
70 70
 
71 71
 		// Expect 3 logs with the correct action ID.
72
-		$logs = $logger->get_logs( $action_id );
73
-		$this->assertCount( 3, $logs );
74
-		foreach ( $logs as $log ) {
75
-			$this->assertEquals( $action_id, $log->get_action_id() );
76
-			$this->assertNotEquals( $finished->get_message(), $log->get_message() );
72
+		$logs = $logger->get_logs($action_id);
73
+		$this->assertCount(3, $logs);
74
+		foreach ($logs as $log) {
75
+			$this->assertEquals($action_id, $log->get_action_id());
76
+			$this->assertNotEquals($finished->get_message(), $log->get_message());
77 77
 		}
78 78
 
79 79
 		// Expect created, then started, then failed.
80
-		$this->assertEquals( 'action created', $logs[0]->get_message() );
81
-		$this->assertEquals( $started->get_message(), $logs[1]->get_message() );
82
-		$this->assertEquals( $failed->get_message(), $logs[2]->get_message() );
80
+		$this->assertEquals('action created', $logs[0]->get_message());
81
+		$this->assertEquals($started->get_message(), $logs[1]->get_message());
82
+		$this->assertEquals($failed->get_message(), $logs[2]->get_message());
83 83
 	}
84 84
 
85 85
 	public function test_fatal_error_log() {
86
-		$action_id = as_schedule_single_action( time(), __METHOD__ );
86
+		$action_id = as_schedule_single_action(time(), __METHOD__);
87 87
 		$logger    = ActionScheduler::logger();
88 88
 		do_action(
89 89
 			'action_scheduler_unexpected_shutdown',
@@ -96,42 +96,42 @@  discard block
 block discarded – undo
96 96
 			)
97 97
 		);
98 98
 
99
-		$logs      = $logger->get_logs( $action_id );
99
+		$logs      = $logger->get_logs($action_id);
100 100
 		$found_log = false;
101
-		foreach ( $logs as $l ) {
102
-			if ( strpos( $l->get_message(), 'unexpected shutdown' ) === 0 ) {
101
+		foreach ($logs as $l) {
102
+			if (strpos($l->get_message(), 'unexpected shutdown') === 0) {
103 103
 				$found_log = true;
104 104
 			}
105 105
 		}
106
-		$this->assertTrue( $found_log, 'Unexpected shutdown log not found' );
106
+		$this->assertTrue($found_log, 'Unexpected shutdown log not found');
107 107
 	}
108 108
 
109 109
 	public function test_canceled_action_log() {
110
-		$action_id = as_schedule_single_action( time(), __METHOD__ );
111
-		as_unschedule_action( __METHOD__ );
110
+		$action_id = as_schedule_single_action(time(), __METHOD__);
111
+		as_unschedule_action(__METHOD__);
112 112
 		$logger   = ActionScheduler::logger();
113
-		$logs     = $logger->get_logs( $action_id );
114
-		$expected = new ActionScheduler_LogEntry( $action_id, 'action canceled' );
115
-		$this->assertEquals( $expected->get_message(), end( $logs )->get_message() );
113
+		$logs     = $logger->get_logs($action_id);
114
+		$expected = new ActionScheduler_LogEntry($action_id, 'action canceled');
115
+		$this->assertEquals($expected->get_message(), end($logs)->get_message());
116 116
 	}
117 117
 
118 118
 	public function test_deleted_action_cleanup() {
119
-		$time      = as_get_datetime_object( '-10 minutes' );
120
-		$schedule  = new \ActionScheduler_SimpleSchedule( $time );
121
-		$action    = new \ActionScheduler_Action( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK, array(), $schedule );
119
+		$time      = as_get_datetime_object('-10 minutes');
120
+		$schedule  = new \ActionScheduler_SimpleSchedule($time);
121
+		$action    = new \ActionScheduler_Action(ActionScheduler_Callbacks::HOOK_WITH_CALLBACK, array(), $schedule);
122 122
 		$store     = new ActionScheduler_DBStore();
123
-		$action_id = $store->save_action( $action );
123
+		$action_id = $store->save_action($action);
124 124
 
125 125
 		$logger = new ActionScheduler_DBLogger();
126
-		$logs   = $logger->get_logs( $action_id );
127
-		$this->assertNotEmpty( $logs );
126
+		$logs   = $logger->get_logs($action_id);
127
+		$this->assertNotEmpty($logs);
128 128
 
129
-		$store->delete_action( $action_id );
130
-		$logs = $logger->get_logs( $action_id );
131
-		$this->assertEmpty( $logs );
129
+		$store->delete_action($action_id);
130
+		$logs = $logger->get_logs($action_id);
131
+		$this->assertEmpty($logs);
132 132
 	}
133 133
 
134 134
 	public function _a_hook_callback_that_throws_an_exception() {
135
-		throw new \RuntimeException( 'Execution failed' );
135
+		throw new \RuntimeException('Execution failed');
136 136
 	}
137 137
 }
Please login to merge, or discard this patch.
tests/phpunit/logging/ActionScheduler_wpCommentLogger_Test.php 2 patches
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -6,224 +6,224 @@
 block discarded – undo
6 6
  * @package test_cases\logging
7 7
  */
8 8
 class ActionScheduler_wpCommentLogger_Test extends ActionScheduler_UnitTestCase {
9
-	private $use_comment_logger;
10
-
11
-	public function test_default_logger() {
12
-		$logger = ActionScheduler::logger();
13
-		$this->assertInstanceOf( 'ActionScheduler_Logger', $logger );
14
-		if ( $this->using_comment_logger() ) {
15
-			$this->assertInstanceOf( 'ActionScheduler_wpCommentLogger', $logger );
16
-		} else {
17
-			$this->assertNotInstanceOf( 'ActionScheduler_wpCommentLogger', $logger );
18
-		}
19
-	}
20
-
21
-	public function test_add_log_entry() {
22
-		$action_id = as_schedule_single_action( time(), 'a hook' );
23
-		$logger    = ActionScheduler::logger();
24
-		$message   = 'Logging that something happened';
25
-		$log_id    = $logger->log( $action_id, $message );
26
-		$entry     = $logger->get_entry( $log_id );
27
-
28
-		$this->assertEquals( $action_id, $entry->get_action_id() );
29
-		$this->assertEquals( $message, $entry->get_message() );
30
-	}
31
-
32
-	public function test_add_log_datetime() {
33
-		$action_id = as_schedule_single_action( time(), 'a hook' );
34
-		$logger    = ActionScheduler::logger();
35
-		$message   = 'Logging that something happened';
36
-		$date      = new DateTime( 'now', new DateTimeZone( 'UTC' ) );
37
-		$log_id    = $logger->log( $action_id, $message, $date );
38
-		$entry     = $logger->get_entry( $log_id );
39
-
40
-		$this->assertEquals( $action_id, $entry->get_action_id() );
41
-		$this->assertEquals( $message, $entry->get_message() );
42
-
43
-		$date   = new ActionScheduler_DateTime( 'now', new DateTimeZone( 'UTC' ) );
44
-		$log_id = $logger->log( $action_id, $message, $date );
45
-		$entry  = $logger->get_entry( $log_id );
46
-
47
-		$this->assertEquals( $action_id, $entry->get_action_id() );
48
-		$this->assertEquals( $message, $entry->get_message() );
49
-	}
50
-
51
-	public function test_erroneous_entry_id() {
52
-		$comment = wp_insert_comment(
53
-			array(
54
-				'comment_post_ID' => 1,
55
-				'comment_author'  => 'test',
56
-				'comment_content' => 'this is not a log entry',
57
-			)
58
-		);
59
-		$logger  = ActionScheduler::logger();
60
-		$entry   = $logger->get_entry( $comment );
61
-		$this->assertSame( '', $entry->get_action_id() );
62
-		$this->assertSame( '', $entry->get_message() );
63
-	}
64
-
65
-	public function test_storage_comments() {
66
-		$action_id = as_schedule_single_action( time(), 'a hook' );
67
-		$logger    = ActionScheduler::logger();
68
-		$logs      = $logger->get_logs( $action_id );
69
-		$expected  = new ActionScheduler_LogEntry( $action_id, 'action created' );
70
-		$this->assertContains( $this->log_entry_to_array( $expected ), $this->log_entry_to_array( $logs ) );
71
-	}
72
-
73
-	protected function log_entry_to_array( $logs ) {
74
-		if ( $logs instanceof ActionScheduler_LogEntry ) {
75
-			return array(
76
-				'action_id' => $logs->get_action_id(),
77
-				'message'   => $logs->get_message(),
78
-			);
79
-		}
80
-
81
-		foreach ( $logs as $id => $log ) {
82
-			$logs[ $id ] = array(
83
-				'action_id' => $log->get_action_id(),
84
-				'message'   => $log->get_message(),
85
-			);
86
-		}
87
-
88
-		return $logs;
89
-	}
90
-
91
-	public function test_execution_comments() {
92
-		$action_id = as_schedule_single_action( time(), ActionScheduler_Callbacks::HOOK_WITH_CALLBACK );
93
-		$logger    = ActionScheduler::logger();
94
-		$started   = new ActionScheduler_LogEntry( $action_id, 'action started via Unit Tests' );
95
-		$finished  = new ActionScheduler_LogEntry( $action_id, 'action complete via Unit Tests' );
96
-
97
-		$runner = ActionScheduler_Mocker::get_queue_runner();
98
-		$runner->run( 'Unit Tests' );
99
-
100
-		$logs = $logger->get_logs( $action_id );
101
-		$this->assertContains( $this->log_entry_to_array( $started ), $this->log_entry_to_array( $logs ) );
102
-		$this->assertContains( $this->log_entry_to_array( $finished ), $this->log_entry_to_array( $logs ) );
103
-	}
104
-
105
-	public function test_failed_execution_comments() {
106
-		$hook = md5( rand() );
107
-		add_action( $hook, array( $this, '_a_hook_callback_that_throws_an_exception' ) );
108
-		$action_id = as_schedule_single_action( time(), $hook );
109
-		$logger    = ActionScheduler::logger();
110
-		$started   = new ActionScheduler_LogEntry( $action_id, 'action started via Unit Tests' );
111
-		$finished  = new ActionScheduler_LogEntry( $action_id, 'action complete via Unit Tests' );
112
-		$failed    = new ActionScheduler_LogEntry( $action_id, 'action failed via Unit Tests: Execution failed' );
113
-
114
-		$runner = ActionScheduler_Mocker::get_queue_runner();
115
-		$runner->run( 'Unit Tests' );
116
-
117
-		$logs = $logger->get_logs( $action_id );
118
-		$this->assertContains( $this->log_entry_to_array( $started ), $this->log_entry_to_array( $logs ) );
119
-		$this->assertNotContains( $this->log_entry_to_array( $finished ), $this->log_entry_to_array( $logs ) );
120
-		$this->assertContains( $this->log_entry_to_array( $failed ), $this->log_entry_to_array( $logs ) );
121
-	}
122
-
123
-	public function test_failed_schedule_next_instance_comments() {
124
-		$action_id = rand();
125
-		$logger    = ActionScheduler::logger();
126
-		$log_entry = new ActionScheduler_LogEntry( $action_id, 'There was a failure scheduling the next instance of this action: Execution failed' );
127
-
128
-		try {
129
-			$this->_a_hook_callback_that_throws_an_exception();
130
-		} catch ( Exception $e ) {
131
-			do_action( 'action_scheduler_failed_to_schedule_next_instance', $action_id, $e, new ActionScheduler_Action( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK ) );
132
-		}
133
-
134
-		$logs = $logger->get_logs( $action_id );
135
-		$this->assertContains( $this->log_entry_to_array( $log_entry ), $this->log_entry_to_array( $logs ) );
136
-	}
137
-
138
-	public function test_fatal_error_comments() {
139
-		$hook      = md5( rand() );
140
-		$action_id = as_schedule_single_action( time(), $hook );
141
-		$logger    = ActionScheduler::logger();
142
-		do_action(
143
-			'action_scheduler_unexpected_shutdown',
144
-			$action_id,
145
-			array(
146
-				'type'    => E_ERROR,
147
-				'message' => 'Test error',
148
-				'file'    => __FILE__,
149
-				'line'    => __LINE__,
150
-			)
151
-		);
152
-
153
-		$logs      = $logger->get_logs( $action_id );
154
-		$found_log = false;
155
-		foreach ( $logs as $l ) {
156
-			if ( strpos( $l->get_message(), 'unexpected shutdown' ) === 0 ) {
157
-				$found_log = true;
158
-			}
159
-		}
160
-		$this->assertTrue( $found_log, 'Unexpected shutdown log not found' );
161
-	}
162
-
163
-	public function test_canceled_action_comments() {
164
-		$action_id = as_schedule_single_action( time(), 'a hook' );
165
-		as_unschedule_action( 'a hook' );
166
-		$logger   = ActionScheduler::logger();
167
-		$logs     = $logger->get_logs( $action_id );
168
-		$expected = new ActionScheduler_LogEntry( $action_id, 'action canceled' );
169
-		$this->assertContains( $this->log_entry_to_array( $expected ), $this->log_entry_to_array( $logs ) );
170
-	}
171
-
172
-	public function _a_hook_callback_that_throws_an_exception() {
173
-		throw new RuntimeException( 'Execution failed' );
174
-	}
175
-
176
-	public function test_filtering_of_get_comments() {
177
-		if ( ! $this->using_comment_logger() ) {
178
-			$this->assertTrue( true );
179
-			return;
180
-		}
181
-
182
-		$post_id    = $this->factory->post->create_object(
183
-			array(
184
-				'post_title' => __FUNCTION__,
185
-			)
186
-		);
187
-		$comment_id = $this->factory->comment->create_object(
188
-			array(
189
-				'comment_post_ID' => $post_id,
190
-				'comment_author'  => __CLASS__,
191
-				'comment_content' => __FUNCTION__,
192
-			)
193
-		);
194
-
195
-		// Verify that we're getting the expected comment before we add logging comments
196
-		$comments = get_comments();
197
-		$this->assertCount( 1, $comments );
198
-		$this->assertEquals( $comment_id, $comments[0]->comment_ID );
199
-
200
-		$action_id = as_schedule_single_action( time(), 'a hook' );
201
-		$logger    = ActionScheduler::logger();
202
-		$message   = 'Logging that something happened';
203
-		$log_id    = $logger->log( $action_id, $message );
204
-
205
-		// Verify that logging comments are excluded from general comment queries
206
-		$comments = get_comments();
207
-		$this->assertCount( 1, $comments );
208
-		$this->assertEquals( $comment_id, $comments[0]->comment_ID );
209
-
210
-		// Verify that logging comments are returned when asking for them specifically
211
-		$comments = get_comments(
212
-			array(
213
-				'type' => ActionScheduler_wpCommentLogger::TYPE,
214
-			)
215
-		);
216
-		// Expecting two: one when the action is created, another when we added our custom log
217
-		$this->assertCount( 2, $comments );
218
-		$this->assertContains( $log_id, wp_list_pluck( $comments, 'comment_ID' ) );
219
-	}
220
-
221
-	private function using_comment_logger() {
222
-		if ( null === $this->use_comment_logger ) {
223
-			$this->use_comment_logger = ! ActionScheduler_DataController::dependencies_met();
224
-		}
225
-
226
-		return $this->use_comment_logger;
227
-	}
9
+    private $use_comment_logger;
10
+
11
+    public function test_default_logger() {
12
+        $logger = ActionScheduler::logger();
13
+        $this->assertInstanceOf( 'ActionScheduler_Logger', $logger );
14
+        if ( $this->using_comment_logger() ) {
15
+            $this->assertInstanceOf( 'ActionScheduler_wpCommentLogger', $logger );
16
+        } else {
17
+            $this->assertNotInstanceOf( 'ActionScheduler_wpCommentLogger', $logger );
18
+        }
19
+    }
20
+
21
+    public function test_add_log_entry() {
22
+        $action_id = as_schedule_single_action( time(), 'a hook' );
23
+        $logger    = ActionScheduler::logger();
24
+        $message   = 'Logging that something happened';
25
+        $log_id    = $logger->log( $action_id, $message );
26
+        $entry     = $logger->get_entry( $log_id );
27
+
28
+        $this->assertEquals( $action_id, $entry->get_action_id() );
29
+        $this->assertEquals( $message, $entry->get_message() );
30
+    }
31
+
32
+    public function test_add_log_datetime() {
33
+        $action_id = as_schedule_single_action( time(), 'a hook' );
34
+        $logger    = ActionScheduler::logger();
35
+        $message   = 'Logging that something happened';
36
+        $date      = new DateTime( 'now', new DateTimeZone( 'UTC' ) );
37
+        $log_id    = $logger->log( $action_id, $message, $date );
38
+        $entry     = $logger->get_entry( $log_id );
39
+
40
+        $this->assertEquals( $action_id, $entry->get_action_id() );
41
+        $this->assertEquals( $message, $entry->get_message() );
42
+
43
+        $date   = new ActionScheduler_DateTime( 'now', new DateTimeZone( 'UTC' ) );
44
+        $log_id = $logger->log( $action_id, $message, $date );
45
+        $entry  = $logger->get_entry( $log_id );
46
+
47
+        $this->assertEquals( $action_id, $entry->get_action_id() );
48
+        $this->assertEquals( $message, $entry->get_message() );
49
+    }
50
+
51
+    public function test_erroneous_entry_id() {
52
+        $comment = wp_insert_comment(
53
+            array(
54
+                'comment_post_ID' => 1,
55
+                'comment_author'  => 'test',
56
+                'comment_content' => 'this is not a log entry',
57
+            )
58
+        );
59
+        $logger  = ActionScheduler::logger();
60
+        $entry   = $logger->get_entry( $comment );
61
+        $this->assertSame( '', $entry->get_action_id() );
62
+        $this->assertSame( '', $entry->get_message() );
63
+    }
64
+
65
+    public function test_storage_comments() {
66
+        $action_id = as_schedule_single_action( time(), 'a hook' );
67
+        $logger    = ActionScheduler::logger();
68
+        $logs      = $logger->get_logs( $action_id );
69
+        $expected  = new ActionScheduler_LogEntry( $action_id, 'action created' );
70
+        $this->assertContains( $this->log_entry_to_array( $expected ), $this->log_entry_to_array( $logs ) );
71
+    }
72
+
73
+    protected function log_entry_to_array( $logs ) {
74
+        if ( $logs instanceof ActionScheduler_LogEntry ) {
75
+            return array(
76
+                'action_id' => $logs->get_action_id(),
77
+                'message'   => $logs->get_message(),
78
+            );
79
+        }
80
+
81
+        foreach ( $logs as $id => $log ) {
82
+            $logs[ $id ] = array(
83
+                'action_id' => $log->get_action_id(),
84
+                'message'   => $log->get_message(),
85
+            );
86
+        }
87
+
88
+        return $logs;
89
+    }
90
+
91
+    public function test_execution_comments() {
92
+        $action_id = as_schedule_single_action( time(), ActionScheduler_Callbacks::HOOK_WITH_CALLBACK );
93
+        $logger    = ActionScheduler::logger();
94
+        $started   = new ActionScheduler_LogEntry( $action_id, 'action started via Unit Tests' );
95
+        $finished  = new ActionScheduler_LogEntry( $action_id, 'action complete via Unit Tests' );
96
+
97
+        $runner = ActionScheduler_Mocker::get_queue_runner();
98
+        $runner->run( 'Unit Tests' );
99
+
100
+        $logs = $logger->get_logs( $action_id );
101
+        $this->assertContains( $this->log_entry_to_array( $started ), $this->log_entry_to_array( $logs ) );
102
+        $this->assertContains( $this->log_entry_to_array( $finished ), $this->log_entry_to_array( $logs ) );
103
+    }
104
+
105
+    public function test_failed_execution_comments() {
106
+        $hook = md5( rand() );
107
+        add_action( $hook, array( $this, '_a_hook_callback_that_throws_an_exception' ) );
108
+        $action_id = as_schedule_single_action( time(), $hook );
109
+        $logger    = ActionScheduler::logger();
110
+        $started   = new ActionScheduler_LogEntry( $action_id, 'action started via Unit Tests' );
111
+        $finished  = new ActionScheduler_LogEntry( $action_id, 'action complete via Unit Tests' );
112
+        $failed    = new ActionScheduler_LogEntry( $action_id, 'action failed via Unit Tests: Execution failed' );
113
+
114
+        $runner = ActionScheduler_Mocker::get_queue_runner();
115
+        $runner->run( 'Unit Tests' );
116
+
117
+        $logs = $logger->get_logs( $action_id );
118
+        $this->assertContains( $this->log_entry_to_array( $started ), $this->log_entry_to_array( $logs ) );
119
+        $this->assertNotContains( $this->log_entry_to_array( $finished ), $this->log_entry_to_array( $logs ) );
120
+        $this->assertContains( $this->log_entry_to_array( $failed ), $this->log_entry_to_array( $logs ) );
121
+    }
122
+
123
+    public function test_failed_schedule_next_instance_comments() {
124
+        $action_id = rand();
125
+        $logger    = ActionScheduler::logger();
126
+        $log_entry = new ActionScheduler_LogEntry( $action_id, 'There was a failure scheduling the next instance of this action: Execution failed' );
127
+
128
+        try {
129
+            $this->_a_hook_callback_that_throws_an_exception();
130
+        } catch ( Exception $e ) {
131
+            do_action( 'action_scheduler_failed_to_schedule_next_instance', $action_id, $e, new ActionScheduler_Action( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK ) );
132
+        }
133
+
134
+        $logs = $logger->get_logs( $action_id );
135
+        $this->assertContains( $this->log_entry_to_array( $log_entry ), $this->log_entry_to_array( $logs ) );
136
+    }
137
+
138
+    public function test_fatal_error_comments() {
139
+        $hook      = md5( rand() );
140
+        $action_id = as_schedule_single_action( time(), $hook );
141
+        $logger    = ActionScheduler::logger();
142
+        do_action(
143
+            'action_scheduler_unexpected_shutdown',
144
+            $action_id,
145
+            array(
146
+                'type'    => E_ERROR,
147
+                'message' => 'Test error',
148
+                'file'    => __FILE__,
149
+                'line'    => __LINE__,
150
+            )
151
+        );
152
+
153
+        $logs      = $logger->get_logs( $action_id );
154
+        $found_log = false;
155
+        foreach ( $logs as $l ) {
156
+            if ( strpos( $l->get_message(), 'unexpected shutdown' ) === 0 ) {
157
+                $found_log = true;
158
+            }
159
+        }
160
+        $this->assertTrue( $found_log, 'Unexpected shutdown log not found' );
161
+    }
162
+
163
+    public function test_canceled_action_comments() {
164
+        $action_id = as_schedule_single_action( time(), 'a hook' );
165
+        as_unschedule_action( 'a hook' );
166
+        $logger   = ActionScheduler::logger();
167
+        $logs     = $logger->get_logs( $action_id );
168
+        $expected = new ActionScheduler_LogEntry( $action_id, 'action canceled' );
169
+        $this->assertContains( $this->log_entry_to_array( $expected ), $this->log_entry_to_array( $logs ) );
170
+    }
171
+
172
+    public function _a_hook_callback_that_throws_an_exception() {
173
+        throw new RuntimeException( 'Execution failed' );
174
+    }
175
+
176
+    public function test_filtering_of_get_comments() {
177
+        if ( ! $this->using_comment_logger() ) {
178
+            $this->assertTrue( true );
179
+            return;
180
+        }
181
+
182
+        $post_id    = $this->factory->post->create_object(
183
+            array(
184
+                'post_title' => __FUNCTION__,
185
+            )
186
+        );
187
+        $comment_id = $this->factory->comment->create_object(
188
+            array(
189
+                'comment_post_ID' => $post_id,
190
+                'comment_author'  => __CLASS__,
191
+                'comment_content' => __FUNCTION__,
192
+            )
193
+        );
194
+
195
+        // Verify that we're getting the expected comment before we add logging comments
196
+        $comments = get_comments();
197
+        $this->assertCount( 1, $comments );
198
+        $this->assertEquals( $comment_id, $comments[0]->comment_ID );
199
+
200
+        $action_id = as_schedule_single_action( time(), 'a hook' );
201
+        $logger    = ActionScheduler::logger();
202
+        $message   = 'Logging that something happened';
203
+        $log_id    = $logger->log( $action_id, $message );
204
+
205
+        // Verify that logging comments are excluded from general comment queries
206
+        $comments = get_comments();
207
+        $this->assertCount( 1, $comments );
208
+        $this->assertEquals( $comment_id, $comments[0]->comment_ID );
209
+
210
+        // Verify that logging comments are returned when asking for them specifically
211
+        $comments = get_comments(
212
+            array(
213
+                'type' => ActionScheduler_wpCommentLogger::TYPE,
214
+            )
215
+        );
216
+        // Expecting two: one when the action is created, another when we added our custom log
217
+        $this->assertCount( 2, $comments );
218
+        $this->assertContains( $log_id, wp_list_pluck( $comments, 'comment_ID' ) );
219
+    }
220
+
221
+    private function using_comment_logger() {
222
+        if ( null === $this->use_comment_logger ) {
223
+            $this->use_comment_logger = ! ActionScheduler_DataController::dependencies_met();
224
+        }
225
+
226
+        return $this->use_comment_logger;
227
+    }
228 228
 }
229 229
 
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -10,42 +10,42 @@  discard block
 block discarded – undo
10 10
 
11 11
 	public function test_default_logger() {
12 12
 		$logger = ActionScheduler::logger();
13
-		$this->assertInstanceOf( 'ActionScheduler_Logger', $logger );
14
-		if ( $this->using_comment_logger() ) {
15
-			$this->assertInstanceOf( 'ActionScheduler_wpCommentLogger', $logger );
13
+		$this->assertInstanceOf('ActionScheduler_Logger', $logger);
14
+		if ($this->using_comment_logger()) {
15
+			$this->assertInstanceOf('ActionScheduler_wpCommentLogger', $logger);
16 16
 		} else {
17
-			$this->assertNotInstanceOf( 'ActionScheduler_wpCommentLogger', $logger );
17
+			$this->assertNotInstanceOf('ActionScheduler_wpCommentLogger', $logger);
18 18
 		}
19 19
 	}
20 20
 
21 21
 	public function test_add_log_entry() {
22
-		$action_id = as_schedule_single_action( time(), 'a hook' );
22
+		$action_id = as_schedule_single_action(time(), 'a hook');
23 23
 		$logger    = ActionScheduler::logger();
24 24
 		$message   = 'Logging that something happened';
25
-		$log_id    = $logger->log( $action_id, $message );
26
-		$entry     = $logger->get_entry( $log_id );
25
+		$log_id    = $logger->log($action_id, $message);
26
+		$entry     = $logger->get_entry($log_id);
27 27
 
28
-		$this->assertEquals( $action_id, $entry->get_action_id() );
29
-		$this->assertEquals( $message, $entry->get_message() );
28
+		$this->assertEquals($action_id, $entry->get_action_id());
29
+		$this->assertEquals($message, $entry->get_message());
30 30
 	}
31 31
 
32 32
 	public function test_add_log_datetime() {
33
-		$action_id = as_schedule_single_action( time(), 'a hook' );
33
+		$action_id = as_schedule_single_action(time(), 'a hook');
34 34
 		$logger    = ActionScheduler::logger();
35 35
 		$message   = 'Logging that something happened';
36
-		$date      = new DateTime( 'now', new DateTimeZone( 'UTC' ) );
37
-		$log_id    = $logger->log( $action_id, $message, $date );
38
-		$entry     = $logger->get_entry( $log_id );
36
+		$date      = new DateTime('now', new DateTimeZone('UTC'));
37
+		$log_id    = $logger->log($action_id, $message, $date);
38
+		$entry     = $logger->get_entry($log_id);
39 39
 
40
-		$this->assertEquals( $action_id, $entry->get_action_id() );
41
-		$this->assertEquals( $message, $entry->get_message() );
40
+		$this->assertEquals($action_id, $entry->get_action_id());
41
+		$this->assertEquals($message, $entry->get_message());
42 42
 
43
-		$date   = new ActionScheduler_DateTime( 'now', new DateTimeZone( 'UTC' ) );
44
-		$log_id = $logger->log( $action_id, $message, $date );
45
-		$entry  = $logger->get_entry( $log_id );
43
+		$date   = new ActionScheduler_DateTime('now', new DateTimeZone('UTC'));
44
+		$log_id = $logger->log($action_id, $message, $date);
45
+		$entry  = $logger->get_entry($log_id);
46 46
 
47
-		$this->assertEquals( $action_id, $entry->get_action_id() );
48
-		$this->assertEquals( $message, $entry->get_message() );
47
+		$this->assertEquals($action_id, $entry->get_action_id());
48
+		$this->assertEquals($message, $entry->get_message());
49 49
 	}
50 50
 
51 51
 	public function test_erroneous_entry_id() {
@@ -57,29 +57,29 @@  discard block
 block discarded – undo
57 57
 			)
58 58
 		);
59 59
 		$logger  = ActionScheduler::logger();
60
-		$entry   = $logger->get_entry( $comment );
61
-		$this->assertSame( '', $entry->get_action_id() );
62
-		$this->assertSame( '', $entry->get_message() );
60
+		$entry   = $logger->get_entry($comment);
61
+		$this->assertSame('', $entry->get_action_id());
62
+		$this->assertSame('', $entry->get_message());
63 63
 	}
64 64
 
65 65
 	public function test_storage_comments() {
66
-		$action_id = as_schedule_single_action( time(), 'a hook' );
66
+		$action_id = as_schedule_single_action(time(), 'a hook');
67 67
 		$logger    = ActionScheduler::logger();
68
-		$logs      = $logger->get_logs( $action_id );
69
-		$expected  = new ActionScheduler_LogEntry( $action_id, 'action created' );
70
-		$this->assertContains( $this->log_entry_to_array( $expected ), $this->log_entry_to_array( $logs ) );
68
+		$logs      = $logger->get_logs($action_id);
69
+		$expected  = new ActionScheduler_LogEntry($action_id, 'action created');
70
+		$this->assertContains($this->log_entry_to_array($expected), $this->log_entry_to_array($logs));
71 71
 	}
72 72
 
73
-	protected function log_entry_to_array( $logs ) {
74
-		if ( $logs instanceof ActionScheduler_LogEntry ) {
73
+	protected function log_entry_to_array($logs) {
74
+		if ($logs instanceof ActionScheduler_LogEntry) {
75 75
 			return array(
76 76
 				'action_id' => $logs->get_action_id(),
77 77
 				'message'   => $logs->get_message(),
78 78
 			);
79 79
 		}
80 80
 
81
-		foreach ( $logs as $id => $log ) {
82
-			$logs[ $id ] = array(
81
+		foreach ($logs as $id => $log) {
82
+			$logs[$id] = array(
83 83
 				'action_id' => $log->get_action_id(),
84 84
 				'message'   => $log->get_message(),
85 85
 			);
@@ -89,55 +89,55 @@  discard block
 block discarded – undo
89 89
 	}
90 90
 
91 91
 	public function test_execution_comments() {
92
-		$action_id = as_schedule_single_action( time(), ActionScheduler_Callbacks::HOOK_WITH_CALLBACK );
92
+		$action_id = as_schedule_single_action(time(), ActionScheduler_Callbacks::HOOK_WITH_CALLBACK);
93 93
 		$logger    = ActionScheduler::logger();
94
-		$started   = new ActionScheduler_LogEntry( $action_id, 'action started via Unit Tests' );
95
-		$finished  = new ActionScheduler_LogEntry( $action_id, 'action complete via Unit Tests' );
94
+		$started   = new ActionScheduler_LogEntry($action_id, 'action started via Unit Tests');
95
+		$finished  = new ActionScheduler_LogEntry($action_id, 'action complete via Unit Tests');
96 96
 
97 97
 		$runner = ActionScheduler_Mocker::get_queue_runner();
98
-		$runner->run( 'Unit Tests' );
98
+		$runner->run('Unit Tests');
99 99
 
100
-		$logs = $logger->get_logs( $action_id );
101
-		$this->assertContains( $this->log_entry_to_array( $started ), $this->log_entry_to_array( $logs ) );
102
-		$this->assertContains( $this->log_entry_to_array( $finished ), $this->log_entry_to_array( $logs ) );
100
+		$logs = $logger->get_logs($action_id);
101
+		$this->assertContains($this->log_entry_to_array($started), $this->log_entry_to_array($logs));
102
+		$this->assertContains($this->log_entry_to_array($finished), $this->log_entry_to_array($logs));
103 103
 	}
104 104
 
105 105
 	public function test_failed_execution_comments() {
106
-		$hook = md5( rand() );
107
-		add_action( $hook, array( $this, '_a_hook_callback_that_throws_an_exception' ) );
108
-		$action_id = as_schedule_single_action( time(), $hook );
106
+		$hook = md5(rand());
107
+		add_action($hook, array($this, '_a_hook_callback_that_throws_an_exception'));
108
+		$action_id = as_schedule_single_action(time(), $hook);
109 109
 		$logger    = ActionScheduler::logger();
110
-		$started   = new ActionScheduler_LogEntry( $action_id, 'action started via Unit Tests' );
111
-		$finished  = new ActionScheduler_LogEntry( $action_id, 'action complete via Unit Tests' );
112
-		$failed    = new ActionScheduler_LogEntry( $action_id, 'action failed via Unit Tests: Execution failed' );
110
+		$started   = new ActionScheduler_LogEntry($action_id, 'action started via Unit Tests');
111
+		$finished  = new ActionScheduler_LogEntry($action_id, 'action complete via Unit Tests');
112
+		$failed    = new ActionScheduler_LogEntry($action_id, 'action failed via Unit Tests: Execution failed');
113 113
 
114 114
 		$runner = ActionScheduler_Mocker::get_queue_runner();
115
-		$runner->run( 'Unit Tests' );
115
+		$runner->run('Unit Tests');
116 116
 
117
-		$logs = $logger->get_logs( $action_id );
118
-		$this->assertContains( $this->log_entry_to_array( $started ), $this->log_entry_to_array( $logs ) );
119
-		$this->assertNotContains( $this->log_entry_to_array( $finished ), $this->log_entry_to_array( $logs ) );
120
-		$this->assertContains( $this->log_entry_to_array( $failed ), $this->log_entry_to_array( $logs ) );
117
+		$logs = $logger->get_logs($action_id);
118
+		$this->assertContains($this->log_entry_to_array($started), $this->log_entry_to_array($logs));
119
+		$this->assertNotContains($this->log_entry_to_array($finished), $this->log_entry_to_array($logs));
120
+		$this->assertContains($this->log_entry_to_array($failed), $this->log_entry_to_array($logs));
121 121
 	}
122 122
 
123 123
 	public function test_failed_schedule_next_instance_comments() {
124 124
 		$action_id = rand();
125 125
 		$logger    = ActionScheduler::logger();
126
-		$log_entry = new ActionScheduler_LogEntry( $action_id, 'There was a failure scheduling the next instance of this action: Execution failed' );
126
+		$log_entry = new ActionScheduler_LogEntry($action_id, 'There was a failure scheduling the next instance of this action: Execution failed');
127 127
 
128 128
 		try {
129 129
 			$this->_a_hook_callback_that_throws_an_exception();
130
-		} catch ( Exception $e ) {
131
-			do_action( 'action_scheduler_failed_to_schedule_next_instance', $action_id, $e, new ActionScheduler_Action( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK ) );
130
+		} catch (Exception $e) {
131
+			do_action('action_scheduler_failed_to_schedule_next_instance', $action_id, $e, new ActionScheduler_Action(ActionScheduler_Callbacks::HOOK_WITH_CALLBACK));
132 132
 		}
133 133
 
134
-		$logs = $logger->get_logs( $action_id );
135
-		$this->assertContains( $this->log_entry_to_array( $log_entry ), $this->log_entry_to_array( $logs ) );
134
+		$logs = $logger->get_logs($action_id);
135
+		$this->assertContains($this->log_entry_to_array($log_entry), $this->log_entry_to_array($logs));
136 136
 	}
137 137
 
138 138
 	public function test_fatal_error_comments() {
139
-		$hook      = md5( rand() );
140
-		$action_id = as_schedule_single_action( time(), $hook );
139
+		$hook      = md5(rand());
140
+		$action_id = as_schedule_single_action(time(), $hook);
141 141
 		$logger    = ActionScheduler::logger();
142 142
 		do_action(
143 143
 			'action_scheduler_unexpected_shutdown',
@@ -150,36 +150,36 @@  discard block
 block discarded – undo
150 150
 			)
151 151
 		);
152 152
 
153
-		$logs      = $logger->get_logs( $action_id );
153
+		$logs      = $logger->get_logs($action_id);
154 154
 		$found_log = false;
155
-		foreach ( $logs as $l ) {
156
-			if ( strpos( $l->get_message(), 'unexpected shutdown' ) === 0 ) {
155
+		foreach ($logs as $l) {
156
+			if (strpos($l->get_message(), 'unexpected shutdown') === 0) {
157 157
 				$found_log = true;
158 158
 			}
159 159
 		}
160
-		$this->assertTrue( $found_log, 'Unexpected shutdown log not found' );
160
+		$this->assertTrue($found_log, 'Unexpected shutdown log not found');
161 161
 	}
162 162
 
163 163
 	public function test_canceled_action_comments() {
164
-		$action_id = as_schedule_single_action( time(), 'a hook' );
165
-		as_unschedule_action( 'a hook' );
164
+		$action_id = as_schedule_single_action(time(), 'a hook');
165
+		as_unschedule_action('a hook');
166 166
 		$logger   = ActionScheduler::logger();
167
-		$logs     = $logger->get_logs( $action_id );
168
-		$expected = new ActionScheduler_LogEntry( $action_id, 'action canceled' );
169
-		$this->assertContains( $this->log_entry_to_array( $expected ), $this->log_entry_to_array( $logs ) );
167
+		$logs     = $logger->get_logs($action_id);
168
+		$expected = new ActionScheduler_LogEntry($action_id, 'action canceled');
169
+		$this->assertContains($this->log_entry_to_array($expected), $this->log_entry_to_array($logs));
170 170
 	}
171 171
 
172 172
 	public function _a_hook_callback_that_throws_an_exception() {
173
-		throw new RuntimeException( 'Execution failed' );
173
+		throw new RuntimeException('Execution failed');
174 174
 	}
175 175
 
176 176
 	public function test_filtering_of_get_comments() {
177
-		if ( ! $this->using_comment_logger() ) {
178
-			$this->assertTrue( true );
177
+		if ( ! $this->using_comment_logger()) {
178
+			$this->assertTrue(true);
179 179
 			return;
180 180
 		}
181 181
 
182
-		$post_id    = $this->factory->post->create_object(
182
+		$post_id = $this->factory->post->create_object(
183 183
 			array(
184 184
 				'post_title' => __FUNCTION__,
185 185
 			)
@@ -194,18 +194,18 @@  discard block
 block discarded – undo
194 194
 
195 195
 		// Verify that we're getting the expected comment before we add logging comments
196 196
 		$comments = get_comments();
197
-		$this->assertCount( 1, $comments );
198
-		$this->assertEquals( $comment_id, $comments[0]->comment_ID );
197
+		$this->assertCount(1, $comments);
198
+		$this->assertEquals($comment_id, $comments[0]->comment_ID);
199 199
 
200
-		$action_id = as_schedule_single_action( time(), 'a hook' );
200
+		$action_id = as_schedule_single_action(time(), 'a hook');
201 201
 		$logger    = ActionScheduler::logger();
202 202
 		$message   = 'Logging that something happened';
203
-		$log_id    = $logger->log( $action_id, $message );
203
+		$log_id    = $logger->log($action_id, $message);
204 204
 
205 205
 		// Verify that logging comments are excluded from general comment queries
206 206
 		$comments = get_comments();
207
-		$this->assertCount( 1, $comments );
208
-		$this->assertEquals( $comment_id, $comments[0]->comment_ID );
207
+		$this->assertCount(1, $comments);
208
+		$this->assertEquals($comment_id, $comments[0]->comment_ID);
209 209
 
210 210
 		// Verify that logging comments are returned when asking for them specifically
211 211
 		$comments = get_comments(
@@ -214,12 +214,12 @@  discard block
 block discarded – undo
214 214
 			)
215 215
 		);
216 216
 		// Expecting two: one when the action is created, another when we added our custom log
217
-		$this->assertCount( 2, $comments );
218
-		$this->assertContains( $log_id, wp_list_pluck( $comments, 'comment_ID' ) );
217
+		$this->assertCount(2, $comments);
218
+		$this->assertContains($log_id, wp_list_pluck($comments, 'comment_ID'));
219 219
 	}
220 220
 
221 221
 	private function using_comment_logger() {
222
-		if ( null === $this->use_comment_logger ) {
222
+		if (null === $this->use_comment_logger) {
223 223
 			$this->use_comment_logger = ! ActionScheduler_DataController::dependencies_met();
224 224
 		}
225 225
 
Please login to merge, or discard this patch.
src/ext/action-scheduler/tests/bootstrap.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -6,13 +6,13 @@  discard block
 block discarded – undo
6 6
 
7 7
 // Check for select constants defined as environment variables
8 8
 foreach ( array( 'WP_CONTENT_DIR', 'WP_CONTENT_URL', 'WP_PLUGIN_DIR', 'WP_PLUGIN_URL', 'WPMU_PLUGIN_DIR' ) as $env_constant ) {
9
-	if ( false !== getenv( $env_constant ) && ! defined( $env_constant ) ) {
10
-		define( $env_constant, getenv( $env_constant ) );
11
-	}
9
+    if ( false !== getenv( $env_constant ) && ! defined( $env_constant ) ) {
10
+        define( $env_constant, getenv( $env_constant ) );
11
+    }
12 12
 }
13 13
 
14 14
 if ( ! defined( 'WP_PLUGIN_DIR' ) ) {
15
-	define( 'WP_PLUGIN_DIR', dirname( dirname( __DIR__ ) ) );
15
+    define( 'WP_PLUGIN_DIR', dirname( dirname( __DIR__ ) ) );
16 16
 }
17 17
 
18 18
 // PHPUnit polyfills as required by the core WP test framework.
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
 require_once dirname( __DIR__ ) . '/action-scheduler.php';
26 26
 
27 27
 if ( class_exists( 'PHPUnit\Framework\TestResult' ) ) { // PHPUnit 6.0 or newer
28
-	include_once('ActionScheduler_UnitTestCase.php';
28
+    include_once('ActionScheduler_UnitTestCase.php';
29 29
 } else {
30
-	include_once('phpunit/deprecated/ActionScheduler_UnitTestCase.php';
30
+    include_once('phpunit/deprecated/ActionScheduler_UnitTestCase.php';
31 31
 }
32 32
 
33 33
 require_once 'phpunit/helpers/ActionScheduler_Callbacks.php';
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -2,29 +2,29 @@
 block discarded – undo
2 2
 
3 3
 $GLOBALS['wp_tests_options']['template']         = 'twentyseventeen';
4 4
 $GLOBALS['wp_tests_options']['stylesheet']       = 'twentyseventeen';
5
-$GLOBALS['wp_tests_options']['active_plugins'][] = basename( dirname( __DIR__ ) ) . '/action-scheduler.php';
5
+$GLOBALS['wp_tests_options']['active_plugins'][] = basename(dirname(__DIR__)).'/action-scheduler.php';
6 6
 
7 7
 // Check for select constants defined as environment variables
8
-foreach ( array( 'WP_CONTENT_DIR', 'WP_CONTENT_URL', 'WP_PLUGIN_DIR', 'WP_PLUGIN_URL', 'WPMU_PLUGIN_DIR' ) as $env_constant ) {
9
-	if ( false !== getenv( $env_constant ) && ! defined( $env_constant ) ) {
10
-		define( $env_constant, getenv( $env_constant ) );
8
+foreach (array('WP_CONTENT_DIR', 'WP_CONTENT_URL', 'WP_PLUGIN_DIR', 'WP_PLUGIN_URL', 'WPMU_PLUGIN_DIR') as $env_constant) {
9
+	if (false !== getenv($env_constant) && ! defined($env_constant)) {
10
+		define($env_constant, getenv($env_constant));
11 11
 	}
12 12
 }
13 13
 
14
-if ( ! defined( 'WP_PLUGIN_DIR' ) ) {
15
-	define( 'WP_PLUGIN_DIR', dirname( dirname( __DIR__ ) ) );
14
+if ( ! defined('WP_PLUGIN_DIR')) {
15
+	define('WP_PLUGIN_DIR', dirname(dirname(__DIR__)));
16 16
 }
17 17
 
18 18
 // PHPUnit polyfills as required by the core WP test framework.
19
-require_once __DIR__ . '/../vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php';
19
+require_once __DIR__.'/../vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php';
20 20
 
21
-$wordpress_tests_dir = getenv( 'WP_TESTS_DIR' ) ? getenv( 'WP_TESTS_DIR' ) : sys_get_temp_dir() . '/wordpress-tests-lib';
22
-require_once $wordpress_tests_dir . '/includes/functions.php';
23
-require $wordpress_tests_dir . '/includes/bootstrap.php';
21
+$wordpress_tests_dir = getenv('WP_TESTS_DIR') ? getenv('WP_TESTS_DIR') : sys_get_temp_dir().'/wordpress-tests-lib';
22
+require_once $wordpress_tests_dir.'/includes/functions.php';
23
+require $wordpress_tests_dir.'/includes/bootstrap.php';
24 24
 
25
-require_once dirname( __DIR__ ) . '/action-scheduler.php';
25
+require_once dirname(__DIR__).'/action-scheduler.php';
26 26
 
27
-if ( class_exists( 'PHPUnit\Framework\TestResult' ) ) { // PHPUnit 6.0 or newer
27
+if (class_exists('PHPUnit\Framework\TestResult')) { // PHPUnit 6.0 or newer
28 28
 	include_once('ActionScheduler_UnitTestCase.php';
29 29
 } else {
30 30
 	include_once('phpunit/deprecated/ActionScheduler_UnitTestCase.php';
Please login to merge, or discard this patch.
src/ext/action-scheduler/tests/ActionScheduler_UnitTestCase.php 2 patches
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -5,56 +5,56 @@
 block discarded – undo
5 5
  */
6 6
 class ActionScheduler_UnitTestCase extends WP_UnitTestCase {
7 7
 
8
-	protected $existing_timezone;
9
-
10
-	/**
11
-	 * Perform test set-up work.
12
-	 */
13
-	public function set_up() {
14
-		ActionScheduler_Callbacks::add_callbacks();
15
-		parent::set_up();
16
-	}
17
-
18
-	/**
19
-	 * Perform test tear-down work.
20
-	 */
21
-	public function tear_down() {
22
-		ActionScheduler_Callbacks::remove_callbacks();
23
-		parent::tear_down();
24
-	}
25
-
26
-	/**
27
-	 * Counts the number of test cases executed by run(TestResult result).
28
-	 *
29
-	 * @return int
30
-	 */
31
-	public function count(): int {
32
-		return 'UTC' == date_default_timezone_get() ? 2 : 3;
33
-	}
34
-
35
-	/**
36
-	 * We want to run every test multiple times using a different timezone to make sure
37
-	 * that they are unaffected by changes to PHP's timezone.
38
-	 */
39
-	public function run( PHPUnit\Framework\TestResult $result = null ): \PHPUnit\Framework\TestResult {
40
-
41
-		if ( $result === null ) {
42
-			$result = $this->createResult();
43
-		}
44
-
45
-		if ( 'UTC' != ( $this->existing_timezone = date_default_timezone_get() ) ) {
46
-			date_default_timezone_set( 'UTC' );
47
-			$result->run( $this );
48
-		}
49
-
50
-		date_default_timezone_set( 'Pacific/Fiji' ); // UTC+12
51
-		$result->run( $this );
52
-
53
-		date_default_timezone_set( 'Pacific/Tahiti' ); // UTC-10: it's a magical place
54
-		$result->run( $this );
55
-
56
-		date_default_timezone_set( $this->existing_timezone );
57
-
58
-		return $result;
59
-	}
8
+    protected $existing_timezone;
9
+
10
+    /**
11
+     * Perform test set-up work.
12
+     */
13
+    public function set_up() {
14
+        ActionScheduler_Callbacks::add_callbacks();
15
+        parent::set_up();
16
+    }
17
+
18
+    /**
19
+     * Perform test tear-down work.
20
+     */
21
+    public function tear_down() {
22
+        ActionScheduler_Callbacks::remove_callbacks();
23
+        parent::tear_down();
24
+    }
25
+
26
+    /**
27
+     * Counts the number of test cases executed by run(TestResult result).
28
+     *
29
+     * @return int
30
+     */
31
+    public function count(): int {
32
+        return 'UTC' == date_default_timezone_get() ? 2 : 3;
33
+    }
34
+
35
+    /**
36
+     * We want to run every test multiple times using a different timezone to make sure
37
+     * that they are unaffected by changes to PHP's timezone.
38
+     */
39
+    public function run( PHPUnit\Framework\TestResult $result = null ): \PHPUnit\Framework\TestResult {
40
+
41
+        if ( $result === null ) {
42
+            $result = $this->createResult();
43
+        }
44
+
45
+        if ( 'UTC' != ( $this->existing_timezone = date_default_timezone_get() ) ) {
46
+            date_default_timezone_set( 'UTC' );
47
+            $result->run( $this );
48
+        }
49
+
50
+        date_default_timezone_set( 'Pacific/Fiji' ); // UTC+12
51
+        $result->run( $this );
52
+
53
+        date_default_timezone_set( 'Pacific/Tahiti' ); // UTC-10: it's a magical place
54
+        $result->run( $this );
55
+
56
+        date_default_timezone_set( $this->existing_timezone );
57
+
58
+        return $result;
59
+    }
60 60
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -36,24 +36,24 @@
 block discarded – undo
36 36
 	 * We want to run every test multiple times using a different timezone to make sure
37 37
 	 * that they are unaffected by changes to PHP's timezone.
38 38
 	 */
39
-	public function run( PHPUnit\Framework\TestResult $result = null ): \PHPUnit\Framework\TestResult {
39
+	public function run(PHPUnit\Framework\TestResult $result = null): \PHPUnit\Framework\TestResult {
40 40
 
41
-		if ( $result === null ) {
41
+		if ($result === null) {
42 42
 			$result = $this->createResult();
43 43
 		}
44 44
 
45
-		if ( 'UTC' != ( $this->existing_timezone = date_default_timezone_get() ) ) {
46
-			date_default_timezone_set( 'UTC' );
47
-			$result->run( $this );
45
+		if ('UTC' != ($this->existing_timezone = date_default_timezone_get())) {
46
+			date_default_timezone_set('UTC');
47
+			$result->run($this);
48 48
 		}
49 49
 
50
-		date_default_timezone_set( 'Pacific/Fiji' ); // UTC+12
51
-		$result->run( $this );
50
+		date_default_timezone_set('Pacific/Fiji'); // UTC+12
51
+		$result->run($this);
52 52
 
53
-		date_default_timezone_set( 'Pacific/Tahiti' ); // UTC-10: it's a magical place
54
-		$result->run( $this );
53
+		date_default_timezone_set('Pacific/Tahiti'); // UTC-10: it's a magical place
54
+		$result->run($this);
55 55
 
56
-		date_default_timezone_set( $this->existing_timezone );
56
+		date_default_timezone_set($this->existing_timezone);
57 57
 
58 58
 		return $result;
59 59
 	}
Please login to merge, or discard this patch.
src/ext/action-scheduler/deprecated/functions.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
  * @return string The job ID
20 20
  */
21 21
 function wc_schedule_single_action( $timestamp, $hook, $args = array(), $group = '' ) {
22
-	_deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_single_action()' );
23
-	return as_schedule_single_action( $timestamp, $hook, $args, $group );
22
+    _deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_single_action()' );
23
+    return as_schedule_single_action( $timestamp, $hook, $args, $group );
24 24
 }
25 25
 
26 26
 /**
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
  * @return string The job ID
38 38
  */
39 39
 function wc_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args = array(), $group = '' ) {
40
-	_deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_recurring_action()' );
41
-	return as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args, $group );
40
+    _deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_recurring_action()' );
41
+    return as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args, $group );
42 42
 }
43 43
 
44 44
 /**
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
  * @return string The job ID
66 66
  */
67 67
 function wc_schedule_cron_action( $timestamp, $schedule, $hook, $args = array(), $group = '' ) {
68
-	_deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_cron_action()' );
69
-	return as_schedule_cron_action( $timestamp, $schedule, $hook, $args, $group );
68
+    _deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_cron_action()' );
69
+    return as_schedule_cron_action( $timestamp, $schedule, $hook, $args, $group );
70 70
 }
71 71
 
72 72
 /**
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
  * @deprecated 2.1.0
80 80
  */
81 81
 function wc_unschedule_action( $hook, $args = array(), $group = '' ) {
82
-	_deprecated_function( __FUNCTION__, '2.1.0', 'as_unschedule_action()' );
83
-	as_unschedule_action( $hook, $args, $group );
82
+    _deprecated_function( __FUNCTION__, '2.1.0', 'as_unschedule_action()' );
83
+    as_unschedule_action( $hook, $args, $group );
84 84
 }
85 85
 
86 86
 /**
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
  * @return int|bool The timestamp for the next occurrence, or false if nothing was found
94 94
  */
95 95
 function wc_next_scheduled_action( $hook, $args = null, $group = '' ) {
96
-	_deprecated_function( __FUNCTION__, '2.1.0', 'as_next_scheduled_action()' );
97
-	return as_next_scheduled_action( $hook, $args, $group );
96
+    _deprecated_function( __FUNCTION__, '2.1.0', 'as_next_scheduled_action()' );
97
+    return as_next_scheduled_action( $hook, $args, $group );
98 98
 }
99 99
 
100 100
 /**
@@ -121,6 +121,6 @@  discard block
 block discarded – undo
121 121
  * @return array
122 122
  */
123 123
 function wc_get_scheduled_actions( $args = array(), $return_format = OBJECT ) {
124
-	_deprecated_function( __FUNCTION__, '2.1.0', 'as_get_scheduled_actions()' );
125
-	return as_get_scheduled_actions( $args, $return_format );
124
+    _deprecated_function( __FUNCTION__, '2.1.0', 'as_get_scheduled_actions()' );
125
+    return as_get_scheduled_actions( $args, $return_format );
126 126
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -18,9 +18,9 @@  discard block
 block discarded – undo
18 18
  *
19 19
  * @return string The job ID
20 20
  */
21
-function wc_schedule_single_action( $timestamp, $hook, $args = array(), $group = '' ) {
22
-	_deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_single_action()' );
23
-	return as_schedule_single_action( $timestamp, $hook, $args, $group );
21
+function wc_schedule_single_action($timestamp, $hook, $args = array(), $group = '') {
22
+	_deprecated_function(__FUNCTION__, '2.1.0', 'as_schedule_single_action()');
23
+	return as_schedule_single_action($timestamp, $hook, $args, $group);
24 24
 }
25 25
 
26 26
 /**
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
  *
37 37
  * @return string The job ID
38 38
  */
39
-function wc_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args = array(), $group = '' ) {
40
-	_deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_recurring_action()' );
41
-	return as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args, $group );
39
+function wc_schedule_recurring_action($timestamp, $interval_in_seconds, $hook, $args = array(), $group = '') {
40
+	_deprecated_function(__FUNCTION__, '2.1.0', 'as_schedule_recurring_action()');
41
+	return as_schedule_recurring_action($timestamp, $interval_in_seconds, $hook, $args, $group);
42 42
 }
43 43
 
44 44
 /**
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
  *
65 65
  * @return string The job ID
66 66
  */
67
-function wc_schedule_cron_action( $timestamp, $schedule, $hook, $args = array(), $group = '' ) {
68
-	_deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_cron_action()' );
69
-	return as_schedule_cron_action( $timestamp, $schedule, $hook, $args, $group );
67
+function wc_schedule_cron_action($timestamp, $schedule, $hook, $args = array(), $group = '') {
68
+	_deprecated_function(__FUNCTION__, '2.1.0', 'as_schedule_cron_action()');
69
+	return as_schedule_cron_action($timestamp, $schedule, $hook, $args, $group);
70 70
 }
71 71
 
72 72
 /**
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
  *
79 79
  * @deprecated 2.1.0
80 80
  */
81
-function wc_unschedule_action( $hook, $args = array(), $group = '' ) {
82
-	_deprecated_function( __FUNCTION__, '2.1.0', 'as_unschedule_action()' );
83
-	as_unschedule_action( $hook, $args, $group );
81
+function wc_unschedule_action($hook, $args = array(), $group = '') {
82
+	_deprecated_function(__FUNCTION__, '2.1.0', 'as_unschedule_action()');
83
+	as_unschedule_action($hook, $args, $group);
84 84
 }
85 85
 
86 86
 /**
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
  *
93 93
  * @return int|bool The timestamp for the next occurrence, or false if nothing was found
94 94
  */
95
-function wc_next_scheduled_action( $hook, $args = null, $group = '' ) {
96
-	_deprecated_function( __FUNCTION__, '2.1.0', 'as_next_scheduled_action()' );
97
-	return as_next_scheduled_action( $hook, $args, $group );
95
+function wc_next_scheduled_action($hook, $args = null, $group = '') {
96
+	_deprecated_function(__FUNCTION__, '2.1.0', 'as_next_scheduled_action()');
97
+	return as_next_scheduled_action($hook, $args, $group);
98 98
 }
99 99
 
100 100
 /**
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
  *
121 121
  * @return array
122 122
  */
123
-function wc_get_scheduled_actions( $args = array(), $return_format = OBJECT ) {
124
-	_deprecated_function( __FUNCTION__, '2.1.0', 'as_get_scheduled_actions()' );
125
-	return as_get_scheduled_actions( $args, $return_format );
123
+function wc_get_scheduled_actions($args = array(), $return_format = OBJECT) {
124
+	_deprecated_function(__FUNCTION__, '2.1.0', 'as_get_scheduled_actions()');
125
+	return as_get_scheduled_actions($args, $return_format);
126 126
 }
Please login to merge, or discard this patch.
ext/action-scheduler/deprecated/ActionScheduler_AdminView_Deprecated.php 2 patches
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -10,138 +10,138 @@
 block discarded – undo
10 10
  */
11 11
 class ActionScheduler_AdminView_Deprecated {
12 12
 
13
-	public function action_scheduler_post_type_args( $args ) {
14
-		_deprecated_function( __METHOD__, '2.0.0' );
15
-		return $args;
16
-	}
13
+    public function action_scheduler_post_type_args( $args ) {
14
+        _deprecated_function( __METHOD__, '2.0.0' );
15
+        return $args;
16
+    }
17 17
 
18
-	/**
19
-	 * Customise the post status related views displayed on the Scheduled Actions administration screen.
20
-	 *
21
-	 * @param array $views An associative array of views and view labels which can be used to filter the 'scheduled-action' posts displayed on the Scheduled Actions administration screen.
22
-	 * @return array $views An associative array of views and view labels which can be used to filter the 'scheduled-action' posts displayed on the Scheduled Actions administration screen.
23
-	 */
24
-	public function list_table_views( $views ) {
25
-		_deprecated_function( __METHOD__, '2.0.0' );
26
-		return $views;
27
-	}
18
+    /**
19
+     * Customise the post status related views displayed on the Scheduled Actions administration screen.
20
+     *
21
+     * @param array $views An associative array of views and view labels which can be used to filter the 'scheduled-action' posts displayed on the Scheduled Actions administration screen.
22
+     * @return array $views An associative array of views and view labels which can be used to filter the 'scheduled-action' posts displayed on the Scheduled Actions administration screen.
23
+     */
24
+    public function list_table_views( $views ) {
25
+        _deprecated_function( __METHOD__, '2.0.0' );
26
+        return $views;
27
+    }
28 28
 
29
-	/**
30
-	 * Do not include the "Edit" action for the Scheduled Actions administration screen.
31
-	 *
32
-	 * Hooked to the 'bulk_actions-edit-action-scheduler' filter.
33
-	 *
34
-	 * @param array $actions An associative array of actions which can be performed on the 'scheduled-action' post type.
35
-	 * @return array $actions An associative array of actions which can be performed on the 'scheduled-action' post type.
36
-	 */
37
-	public function bulk_actions( $actions ) {
38
-		_deprecated_function( __METHOD__, '2.0.0' );
39
-		return $actions;
40
-	}
29
+    /**
30
+     * Do not include the "Edit" action for the Scheduled Actions administration screen.
31
+     *
32
+     * Hooked to the 'bulk_actions-edit-action-scheduler' filter.
33
+     *
34
+     * @param array $actions An associative array of actions which can be performed on the 'scheduled-action' post type.
35
+     * @return array $actions An associative array of actions which can be performed on the 'scheduled-action' post type.
36
+     */
37
+    public function bulk_actions( $actions ) {
38
+        _deprecated_function( __METHOD__, '2.0.0' );
39
+        return $actions;
40
+    }
41 41
 
42
-	/**
43
-	 * Completely customer the columns displayed on the Scheduled Actions administration screen.
44
-	 *
45
-	 * Because we can't filter the content of the default title and date columns, we need to recreate our own
46
-	 * custom columns for displaying those post fields. For the column content, @see self::list_table_column_content().
47
-	 *
48
-	 * @param array $columns An associative array of columns that are use for the table on the Scheduled Actions administration screen.
49
-	 * @return array $columns An associative array of columns that are use for the table on the Scheduled Actions administration screen.
50
-	 */
51
-	public function list_table_columns( $columns ) {
52
-		_deprecated_function( __METHOD__, '2.0.0' );
53
-		return $columns;
54
-	}
42
+    /**
43
+     * Completely customer the columns displayed on the Scheduled Actions administration screen.
44
+     *
45
+     * Because we can't filter the content of the default title and date columns, we need to recreate our own
46
+     * custom columns for displaying those post fields. For the column content, @see self::list_table_column_content().
47
+     *
48
+     * @param array $columns An associative array of columns that are use for the table on the Scheduled Actions administration screen.
49
+     * @return array $columns An associative array of columns that are use for the table on the Scheduled Actions administration screen.
50
+     */
51
+    public function list_table_columns( $columns ) {
52
+        _deprecated_function( __METHOD__, '2.0.0' );
53
+        return $columns;
54
+    }
55 55
 
56
-	/**
57
-	 * Make our custom title & date columns use defaulting title & date sorting.
58
-	 *
59
-	 * @param array $columns An associative array of columns that can be used to sort the table on the Scheduled Actions administration screen.
60
-	 * @return array $columns An associative array of columns that can be used to sort the table on the Scheduled Actions administration screen.
61
-	 */
62
-	public static function list_table_sortable_columns( $columns ) {
63
-		_deprecated_function( __METHOD__, '2.0.0' );
64
-		return $columns;
65
-	}
56
+    /**
57
+     * Make our custom title & date columns use defaulting title & date sorting.
58
+     *
59
+     * @param array $columns An associative array of columns that can be used to sort the table on the Scheduled Actions administration screen.
60
+     * @return array $columns An associative array of columns that can be used to sort the table on the Scheduled Actions administration screen.
61
+     */
62
+    public static function list_table_sortable_columns( $columns ) {
63
+        _deprecated_function( __METHOD__, '2.0.0' );
64
+        return $columns;
65
+    }
66 66
 
67
-	/**
68
-	 * Print the content for our custom columns.
69
-	 *
70
-	 * @param string $column_name The key for the column for which we should output our content.
71
-	 * @param int    $post_id The ID of the 'scheduled-action' post for which this row relates.
72
-	 */
73
-	public static function list_table_column_content( $column_name, $post_id ) {
74
-		_deprecated_function( __METHOD__, '2.0.0' );
75
-	}
67
+    /**
68
+     * Print the content for our custom columns.
69
+     *
70
+     * @param string $column_name The key for the column for which we should output our content.
71
+     * @param int    $post_id The ID of the 'scheduled-action' post for which this row relates.
72
+     */
73
+    public static function list_table_column_content( $column_name, $post_id ) {
74
+        _deprecated_function( __METHOD__, '2.0.0' );
75
+    }
76 76
 
77
-	/**
78
-	 * Hide the inline "Edit" action for all 'scheduled-action' posts.
79
-	 *
80
-	 * Hooked to the 'post_row_actions' filter.
81
-	 *
82
-	 * @param array $actions An associative array of actions which can be performed on the 'scheduled-action' post type.
83
-	 * @return array $actions An associative array of actions which can be performed on the 'scheduled-action' post type.
84
-	 */
85
-	public static function row_actions( $actions, $post ) {
86
-		_deprecated_function( __METHOD__, '2.0.0' );
87
-		return $actions;
88
-	}
77
+    /**
78
+     * Hide the inline "Edit" action for all 'scheduled-action' posts.
79
+     *
80
+     * Hooked to the 'post_row_actions' filter.
81
+     *
82
+     * @param array $actions An associative array of actions which can be performed on the 'scheduled-action' post type.
83
+     * @return array $actions An associative array of actions which can be performed on the 'scheduled-action' post type.
84
+     */
85
+    public static function row_actions( $actions, $post ) {
86
+        _deprecated_function( __METHOD__, '2.0.0' );
87
+        return $actions;
88
+    }
89 89
 
90
-	/**
91
-	 * Run an action when triggered from the Action Scheduler administration screen.
92
-	 *
93
-	 * @codeCoverageIgnore
94
-	 */
95
-	public static function maybe_execute_action() {
96
-		_deprecated_function( __METHOD__, '2.0.0' );
97
-	}
90
+    /**
91
+     * Run an action when triggered from the Action Scheduler administration screen.
92
+     *
93
+     * @codeCoverageIgnore
94
+     */
95
+    public static function maybe_execute_action() {
96
+        _deprecated_function( __METHOD__, '2.0.0' );
97
+    }
98 98
 
99
-	/**
100
-	 * Convert an interval of seconds into a two part human friendly string.
101
-	 *
102
-	 * The WordPress human_time_diff() function only calculates the time difference to one degree, meaning
103
-	 * even if an action is 1 day and 11 hours away, it will display "1 day". This funciton goes one step
104
-	 * further to display two degrees of accuracy.
105
-	 *
106
-	 * Based on Crontrol::interval() function by Edward Dale: https://wordpress.org/plugins/wp-crontrol/
107
-	 *
108
-	 * @param int $interval A interval in seconds.
109
-	 * @return string A human friendly string representation of the interval.
110
-	 */
111
-	public static function admin_notices() {
112
-		_deprecated_function( __METHOD__, '2.0.0' );
113
-	}
99
+    /**
100
+     * Convert an interval of seconds into a two part human friendly string.
101
+     *
102
+     * The WordPress human_time_diff() function only calculates the time difference to one degree, meaning
103
+     * even if an action is 1 day and 11 hours away, it will display "1 day". This funciton goes one step
104
+     * further to display two degrees of accuracy.
105
+     *
106
+     * Based on Crontrol::interval() function by Edward Dale: https://wordpress.org/plugins/wp-crontrol/
107
+     *
108
+     * @param int $interval A interval in seconds.
109
+     * @return string A human friendly string representation of the interval.
110
+     */
111
+    public static function admin_notices() {
112
+        _deprecated_function( __METHOD__, '2.0.0' );
113
+    }
114 114
 
115
-	/**
116
-	 * Filter search queries to allow searching by Claim ID (i.e. post_password).
117
-	 *
118
-	 * @param string   $orderby MySQL orderby string.
119
-	 * @param WP_Query $query Instance of a WP_Query object
120
-	 * @return string MySQL orderby string.
121
-	 */
122
-	public function custom_orderby( $orderby, $query ) {
123
-		_deprecated_function( __METHOD__, '2.0.0' );
124
-	}
115
+    /**
116
+     * Filter search queries to allow searching by Claim ID (i.e. post_password).
117
+     *
118
+     * @param string   $orderby MySQL orderby string.
119
+     * @param WP_Query $query Instance of a WP_Query object
120
+     * @return string MySQL orderby string.
121
+     */
122
+    public function custom_orderby( $orderby, $query ) {
123
+        _deprecated_function( __METHOD__, '2.0.0' );
124
+    }
125 125
 
126
-	/**
127
-	 * Filter search queries to allow searching by Claim ID (i.e. post_password).
128
-	 *
129
-	 * @param string   $search MySQL search string.
130
-	 * @param WP_Query $query Instance of a WP_Query object
131
-	 * @return string MySQL search string.
132
-	 */
133
-	public function search_post_password( $search, $query ) {
134
-		_deprecated_function( __METHOD__, '2.0.0' );
135
-	}
126
+    /**
127
+     * Filter search queries to allow searching by Claim ID (i.e. post_password).
128
+     *
129
+     * @param string   $search MySQL search string.
130
+     * @param WP_Query $query Instance of a WP_Query object
131
+     * @return string MySQL search string.
132
+     */
133
+    public function search_post_password( $search, $query ) {
134
+        _deprecated_function( __METHOD__, '2.0.0' );
135
+    }
136 136
 
137
-	/**
138
-	 * Change messages when a scheduled action is updated.
139
-	 *
140
-	 * @param  array $messages
141
-	 * @return array
142
-	 */
143
-	public function post_updated_messages( $messages ) {
144
-		_deprecated_function( __METHOD__, '2.0.0' );
145
-		return $messages;
146
-	}
137
+    /**
138
+     * Change messages when a scheduled action is updated.
139
+     *
140
+     * @param  array $messages
141
+     * @return array
142
+     */
143
+    public function post_updated_messages( $messages ) {
144
+        _deprecated_function( __METHOD__, '2.0.0' );
145
+        return $messages;
146
+    }
147 147
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@  discard block
 block discarded – undo
10 10
  */
11 11
 class ActionScheduler_AdminView_Deprecated {
12 12
 
13
-	public function action_scheduler_post_type_args( $args ) {
14
-		_deprecated_function( __METHOD__, '2.0.0' );
13
+	public function action_scheduler_post_type_args($args) {
14
+		_deprecated_function(__METHOD__, '2.0.0');
15 15
 		return $args;
16 16
 	}
17 17
 
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 	 * @param array $views An associative array of views and view labels which can be used to filter the 'scheduled-action' posts displayed on the Scheduled Actions administration screen.
22 22
 	 * @return array $views An associative array of views and view labels which can be used to filter the 'scheduled-action' posts displayed on the Scheduled Actions administration screen.
23 23
 	 */
24
-	public function list_table_views( $views ) {
25
-		_deprecated_function( __METHOD__, '2.0.0' );
24
+	public function list_table_views($views) {
25
+		_deprecated_function(__METHOD__, '2.0.0');
26 26
 		return $views;
27 27
 	}
28 28
 
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
 	 * @param array $actions An associative array of actions which can be performed on the 'scheduled-action' post type.
35 35
 	 * @return array $actions An associative array of actions which can be performed on the 'scheduled-action' post type.
36 36
 	 */
37
-	public function bulk_actions( $actions ) {
38
-		_deprecated_function( __METHOD__, '2.0.0' );
37
+	public function bulk_actions($actions) {
38
+		_deprecated_function(__METHOD__, '2.0.0');
39 39
 		return $actions;
40 40
 	}
41 41
 
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
 	 * @param array $columns An associative array of columns that are use for the table on the Scheduled Actions administration screen.
49 49
 	 * @return array $columns An associative array of columns that are use for the table on the Scheduled Actions administration screen.
50 50
 	 */
51
-	public function list_table_columns( $columns ) {
52
-		_deprecated_function( __METHOD__, '2.0.0' );
51
+	public function list_table_columns($columns) {
52
+		_deprecated_function(__METHOD__, '2.0.0');
53 53
 		return $columns;
54 54
 	}
55 55
 
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
 	 * @param array $columns An associative array of columns that can be used to sort the table on the Scheduled Actions administration screen.
60 60
 	 * @return array $columns An associative array of columns that can be used to sort the table on the Scheduled Actions administration screen.
61 61
 	 */
62
-	public static function list_table_sortable_columns( $columns ) {
63
-		_deprecated_function( __METHOD__, '2.0.0' );
62
+	public static function list_table_sortable_columns($columns) {
63
+		_deprecated_function(__METHOD__, '2.0.0');
64 64
 		return $columns;
65 65
 	}
66 66
 
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
 	 * @param string $column_name The key for the column for which we should output our content.
71 71
 	 * @param int    $post_id The ID of the 'scheduled-action' post for which this row relates.
72 72
 	 */
73
-	public static function list_table_column_content( $column_name, $post_id ) {
74
-		_deprecated_function( __METHOD__, '2.0.0' );
73
+	public static function list_table_column_content($column_name, $post_id) {
74
+		_deprecated_function(__METHOD__, '2.0.0');
75 75
 	}
76 76
 
77 77
 	/**
@@ -82,8 +82,8 @@  discard block
 block discarded – undo
82 82
 	 * @param array $actions An associative array of actions which can be performed on the 'scheduled-action' post type.
83 83
 	 * @return array $actions An associative array of actions which can be performed on the 'scheduled-action' post type.
84 84
 	 */
85
-	public static function row_actions( $actions, $post ) {
86
-		_deprecated_function( __METHOD__, '2.0.0' );
85
+	public static function row_actions($actions, $post) {
86
+		_deprecated_function(__METHOD__, '2.0.0');
87 87
 		return $actions;
88 88
 	}
89 89
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * @codeCoverageIgnore
94 94
 	 */
95 95
 	public static function maybe_execute_action() {
96
-		_deprecated_function( __METHOD__, '2.0.0' );
96
+		_deprecated_function(__METHOD__, '2.0.0');
97 97
 	}
98 98
 
99 99
 	/**
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 * @return string A human friendly string representation of the interval.
110 110
 	 */
111 111
 	public static function admin_notices() {
112
-		_deprecated_function( __METHOD__, '2.0.0' );
112
+		_deprecated_function(__METHOD__, '2.0.0');
113 113
 	}
114 114
 
115 115
 	/**
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 	 * @param WP_Query $query Instance of a WP_Query object
120 120
 	 * @return string MySQL orderby string.
121 121
 	 */
122
-	public function custom_orderby( $orderby, $query ) {
123
-		_deprecated_function( __METHOD__, '2.0.0' );
122
+	public function custom_orderby($orderby, $query) {
123
+		_deprecated_function(__METHOD__, '2.0.0');
124 124
 	}
125 125
 
126 126
 	/**
@@ -130,8 +130,8 @@  discard block
 block discarded – undo
130 130
 	 * @param WP_Query $query Instance of a WP_Query object
131 131
 	 * @return string MySQL search string.
132 132
 	 */
133
-	public function search_post_password( $search, $query ) {
134
-		_deprecated_function( __METHOD__, '2.0.0' );
133
+	public function search_post_password($search, $query) {
134
+		_deprecated_function(__METHOD__, '2.0.0');
135 135
 	}
136 136
 
137 137
 	/**
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 	 * @param  array $messages
141 141
 	 * @return array
142 142
 	 */
143
-	public function post_updated_messages( $messages ) {
144
-		_deprecated_function( __METHOD__, '2.0.0' );
143
+	public function post_updated_messages($messages) {
144
+		_deprecated_function(__METHOD__, '2.0.0');
145 145
 		return $messages;
146 146
 	}
147 147
 }
Please login to merge, or discard this patch.