Completed
Pull Request — develop (#1642)
by Naveen
01:15
created
tests/phpunit/schedules/ActionScheduler_SimpleSchedule_Test.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -6,33 +6,33 @@
 block discarded – undo
6 6
  * @group schedules
7 7
  */
8 8
 class ActionScheduler_SimpleSchedule_Test extends ActionScheduler_UnitTestCase {
9
-	public function test_creation() {
10
-		$time     = as_get_datetime_object();
11
-		$schedule = new ActionScheduler_SimpleSchedule( $time );
12
-		$this->assertEquals( $time, $schedule->get_date() );
13
-	}
9
+    public function test_creation() {
10
+        $time     = as_get_datetime_object();
11
+        $schedule = new ActionScheduler_SimpleSchedule( $time );
12
+        $this->assertEquals( $time, $schedule->get_date() );
13
+    }
14 14
 
15
-	public function test_past_date() {
16
-		$time     = as_get_datetime_object( '-1 day' );
17
-		$schedule = new ActionScheduler_SimpleSchedule( $time );
18
-		$this->assertEquals( $time, $schedule->get_date() );
19
-	}
15
+    public function test_past_date() {
16
+        $time     = as_get_datetime_object( '-1 day' );
17
+        $schedule = new ActionScheduler_SimpleSchedule( $time );
18
+        $this->assertEquals( $time, $schedule->get_date() );
19
+    }
20 20
 
21
-	public function test_future_date() {
22
-		$time     = as_get_datetime_object( '+1 day' );
23
-		$schedule = new ActionScheduler_SimpleSchedule( $time );
24
-		$this->assertEquals( $time, $schedule->get_date() );
25
-	}
21
+    public function test_future_date() {
22
+        $time     = as_get_datetime_object( '+1 day' );
23
+        $schedule = new ActionScheduler_SimpleSchedule( $time );
24
+        $this->assertEquals( $time, $schedule->get_date() );
25
+    }
26 26
 
27
-	public function test_grace_period_for_next() {
28
-		$time     = as_get_datetime_object( '3 seconds ago' );
29
-		$schedule = new ActionScheduler_SimpleSchedule( $time );
30
-		$this->assertEquals( $time, $schedule->get_date() );
31
-	}
27
+    public function test_grace_period_for_next() {
28
+        $time     = as_get_datetime_object( '3 seconds ago' );
29
+        $schedule = new ActionScheduler_SimpleSchedule( $time );
30
+        $this->assertEquals( $time, $schedule->get_date() );
31
+    }
32 32
 
33
-	public function test_is_recurring() {
34
-		$schedule = new ActionScheduler_SimpleSchedule( as_get_datetime_object( '+1 day' ) );
35
-		$this->assertFalse( $schedule->is_recurring() );
36
-	}
33
+    public function test_is_recurring() {
34
+        $schedule = new ActionScheduler_SimpleSchedule( as_get_datetime_object( '+1 day' ) );
35
+        $this->assertFalse( $schedule->is_recurring() );
36
+    }
37 37
 }
38 38
 
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -8,31 +8,31 @@
 block discarded – undo
8 8
 class ActionScheduler_SimpleSchedule_Test extends ActionScheduler_UnitTestCase {
9 9
 	public function test_creation() {
10 10
 		$time     = as_get_datetime_object();
11
-		$schedule = new ActionScheduler_SimpleSchedule( $time );
12
-		$this->assertEquals( $time, $schedule->get_date() );
11
+		$schedule = new ActionScheduler_SimpleSchedule($time);
12
+		$this->assertEquals($time, $schedule->get_date());
13 13
 	}
14 14
 
15 15
 	public function test_past_date() {
16
-		$time     = as_get_datetime_object( '-1 day' );
17
-		$schedule = new ActionScheduler_SimpleSchedule( $time );
18
-		$this->assertEquals( $time, $schedule->get_date() );
16
+		$time     = as_get_datetime_object('-1 day');
17
+		$schedule = new ActionScheduler_SimpleSchedule($time);
18
+		$this->assertEquals($time, $schedule->get_date());
19 19
 	}
20 20
 
21 21
 	public function test_future_date() {
22
-		$time     = as_get_datetime_object( '+1 day' );
23
-		$schedule = new ActionScheduler_SimpleSchedule( $time );
24
-		$this->assertEquals( $time, $schedule->get_date() );
22
+		$time     = as_get_datetime_object('+1 day');
23
+		$schedule = new ActionScheduler_SimpleSchedule($time);
24
+		$this->assertEquals($time, $schedule->get_date());
25 25
 	}
26 26
 
27 27
 	public function test_grace_period_for_next() {
28
-		$time     = as_get_datetime_object( '3 seconds ago' );
29
-		$schedule = new ActionScheduler_SimpleSchedule( $time );
30
-		$this->assertEquals( $time, $schedule->get_date() );
28
+		$time     = as_get_datetime_object('3 seconds ago');
29
+		$schedule = new ActionScheduler_SimpleSchedule($time);
30
+		$this->assertEquals($time, $schedule->get_date());
31 31
 	}
32 32
 
33 33
 	public function test_is_recurring() {
34
-		$schedule = new ActionScheduler_SimpleSchedule( as_get_datetime_object( '+1 day' ) );
35
-		$this->assertFalse( $schedule->is_recurring() );
34
+		$schedule = new ActionScheduler_SimpleSchedule(as_get_datetime_object('+1 day'));
35
+		$this->assertFalse($schedule->is_recurring());
36 36
 	}
37 37
 }
38 38
 
Please login to merge, or discard this patch.
tests/phpunit/schedules/ActionScheduler_IntervalSchedule_Test.php 2 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -6,33 +6,33 @@
 block discarded – undo
6 6
  * @group schedules
7 7
  */
8 8
 class ActionScheduler_IntervalSchedule_Test extends ActionScheduler_UnitTestCase {
9
-	public function test_creation() {
10
-		$time     = as_get_datetime_object();
11
-		$schedule = new ActionScheduler_IntervalSchedule( $time, HOUR_IN_SECONDS );
12
-		$this->assertEquals( $time, $schedule->get_date() );
13
-		$this->assertEquals( $time, $schedule->get_first_date() );
14
-	}
9
+    public function test_creation() {
10
+        $time     = as_get_datetime_object();
11
+        $schedule = new ActionScheduler_IntervalSchedule( $time, HOUR_IN_SECONDS );
12
+        $this->assertEquals( $time, $schedule->get_date() );
13
+        $this->assertEquals( $time, $schedule->get_first_date() );
14
+    }
15 15
 
16
-	public function test_creation_with_first_date() {
17
-		$first    = as_get_datetime_object();
18
-		$time     = as_get_datetime_object( '+12 hours' );
19
-		$schedule = new ActionScheduler_IntervalSchedule( $time, HOUR_IN_SECONDS, $first );
20
-		$this->assertEquals( $time, $schedule->get_date() );
21
-		$this->assertEquals( $first, $schedule->get_first_date() );
22
-	}
16
+    public function test_creation_with_first_date() {
17
+        $first    = as_get_datetime_object();
18
+        $time     = as_get_datetime_object( '+12 hours' );
19
+        $schedule = new ActionScheduler_IntervalSchedule( $time, HOUR_IN_SECONDS, $first );
20
+        $this->assertEquals( $time, $schedule->get_date() );
21
+        $this->assertEquals( $first, $schedule->get_first_date() );
22
+    }
23 23
 
24
-	public function test_next() {
25
-		$now      = time();
26
-		$start    = $now - 30;
27
-		$schedule = new ActionScheduler_IntervalSchedule( as_get_datetime_object( "@$start" ), MINUTE_IN_SECONDS );
28
-		$this->assertEquals( $start, $schedule->get_date()->getTimestamp() );
29
-		$this->assertEquals( $now + MINUTE_IN_SECONDS, $schedule->get_next( as_get_datetime_object() )->getTimestamp() );
30
-		$this->assertEquals( $start, $schedule->get_next( as_get_datetime_object( "@$start" ) )->getTimestamp() );
31
-	}
24
+    public function test_next() {
25
+        $now      = time();
26
+        $start    = $now - 30;
27
+        $schedule = new ActionScheduler_IntervalSchedule( as_get_datetime_object( "@$start" ), MINUTE_IN_SECONDS );
28
+        $this->assertEquals( $start, $schedule->get_date()->getTimestamp() );
29
+        $this->assertEquals( $now + MINUTE_IN_SECONDS, $schedule->get_next( as_get_datetime_object() )->getTimestamp() );
30
+        $this->assertEquals( $start, $schedule->get_next( as_get_datetime_object( "@$start" ) )->getTimestamp() );
31
+    }
32 32
 
33
-	public function test_is_recurring() {
34
-		$start    = time() - 30;
35
-		$schedule = new ActionScheduler_IntervalSchedule( as_get_datetime_object( "@$start" ), MINUTE_IN_SECONDS );
36
-		$this->assertTrue( $schedule->is_recurring() );
37
-	}
33
+    public function test_is_recurring() {
34
+        $start    = time() - 30;
35
+        $schedule = new ActionScheduler_IntervalSchedule( as_get_datetime_object( "@$start" ), MINUTE_IN_SECONDS );
36
+        $this->assertTrue( $schedule->is_recurring() );
37
+    }
38 38
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -8,31 +8,31 @@
 block discarded – undo
8 8
 class ActionScheduler_IntervalSchedule_Test extends ActionScheduler_UnitTestCase {
9 9
 	public function test_creation() {
10 10
 		$time     = as_get_datetime_object();
11
-		$schedule = new ActionScheduler_IntervalSchedule( $time, HOUR_IN_SECONDS );
12
-		$this->assertEquals( $time, $schedule->get_date() );
13
-		$this->assertEquals( $time, $schedule->get_first_date() );
11
+		$schedule = new ActionScheduler_IntervalSchedule($time, HOUR_IN_SECONDS);
12
+		$this->assertEquals($time, $schedule->get_date());
13
+		$this->assertEquals($time, $schedule->get_first_date());
14 14
 	}
15 15
 
16 16
 	public function test_creation_with_first_date() {
17 17
 		$first    = as_get_datetime_object();
18
-		$time     = as_get_datetime_object( '+12 hours' );
19
-		$schedule = new ActionScheduler_IntervalSchedule( $time, HOUR_IN_SECONDS, $first );
20
-		$this->assertEquals( $time, $schedule->get_date() );
21
-		$this->assertEquals( $first, $schedule->get_first_date() );
18
+		$time     = as_get_datetime_object('+12 hours');
19
+		$schedule = new ActionScheduler_IntervalSchedule($time, HOUR_IN_SECONDS, $first);
20
+		$this->assertEquals($time, $schedule->get_date());
21
+		$this->assertEquals($first, $schedule->get_first_date());
22 22
 	}
23 23
 
24 24
 	public function test_next() {
25 25
 		$now      = time();
26 26
 		$start    = $now - 30;
27
-		$schedule = new ActionScheduler_IntervalSchedule( as_get_datetime_object( "@$start" ), MINUTE_IN_SECONDS );
28
-		$this->assertEquals( $start, $schedule->get_date()->getTimestamp() );
29
-		$this->assertEquals( $now + MINUTE_IN_SECONDS, $schedule->get_next( as_get_datetime_object() )->getTimestamp() );
30
-		$this->assertEquals( $start, $schedule->get_next( as_get_datetime_object( "@$start" ) )->getTimestamp() );
27
+		$schedule = new ActionScheduler_IntervalSchedule(as_get_datetime_object("@$start"), MINUTE_IN_SECONDS);
28
+		$this->assertEquals($start, $schedule->get_date()->getTimestamp());
29
+		$this->assertEquals($now + MINUTE_IN_SECONDS, $schedule->get_next(as_get_datetime_object())->getTimestamp());
30
+		$this->assertEquals($start, $schedule->get_next(as_get_datetime_object("@$start"))->getTimestamp());
31 31
 	}
32 32
 
33 33
 	public function test_is_recurring() {
34 34
 		$start    = time() - 30;
35
-		$schedule = new ActionScheduler_IntervalSchedule( as_get_datetime_object( "@$start" ), MINUTE_IN_SECONDS );
36
-		$this->assertTrue( $schedule->is_recurring() );
35
+		$schedule = new ActionScheduler_IntervalSchedule(as_get_datetime_object("@$start"), MINUTE_IN_SECONDS);
36
+		$this->assertTrue($schedule->is_recurring());
37 37
 	}
38 38
 }
Please login to merge, or discard this patch.
tests/phpunit/schedules/ActionScheduler_NullSchedule_Test.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,14 +6,14 @@
 block discarded – undo
6 6
  * @group schedules
7 7
  */
8 8
 class ActionScheduler_NullSchedule_Test extends ActionScheduler_UnitTestCase {
9
-	public function test_null_schedule() {
10
-		$schedule = new ActionScheduler_NullSchedule();
11
-		$this->assertNull( $schedule->get_date() );
12
-	}
9
+    public function test_null_schedule() {
10
+        $schedule = new ActionScheduler_NullSchedule();
11
+        $this->assertNull( $schedule->get_date() );
12
+    }
13 13
 
14
-	public function test_is_recurring() {
15
-		$schedule = new ActionScheduler_NullSchedule();
16
-		$this->assertFalse( $schedule->is_recurring() );
17
-	}
14
+    public function test_is_recurring() {
15
+        $schedule = new ActionScheduler_NullSchedule();
16
+        $this->assertFalse( $schedule->is_recurring() );
17
+    }
18 18
 }
19 19
 
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,12 +8,12 @@
 block discarded – undo
8 8
 class ActionScheduler_NullSchedule_Test extends ActionScheduler_UnitTestCase {
9 9
 	public function test_null_schedule() {
10 10
 		$schedule = new ActionScheduler_NullSchedule();
11
-		$this->assertNull( $schedule->get_date() );
11
+		$this->assertNull($schedule->get_date());
12 12
 	}
13 13
 
14 14
 	public function test_is_recurring() {
15 15
 		$schedule = new ActionScheduler_NullSchedule();
16
-		$this->assertFalse( $schedule->is_recurring() );
16
+		$this->assertFalse($schedule->is_recurring());
17 17
 	}
18 18
 }
19 19
 
Please login to merge, or discard this patch.
tests/phpunit/helpers/ActionScheduler_Compatibility_Test.php 2 patches
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -3,44 +3,44 @@
 block discarded – undo
3 3
  * @group helpers
4 4
  */
5 5
 class ActionScheduler_Compatibility_Test extends ActionScheduler_UnitTestCase {
6
-	/**
7
-	 * Test the logic relating to ActionScheduler_Compatibility::raise_time_limit().
8
-	 */
9
-	public function test_raise_time_limit() {
10
-		// We'll want to restore things after this test.
11
-		$default_max_execution_time = ini_get( 'max_execution_time' );
6
+    /**
7
+     * Test the logic relating to ActionScheduler_Compatibility::raise_time_limit().
8
+     */
9
+    public function test_raise_time_limit() {
10
+        // We'll want to restore things after this test.
11
+        $default_max_execution_time = ini_get( 'max_execution_time' );
12 12
 
13
-		ini_set( 'max_execution_time', 0 );
14
-		ActionScheduler_Compatibility::raise_time_limit( 10 );
15
-		$this->assertSame(
16
-			'0',
17
-			ini_get( 'max_execution_time' ),
18
-			'If the max_execution_time was already zero (unlimited), then it will not be changed.'
19
-		);
13
+        ini_set( 'max_execution_time', 0 );
14
+        ActionScheduler_Compatibility::raise_time_limit( 10 );
15
+        $this->assertSame(
16
+            '0',
17
+            ini_get( 'max_execution_time' ),
18
+            'If the max_execution_time was already zero (unlimited), then it will not be changed.'
19
+        );
20 20
 
21
-		ini_set( 'max_execution_time', 60 );
22
-		ActionScheduler_Compatibility::raise_time_limit( 30 );
23
-		$this->assertSame(
24
-			'60',
25
-			ini_get( 'max_execution_time' ),
26
-			'If the max_execution_time was already a higher value than we specify, then it will not be changed.'
27
-		);
21
+        ini_set( 'max_execution_time', 60 );
22
+        ActionScheduler_Compatibility::raise_time_limit( 30 );
23
+        $this->assertSame(
24
+            '60',
25
+            ini_get( 'max_execution_time' ),
26
+            'If the max_execution_time was already a higher value than we specify, then it will not be changed.'
27
+        );
28 28
 
29
-		ActionScheduler_Compatibility::raise_time_limit( 200 );
30
-		$this->assertSame(
31
-			'200',
32
-			ini_get( 'max_execution_time' ),
33
-			'If the max_execution_time was a lower value than we specify, but was above zero, then it will be updated to the new value.'
34
-		);
29
+        ActionScheduler_Compatibility::raise_time_limit( 200 );
30
+        $this->assertSame(
31
+            '200',
32
+            ini_get( 'max_execution_time' ),
33
+            'If the max_execution_time was a lower value than we specify, but was above zero, then it will be updated to the new value.'
34
+        );
35 35
 
36
-		ActionScheduler_Compatibility::raise_time_limit( 0 );
37
-		$this->assertSame(
38
-			'0',
39
-			ini_get( 'max_execution_time' ),
40
-			'If the max_execution_time was a positive, non-zero value and we then specify zero (unlimited) as the new value, then it will be updated.'
41
-		);
36
+        ActionScheduler_Compatibility::raise_time_limit( 0 );
37
+        $this->assertSame(
38
+            '0',
39
+            ini_get( 'max_execution_time' ),
40
+            'If the max_execution_time was a positive, non-zero value and we then specify zero (unlimited) as the new value, then it will be updated.'
41
+        );
42 42
 
43
-		// Cleanup.
44
-		ini_set( 'max_execution_time', $default_max_execution_time );
45
-	}
43
+        // Cleanup.
44
+        ini_set( 'max_execution_time', $default_max_execution_time );
45
+    }
46 46
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -8,39 +8,39 @@
 block discarded – undo
8 8
 	 */
9 9
 	public function test_raise_time_limit() {
10 10
 		// We'll want to restore things after this test.
11
-		$default_max_execution_time = ini_get( 'max_execution_time' );
11
+		$default_max_execution_time = ini_get('max_execution_time');
12 12
 
13
-		ini_set( 'max_execution_time', 0 );
14
-		ActionScheduler_Compatibility::raise_time_limit( 10 );
13
+		ini_set('max_execution_time', 0);
14
+		ActionScheduler_Compatibility::raise_time_limit(10);
15 15
 		$this->assertSame(
16 16
 			'0',
17
-			ini_get( 'max_execution_time' ),
17
+			ini_get('max_execution_time'),
18 18
 			'If the max_execution_time was already zero (unlimited), then it will not be changed.'
19 19
 		);
20 20
 
21
-		ini_set( 'max_execution_time', 60 );
22
-		ActionScheduler_Compatibility::raise_time_limit( 30 );
21
+		ini_set('max_execution_time', 60);
22
+		ActionScheduler_Compatibility::raise_time_limit(30);
23 23
 		$this->assertSame(
24 24
 			'60',
25
-			ini_get( 'max_execution_time' ),
25
+			ini_get('max_execution_time'),
26 26
 			'If the max_execution_time was already a higher value than we specify, then it will not be changed.'
27 27
 		);
28 28
 
29
-		ActionScheduler_Compatibility::raise_time_limit( 200 );
29
+		ActionScheduler_Compatibility::raise_time_limit(200);
30 30
 		$this->assertSame(
31 31
 			'200',
32
-			ini_get( 'max_execution_time' ),
32
+			ini_get('max_execution_time'),
33 33
 			'If the max_execution_time was a lower value than we specify, but was above zero, then it will be updated to the new value.'
34 34
 		);
35 35
 
36
-		ActionScheduler_Compatibility::raise_time_limit( 0 );
36
+		ActionScheduler_Compatibility::raise_time_limit(0);
37 37
 		$this->assertSame(
38 38
 			'0',
39
-			ini_get( 'max_execution_time' ),
39
+			ini_get('max_execution_time'),
40 40
 			'If the max_execution_time was a positive, non-zero value and we then specify zero (unlimited) as the new value, then it will be updated.'
41 41
 		);
42 42
 
43 43
 		// Cleanup.
44
-		ini_set( 'max_execution_time', $default_max_execution_time );
44
+		ini_set('max_execution_time', $default_max_execution_time);
45 45
 	}
46 46
 }
Please login to merge, or discard this patch.
action-scheduler/tests/phpunit/helpers/ActionScheduler_Callbacks.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,31 +1,31 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class ActionScheduler_Callbacks {
4
-	/**
5
-	 * Scheduled action hook that can be used when we want to simulate an action
6
-	 * with a registered callback.
7
-	 */
8
-	const HOOK_WITH_CALLBACK = 'hook_with_callback';
4
+    /**
5
+     * Scheduled action hook that can be used when we want to simulate an action
6
+     * with a registered callback.
7
+     */
8
+    const HOOK_WITH_CALLBACK = 'hook_with_callback';
9 9
 
10
-	/**
11
-	 * Setup callbacks for different types of hook.
12
-	 */
13
-	public static function add_callbacks() {
14
-		add_action( self::HOOK_WITH_CALLBACK, array( __CLASS__, 'empty_callback' ) );
15
-	}
10
+    /**
11
+     * Setup callbacks for different types of hook.
12
+     */
13
+    public static function add_callbacks() {
14
+        add_action( self::HOOK_WITH_CALLBACK, array( __CLASS__, 'empty_callback' ) );
15
+    }
16 16
 
17
-	/**
18
-	 * Remove callbacks.
19
-	 */
20
-	public static function remove_callbacks() {
21
-		remove_action( self::HOOK_WITH_CALLBACK, array( __CLASS__, 'empty_callback' ) );
22
-	}
17
+    /**
18
+     * Remove callbacks.
19
+     */
20
+    public static function remove_callbacks() {
21
+        remove_action( self::HOOK_WITH_CALLBACK, array( __CLASS__, 'empty_callback' ) );
22
+    }
23 23
 
24
-	/**
25
-	 * This stub is used as the callback function for the ActionScheduler_Callbacks::HOOK_WITH_CALLBACK hook.
26
-	 *
27
-	 * Action Scheduler will mark actions as 'failed' if a callback does not exist, this
28
-	 * simply serves to act as the callback for various test scenarios in child classes.
29
-	 */
30
-	public static function empty_callback() {}
24
+    /**
25
+     * This stub is used as the callback function for the ActionScheduler_Callbacks::HOOK_WITH_CALLBACK hook.
26
+     *
27
+     * Action Scheduler will mark actions as 'failed' if a callback does not exist, this
28
+     * simply serves to act as the callback for various test scenarios in child classes.
29
+     */
30
+    public static function empty_callback() {}
31 31
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,14 +11,14 @@
 block discarded – undo
11 11
 	 * Setup callbacks for different types of hook.
12 12
 	 */
13 13
 	public static function add_callbacks() {
14
-		add_action( self::HOOK_WITH_CALLBACK, array( __CLASS__, 'empty_callback' ) );
14
+		add_action(self::HOOK_WITH_CALLBACK, array(__CLASS__, 'empty_callback'));
15 15
 	}
16 16
 
17 17
 	/**
18 18
 	 * Remove callbacks.
19 19
 	 */
20 20
 	public static function remove_callbacks() {
21
-		remove_action( self::HOOK_WITH_CALLBACK, array( __CLASS__, 'empty_callback' ) );
21
+		remove_action(self::HOOK_WITH_CALLBACK, array(__CLASS__, 'empty_callback'));
22 22
 	}
23 23
 
24 24
 	/**
Please login to merge, or discard this patch.
action-scheduler/tests/phpunit/deprecated/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() {
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 ) {
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() {
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 ) {
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 ) {
39
+	public function run(PHPUnit_Framework_TestResult $result = null) {
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.
action-scheduler/tests/phpunit/jobs/ActionScheduler_Action_Test.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -6,50 +6,50 @@
 block discarded – undo
6 6
  * @group actions
7 7
  */
8 8
 class ActionScheduler_Action_Test extends ActionScheduler_UnitTestCase {
9
-	public function test_set_schedule() {
10
-		$time     = as_get_datetime_object();
11
-		$schedule = new ActionScheduler_SimpleSchedule( $time );
12
-		$action   = new ActionScheduler_Action( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK, array(), $schedule );
13
-		$this->assertEquals( $schedule, $action->get_schedule() );
14
-	}
15
-
16
-	public function test_null_schedule() {
17
-		$action = new ActionScheduler_Action( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK );
18
-		$this->assertInstanceOf( 'ActionScheduler_NullSchedule', $action->get_schedule() );
19
-	}
20
-
21
-	public function test_set_hook() {
22
-		$action = new ActionScheduler_Action( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK );
23
-		$this->assertEquals( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK, $action->get_hook() );
24
-	}
25
-
26
-	public function test_args() {
27
-		$action = new ActionScheduler_Action( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK );
28
-		$this->assertEmpty( $action->get_args() );
29
-
30
-		$action = new ActionScheduler_Action( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK, array( 5, 10, 15 ) );
31
-		$this->assertEqualSets( array( 5, 10, 15 ), $action->get_args() );
32
-	}
33
-
34
-	public function test_set_group() {
35
-		$action = new ActionScheduler_Action( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK, array(), null, 'my_group' );
36
-		$this->assertEquals( 'my_group', $action->get_group() );
37
-	}
38
-
39
-	public function test_execute() {
40
-		$mock = new MockAction();
41
-
42
-		$random = md5( rand() );
43
-		add_action( $random, array( $mock, 'action' ) );
44
-
45
-		$action = new ActionScheduler_Action( $random, array( $random ) );
46
-		$action->execute();
47
-
48
-		remove_action( $random, array( $mock, 'action' ) );
49
-
50
-		$this->assertSame( 1, $mock->get_call_count() );
51
-		$events = $mock->get_events();
52
-		$event  = reset( $events );
53
-		$this->assertEquals( $random, reset( $event['args'] ) );
54
-	}
9
+    public function test_set_schedule() {
10
+        $time     = as_get_datetime_object();
11
+        $schedule = new ActionScheduler_SimpleSchedule( $time );
12
+        $action   = new ActionScheduler_Action( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK, array(), $schedule );
13
+        $this->assertEquals( $schedule, $action->get_schedule() );
14
+    }
15
+
16
+    public function test_null_schedule() {
17
+        $action = new ActionScheduler_Action( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK );
18
+        $this->assertInstanceOf( 'ActionScheduler_NullSchedule', $action->get_schedule() );
19
+    }
20
+
21
+    public function test_set_hook() {
22
+        $action = new ActionScheduler_Action( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK );
23
+        $this->assertEquals( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK, $action->get_hook() );
24
+    }
25
+
26
+    public function test_args() {
27
+        $action = new ActionScheduler_Action( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK );
28
+        $this->assertEmpty( $action->get_args() );
29
+
30
+        $action = new ActionScheduler_Action( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK, array( 5, 10, 15 ) );
31
+        $this->assertEqualSets( array( 5, 10, 15 ), $action->get_args() );
32
+    }
33
+
34
+    public function test_set_group() {
35
+        $action = new ActionScheduler_Action( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK, array(), null, 'my_group' );
36
+        $this->assertEquals( 'my_group', $action->get_group() );
37
+    }
38
+
39
+    public function test_execute() {
40
+        $mock = new MockAction();
41
+
42
+        $random = md5( rand() );
43
+        add_action( $random, array( $mock, 'action' ) );
44
+
45
+        $action = new ActionScheduler_Action( $random, array( $random ) );
46
+        $action->execute();
47
+
48
+        remove_action( $random, array( $mock, 'action' ) );
49
+
50
+        $this->assertSame( 1, $mock->get_call_count() );
51
+        $events = $mock->get_events();
52
+        $event  = reset( $events );
53
+        $this->assertEquals( $random, reset( $event['args'] ) );
54
+    }
55 55
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -8,48 +8,48 @@
 block discarded – undo
8 8
 class ActionScheduler_Action_Test extends ActionScheduler_UnitTestCase {
9 9
 	public function test_set_schedule() {
10 10
 		$time     = as_get_datetime_object();
11
-		$schedule = new ActionScheduler_SimpleSchedule( $time );
12
-		$action   = new ActionScheduler_Action( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK, array(), $schedule );
13
-		$this->assertEquals( $schedule, $action->get_schedule() );
11
+		$schedule = new ActionScheduler_SimpleSchedule($time);
12
+		$action   = new ActionScheduler_Action(ActionScheduler_Callbacks::HOOK_WITH_CALLBACK, array(), $schedule);
13
+		$this->assertEquals($schedule, $action->get_schedule());
14 14
 	}
15 15
 
16 16
 	public function test_null_schedule() {
17
-		$action = new ActionScheduler_Action( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK );
18
-		$this->assertInstanceOf( 'ActionScheduler_NullSchedule', $action->get_schedule() );
17
+		$action = new ActionScheduler_Action(ActionScheduler_Callbacks::HOOK_WITH_CALLBACK);
18
+		$this->assertInstanceOf('ActionScheduler_NullSchedule', $action->get_schedule());
19 19
 	}
20 20
 
21 21
 	public function test_set_hook() {
22
-		$action = new ActionScheduler_Action( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK );
23
-		$this->assertEquals( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK, $action->get_hook() );
22
+		$action = new ActionScheduler_Action(ActionScheduler_Callbacks::HOOK_WITH_CALLBACK);
23
+		$this->assertEquals(ActionScheduler_Callbacks::HOOK_WITH_CALLBACK, $action->get_hook());
24 24
 	}
25 25
 
26 26
 	public function test_args() {
27
-		$action = new ActionScheduler_Action( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK );
28
-		$this->assertEmpty( $action->get_args() );
27
+		$action = new ActionScheduler_Action(ActionScheduler_Callbacks::HOOK_WITH_CALLBACK);
28
+		$this->assertEmpty($action->get_args());
29 29
 
30
-		$action = new ActionScheduler_Action( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK, array( 5, 10, 15 ) );
31
-		$this->assertEqualSets( array( 5, 10, 15 ), $action->get_args() );
30
+		$action = new ActionScheduler_Action(ActionScheduler_Callbacks::HOOK_WITH_CALLBACK, array(5, 10, 15));
31
+		$this->assertEqualSets(array(5, 10, 15), $action->get_args());
32 32
 	}
33 33
 
34 34
 	public function test_set_group() {
35
-		$action = new ActionScheduler_Action( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK, array(), null, 'my_group' );
36
-		$this->assertEquals( 'my_group', $action->get_group() );
35
+		$action = new ActionScheduler_Action(ActionScheduler_Callbacks::HOOK_WITH_CALLBACK, array(), null, 'my_group');
36
+		$this->assertEquals('my_group', $action->get_group());
37 37
 	}
38 38
 
39 39
 	public function test_execute() {
40 40
 		$mock = new MockAction();
41 41
 
42
-		$random = md5( rand() );
43
-		add_action( $random, array( $mock, 'action' ) );
42
+		$random = md5(rand());
43
+		add_action($random, array($mock, 'action'));
44 44
 
45
-		$action = new ActionScheduler_Action( $random, array( $random ) );
45
+		$action = new ActionScheduler_Action($random, array($random));
46 46
 		$action->execute();
47 47
 
48
-		remove_action( $random, array( $mock, 'action' ) );
48
+		remove_action($random, array($mock, 'action'));
49 49
 
50
-		$this->assertSame( 1, $mock->get_call_count() );
50
+		$this->assertSame(1, $mock->get_call_count());
51 51
 		$events = $mock->get_events();
52
-		$event  = reset( $events );
53
-		$this->assertEquals( $random, reset( $event['args'] ) );
52
+		$event  = reset($events);
53
+		$this->assertEquals($random, reset($event['args']));
54 54
 	}
55 55
 }
Please login to merge, or discard this patch.
action-scheduler/tests/phpunit/jobs/ActionScheduler_NullAction_Test.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -6,12 +6,12 @@
 block discarded – undo
6 6
  * @group actions
7 7
  */
8 8
 class ActionScheduler_NullAction_Test extends ActionScheduler_UnitTestCase {
9
-	public function test_null_action() {
10
-		$action = new ActionScheduler_NullAction();
9
+    public function test_null_action() {
10
+        $action = new ActionScheduler_NullAction();
11 11
 
12
-		$this->assertEmpty( $action->get_hook() );
13
-		$this->assertEmpty( $action->get_args() );
14
-		$this->assertNull( $action->get_schedule()->get_date() );
15
-	}
12
+        $this->assertEmpty( $action->get_hook() );
13
+        $this->assertEmpty( $action->get_args() );
14
+        $this->assertNull( $action->get_schedule()->get_date() );
15
+    }
16 16
 }
17 17
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,9 +9,9 @@
 block discarded – undo
9 9
 	public function test_null_action() {
10 10
 		$action = new ActionScheduler_NullAction();
11 11
 
12
-		$this->assertEmpty( $action->get_hook() );
13
-		$this->assertEmpty( $action->get_args() );
14
-		$this->assertNull( $action->get_schedule()->get_date() );
12
+		$this->assertEmpty($action->get_hook());
13
+		$this->assertEmpty($action->get_args());
14
+		$this->assertNull($action->get_schedule()->get_date());
15 15
 	}
16 16
 }
17 17
 
Please login to merge, or discard this patch.
action-scheduler/tests/phpunit/runner/ActionScheduler_QueueCleaner_Test.php 2 patches
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -5,149 +5,149 @@
 block discarded – undo
5 5
  */
6 6
 class ActionScheduler_QueueCleaner_Test extends ActionScheduler_UnitTestCase {
7 7
 
8
-	public function test_delete_old_actions() {
9
-		$store  = ActionScheduler::store();
10
-		$runner = ActionScheduler_Mocker::get_queue_runner( $store );
8
+    public function test_delete_old_actions() {
9
+        $store  = ActionScheduler::store();
10
+        $runner = ActionScheduler_Mocker::get_queue_runner( $store );
11 11
 
12
-		$random   = md5( rand() );
13
-		$schedule = new ActionScheduler_SimpleSchedule( as_get_datetime_object( '1 day ago' ) );
12
+        $random   = md5( rand() );
13
+        $schedule = new ActionScheduler_SimpleSchedule( as_get_datetime_object( '1 day ago' ) );
14 14
 
15
-		$created_actions = array();
16
-		for ( $i = 0; $i < 5; $i++ ) {
17
-			$action            = new ActionScheduler_Action( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK, array( $random ), $schedule );
18
-			$created_actions[] = $store->save_action( $action );
19
-		}
15
+        $created_actions = array();
16
+        for ( $i = 0; $i < 5; $i++ ) {
17
+            $action            = new ActionScheduler_Action( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK, array( $random ), $schedule );
18
+            $created_actions[] = $store->save_action( $action );
19
+        }
20 20
 
21
-		$runner->run();
21
+        $runner->run();
22 22
 
23
-		add_filter( 'action_scheduler_retention_period', '__return_zero' ); // delete any finished job
24
-		$cleaner = new ActionScheduler_QueueCleaner( $store );
25
-		$cleaner->delete_old_actions();
26
-		remove_filter( 'action_scheduler_retention_period', '__return_zero' );
23
+        add_filter( 'action_scheduler_retention_period', '__return_zero' ); // delete any finished job
24
+        $cleaner = new ActionScheduler_QueueCleaner( $store );
25
+        $cleaner->delete_old_actions();
26
+        remove_filter( 'action_scheduler_retention_period', '__return_zero' );
27 27
 
28
-		foreach ( $created_actions as $action_id ) {
29
-			$action = $store->fetch_action( $action_id );
30
-			$this->assertFalse( $action->is_finished() ); // it's a NullAction
31
-		}
32
-	}
28
+        foreach ( $created_actions as $action_id ) {
29
+            $action = $store->fetch_action( $action_id );
30
+            $this->assertFalse( $action->is_finished() ); // it's a NullAction
31
+        }
32
+    }
33 33
 
34
-	public function test_delete_canceled_actions() {
35
-		$store = ActionScheduler::store();
34
+    public function test_delete_canceled_actions() {
35
+        $store = ActionScheduler::store();
36 36
 
37
-		$random   = md5( rand() );
38
-		$schedule = new ActionScheduler_SimpleSchedule( as_get_datetime_object( '1 day ago' ) );
39
-
40
-		$created_actions = array();
41
-		for ( $i = 0; $i < 5; $i++ ) {
42
-			$action    = new ActionScheduler_Action( $random, array( $random ), $schedule );
43
-			$action_id = $store->save_action( $action );
44
-			$store->cancel_action( $action_id );
45
-			$created_actions[] = $action_id;
46
-		}
37
+        $random   = md5( rand() );
38
+        $schedule = new ActionScheduler_SimpleSchedule( as_get_datetime_object( '1 day ago' ) );
39
+
40
+        $created_actions = array();
41
+        for ( $i = 0; $i < 5; $i++ ) {
42
+            $action    = new ActionScheduler_Action( $random, array( $random ), $schedule );
43
+            $action_id = $store->save_action( $action );
44
+            $store->cancel_action( $action_id );
45
+            $created_actions[] = $action_id;
46
+        }
47 47
 
48
-		// track the actions that are deleted
49
-		$mock_action = new MockAction();
50
-		add_action( 'action_scheduler_deleted_action', array( $mock_action, 'action' ), 10, 1 );
51
-		add_filter( 'action_scheduler_retention_period', '__return_zero' ); // delete any finished job
48
+        // track the actions that are deleted
49
+        $mock_action = new MockAction();
50
+        add_action( 'action_scheduler_deleted_action', array( $mock_action, 'action' ), 10, 1 );
51
+        add_filter( 'action_scheduler_retention_period', '__return_zero' ); // delete any finished job
52 52
 
53
-		$cleaner = new ActionScheduler_QueueCleaner( $store );
54
-		$cleaner->delete_old_actions();
53
+        $cleaner = new ActionScheduler_QueueCleaner( $store );
54
+        $cleaner->delete_old_actions();
55 55
 
56
-		remove_filter( 'action_scheduler_retention_period', '__return_zero' );
57
-		remove_action( 'action_scheduler_deleted_action', array( $mock_action, 'action' ), 10 );
56
+        remove_filter( 'action_scheduler_retention_period', '__return_zero' );
57
+        remove_action( 'action_scheduler_deleted_action', array( $mock_action, 'action' ), 10 );
58 58
 
59
-		$deleted_actions = array();
60
-		foreach ( $mock_action->get_args() as $action ) {
61
-			$deleted_actions[] = reset( $action );
62
-		}
59
+        $deleted_actions = array();
60
+        foreach ( $mock_action->get_args() as $action ) {
61
+            $deleted_actions[] = reset( $action );
62
+        }
63 63
 
64
-		$this->assertEqualSets( $created_actions, $deleted_actions );
65
-	}
64
+        $this->assertEqualSets( $created_actions, $deleted_actions );
65
+    }
66 66
 
67
-	public function test_do_not_delete_recent_actions() {
68
-		$store  = ActionScheduler::store();
69
-		$runner = ActionScheduler_Mocker::get_queue_runner( $store );
67
+    public function test_do_not_delete_recent_actions() {
68
+        $store  = ActionScheduler::store();
69
+        $runner = ActionScheduler_Mocker::get_queue_runner( $store );
70 70
 
71
-		$random   = md5( rand() );
72
-		$schedule = new ActionScheduler_SimpleSchedule( as_get_datetime_object( '1 day ago' ) );
71
+        $random   = md5( rand() );
72
+        $schedule = new ActionScheduler_SimpleSchedule( as_get_datetime_object( '1 day ago' ) );
73 73
 
74
-		$created_actions = array();
75
-		for ( $i = 0; $i < 5; $i++ ) {
76
-			$action            = new ActionScheduler_Action( $random, array( $random ), $schedule );
77
-			$created_actions[] = $store->save_action( $action );
78
-		}
74
+        $created_actions = array();
75
+        for ( $i = 0; $i < 5; $i++ ) {
76
+            $action            = new ActionScheduler_Action( $random, array( $random ), $schedule );
77
+            $created_actions[] = $store->save_action( $action );
78
+        }
79 79
 
80
-		$runner->run();
80
+        $runner->run();
81 81
 
82
-		$cleaner = new ActionScheduler_QueueCleaner( $store );
83
-		$cleaner->delete_old_actions();
82
+        $cleaner = new ActionScheduler_QueueCleaner( $store );
83
+        $cleaner->delete_old_actions();
84 84
 
85
-		foreach ( $created_actions as $action_id ) {
86
-			$action = $store->fetch_action( $action_id );
87
-			$this->assertTrue( $action->is_finished() ); // It's a FinishedAction
88
-		}
89
-	}
85
+        foreach ( $created_actions as $action_id ) {
86
+            $action = $store->fetch_action( $action_id );
87
+            $this->assertTrue( $action->is_finished() ); // It's a FinishedAction
88
+        }
89
+    }
90 90
 
91
-	public function test_reset_unrun_actions() {
92
-		$store = ActionScheduler::store();
91
+    public function test_reset_unrun_actions() {
92
+        $store = ActionScheduler::store();
93 93
 
94
-		$random   = md5( rand() );
95
-		$schedule = new ActionScheduler_SimpleSchedule( as_get_datetime_object( '1 day ago' ) );
94
+        $random   = md5( rand() );
95
+        $schedule = new ActionScheduler_SimpleSchedule( as_get_datetime_object( '1 day ago' ) );
96 96
 
97
-		$created_actions = array();
98
-		for ( $i = 0; $i < 5; $i++ ) {
99
-			$action            = new ActionScheduler_Action( $random, array( $random ), $schedule );
100
-			$created_actions[] = $store->save_action( $action );
101
-		}
97
+        $created_actions = array();
98
+        for ( $i = 0; $i < 5; $i++ ) {
99
+            $action            = new ActionScheduler_Action( $random, array( $random ), $schedule );
100
+            $created_actions[] = $store->save_action( $action );
101
+        }
102 102
 
103
-		$store->stake_claim( 10 );
103
+        $store->stake_claim( 10 );
104 104
 
105
-		// don't actually process the jobs, to simulate a request that timed out
105
+        // don't actually process the jobs, to simulate a request that timed out
106 106
 
107
-		add_filter( 'action_scheduler_timeout_period', '__return_zero' ); // delete any finished job
108
-		$cleaner = new ActionScheduler_QueueCleaner( $store );
109
-		$cleaner->reset_timeouts();
107
+        add_filter( 'action_scheduler_timeout_period', '__return_zero' ); // delete any finished job
108
+        $cleaner = new ActionScheduler_QueueCleaner( $store );
109
+        $cleaner->reset_timeouts();
110 110
 
111
-		remove_filter( 'action_scheduler_timeout_period', '__return_zero' );
111
+        remove_filter( 'action_scheduler_timeout_period', '__return_zero' );
112 112
 
113
-		$claim = $store->stake_claim( 10 );
114
-		$this->assertEqualSets( $created_actions, $claim->get_actions() );
115
-	}
113
+        $claim = $store->stake_claim( 10 );
114
+        $this->assertEqualSets( $created_actions, $claim->get_actions() );
115
+    }
116 116
 
117
-	public function test_do_not_reset_failed_action() {
118
-		$store = ActionScheduler::store();
117
+    public function test_do_not_reset_failed_action() {
118
+        $store = ActionScheduler::store();
119 119
 
120
-		$random   = md5( rand() );
121
-		$schedule = new ActionScheduler_SimpleSchedule( as_get_datetime_object( '1 day ago' ) );
120
+        $random   = md5( rand() );
121
+        $schedule = new ActionScheduler_SimpleSchedule( as_get_datetime_object( '1 day ago' ) );
122 122
 
123
-		$created_actions = array();
124
-		for ( $i = 0; $i < 5; $i++ ) {
125
-			$action            = new ActionScheduler_Action( $random, array( $random ), $schedule );
126
-			$created_actions[] = $store->save_action( $action );
127
-		}
123
+        $created_actions = array();
124
+        for ( $i = 0; $i < 5; $i++ ) {
125
+            $action            = new ActionScheduler_Action( $random, array( $random ), $schedule );
126
+            $created_actions[] = $store->save_action( $action );
127
+        }
128 128
 
129
-		$claim = $store->stake_claim( 10 );
130
-		foreach ( $claim->get_actions() as $action_id ) {
131
-			// simulate the first action interrupted by an uncatchable fatal error
132
-			$store->log_execution( $action_id );
133
-			break;
134
-		}
129
+        $claim = $store->stake_claim( 10 );
130
+        foreach ( $claim->get_actions() as $action_id ) {
131
+            // simulate the first action interrupted by an uncatchable fatal error
132
+            $store->log_execution( $action_id );
133
+            break;
134
+        }
135 135
 
136
-		add_filter( 'action_scheduler_timeout_period', '__return_zero' ); // delete any finished job
137
-		$cleaner = new ActionScheduler_QueueCleaner( $store );
138
-		$cleaner->reset_timeouts();
139
-		remove_filter( 'action_scheduler_timeout_period', '__return_zero' );
136
+        add_filter( 'action_scheduler_timeout_period', '__return_zero' ); // delete any finished job
137
+        $cleaner = new ActionScheduler_QueueCleaner( $store );
138
+        $cleaner->reset_timeouts();
139
+        remove_filter( 'action_scheduler_timeout_period', '__return_zero' );
140 140
 
141
-		$new_claim = $store->stake_claim( 10 );
142
-		$this->assertCount( 4, $new_claim->get_actions() );
141
+        $new_claim = $store->stake_claim( 10 );
142
+        $this->assertCount( 4, $new_claim->get_actions() );
143 143
 
144
-		add_filter( 'action_scheduler_failure_period', '__return_zero' );
145
-		$cleaner->mark_failures();
146
-		remove_filter( 'action_scheduler_failure_period', '__return_zero' );
144
+        add_filter( 'action_scheduler_failure_period', '__return_zero' );
145
+        $cleaner->mark_failures();
146
+        remove_filter( 'action_scheduler_failure_period', '__return_zero' );
147 147
 
148
-		$failed = $store->query_actions( array( 'status' => ActionScheduler_Store::STATUS_FAILED ) );
149
-		$this->assertEquals( $created_actions[0], $failed[0] );
150
-		$this->assertCount( 1, $failed );
148
+        $failed = $store->query_actions( array( 'status' => ActionScheduler_Store::STATUS_FAILED ) );
149
+        $this->assertEquals( $created_actions[0], $failed[0] );
150
+        $this->assertCount( 1, $failed );
151 151
 
152
-	}
152
+    }
153 153
 }
Please login to merge, or discard this patch.
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -7,147 +7,147 @@
 block discarded – undo
7 7
 
8 8
 	public function test_delete_old_actions() {
9 9
 		$store  = ActionScheduler::store();
10
-		$runner = ActionScheduler_Mocker::get_queue_runner( $store );
10
+		$runner = ActionScheduler_Mocker::get_queue_runner($store);
11 11
 
12
-		$random   = md5( rand() );
13
-		$schedule = new ActionScheduler_SimpleSchedule( as_get_datetime_object( '1 day ago' ) );
12
+		$random   = md5(rand());
13
+		$schedule = new ActionScheduler_SimpleSchedule(as_get_datetime_object('1 day ago'));
14 14
 
15 15
 		$created_actions = array();
16
-		for ( $i = 0; $i < 5; $i++ ) {
17
-			$action            = new ActionScheduler_Action( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK, array( $random ), $schedule );
18
-			$created_actions[] = $store->save_action( $action );
16
+		for ($i = 0; $i < 5; $i++) {
17
+			$action            = new ActionScheduler_Action(ActionScheduler_Callbacks::HOOK_WITH_CALLBACK, array($random), $schedule);
18
+			$created_actions[] = $store->save_action($action);
19 19
 		}
20 20
 
21 21
 		$runner->run();
22 22
 
23
-		add_filter( 'action_scheduler_retention_period', '__return_zero' ); // delete any finished job
24
-		$cleaner = new ActionScheduler_QueueCleaner( $store );
23
+		add_filter('action_scheduler_retention_period', '__return_zero'); // delete any finished job
24
+		$cleaner = new ActionScheduler_QueueCleaner($store);
25 25
 		$cleaner->delete_old_actions();
26
-		remove_filter( 'action_scheduler_retention_period', '__return_zero' );
26
+		remove_filter('action_scheduler_retention_period', '__return_zero');
27 27
 
28
-		foreach ( $created_actions as $action_id ) {
29
-			$action = $store->fetch_action( $action_id );
30
-			$this->assertFalse( $action->is_finished() ); // it's a NullAction
28
+		foreach ($created_actions as $action_id) {
29
+			$action = $store->fetch_action($action_id);
30
+			$this->assertFalse($action->is_finished()); // it's a NullAction
31 31
 		}
32 32
 	}
33 33
 
34 34
 	public function test_delete_canceled_actions() {
35 35
 		$store = ActionScheduler::store();
36 36
 
37
-		$random   = md5( rand() );
38
-		$schedule = new ActionScheduler_SimpleSchedule( as_get_datetime_object( '1 day ago' ) );
37
+		$random   = md5(rand());
38
+		$schedule = new ActionScheduler_SimpleSchedule(as_get_datetime_object('1 day ago'));
39 39
 
40 40
 		$created_actions = array();
41
-		for ( $i = 0; $i < 5; $i++ ) {
42
-			$action    = new ActionScheduler_Action( $random, array( $random ), $schedule );
43
-			$action_id = $store->save_action( $action );
44
-			$store->cancel_action( $action_id );
41
+		for ($i = 0; $i < 5; $i++) {
42
+			$action    = new ActionScheduler_Action($random, array($random), $schedule);
43
+			$action_id = $store->save_action($action);
44
+			$store->cancel_action($action_id);
45 45
 			$created_actions[] = $action_id;
46 46
 		}
47 47
 
48 48
 		// track the actions that are deleted
49 49
 		$mock_action = new MockAction();
50
-		add_action( 'action_scheduler_deleted_action', array( $mock_action, 'action' ), 10, 1 );
51
-		add_filter( 'action_scheduler_retention_period', '__return_zero' ); // delete any finished job
50
+		add_action('action_scheduler_deleted_action', array($mock_action, 'action'), 10, 1);
51
+		add_filter('action_scheduler_retention_period', '__return_zero'); // delete any finished job
52 52
 
53
-		$cleaner = new ActionScheduler_QueueCleaner( $store );
53
+		$cleaner = new ActionScheduler_QueueCleaner($store);
54 54
 		$cleaner->delete_old_actions();
55 55
 
56
-		remove_filter( 'action_scheduler_retention_period', '__return_zero' );
57
-		remove_action( 'action_scheduler_deleted_action', array( $mock_action, 'action' ), 10 );
56
+		remove_filter('action_scheduler_retention_period', '__return_zero');
57
+		remove_action('action_scheduler_deleted_action', array($mock_action, 'action'), 10);
58 58
 
59 59
 		$deleted_actions = array();
60
-		foreach ( $mock_action->get_args() as $action ) {
61
-			$deleted_actions[] = reset( $action );
60
+		foreach ($mock_action->get_args() as $action) {
61
+			$deleted_actions[] = reset($action);
62 62
 		}
63 63
 
64
-		$this->assertEqualSets( $created_actions, $deleted_actions );
64
+		$this->assertEqualSets($created_actions, $deleted_actions);
65 65
 	}
66 66
 
67 67
 	public function test_do_not_delete_recent_actions() {
68 68
 		$store  = ActionScheduler::store();
69
-		$runner = ActionScheduler_Mocker::get_queue_runner( $store );
69
+		$runner = ActionScheduler_Mocker::get_queue_runner($store);
70 70
 
71
-		$random   = md5( rand() );
72
-		$schedule = new ActionScheduler_SimpleSchedule( as_get_datetime_object( '1 day ago' ) );
71
+		$random   = md5(rand());
72
+		$schedule = new ActionScheduler_SimpleSchedule(as_get_datetime_object('1 day ago'));
73 73
 
74 74
 		$created_actions = array();
75
-		for ( $i = 0; $i < 5; $i++ ) {
76
-			$action            = new ActionScheduler_Action( $random, array( $random ), $schedule );
77
-			$created_actions[] = $store->save_action( $action );
75
+		for ($i = 0; $i < 5; $i++) {
76
+			$action            = new ActionScheduler_Action($random, array($random), $schedule);
77
+			$created_actions[] = $store->save_action($action);
78 78
 		}
79 79
 
80 80
 		$runner->run();
81 81
 
82
-		$cleaner = new ActionScheduler_QueueCleaner( $store );
82
+		$cleaner = new ActionScheduler_QueueCleaner($store);
83 83
 		$cleaner->delete_old_actions();
84 84
 
85
-		foreach ( $created_actions as $action_id ) {
86
-			$action = $store->fetch_action( $action_id );
87
-			$this->assertTrue( $action->is_finished() ); // It's a FinishedAction
85
+		foreach ($created_actions as $action_id) {
86
+			$action = $store->fetch_action($action_id);
87
+			$this->assertTrue($action->is_finished()); // It's a FinishedAction
88 88
 		}
89 89
 	}
90 90
 
91 91
 	public function test_reset_unrun_actions() {
92 92
 		$store = ActionScheduler::store();
93 93
 
94
-		$random   = md5( rand() );
95
-		$schedule = new ActionScheduler_SimpleSchedule( as_get_datetime_object( '1 day ago' ) );
94
+		$random   = md5(rand());
95
+		$schedule = new ActionScheduler_SimpleSchedule(as_get_datetime_object('1 day ago'));
96 96
 
97 97
 		$created_actions = array();
98
-		for ( $i = 0; $i < 5; $i++ ) {
99
-			$action            = new ActionScheduler_Action( $random, array( $random ), $schedule );
100
-			$created_actions[] = $store->save_action( $action );
98
+		for ($i = 0; $i < 5; $i++) {
99
+			$action            = new ActionScheduler_Action($random, array($random), $schedule);
100
+			$created_actions[] = $store->save_action($action);
101 101
 		}
102 102
 
103
-		$store->stake_claim( 10 );
103
+		$store->stake_claim(10);
104 104
 
105 105
 		// don't actually process the jobs, to simulate a request that timed out
106 106
 
107
-		add_filter( 'action_scheduler_timeout_period', '__return_zero' ); // delete any finished job
108
-		$cleaner = new ActionScheduler_QueueCleaner( $store );
107
+		add_filter('action_scheduler_timeout_period', '__return_zero'); // delete any finished job
108
+		$cleaner = new ActionScheduler_QueueCleaner($store);
109 109
 		$cleaner->reset_timeouts();
110 110
 
111
-		remove_filter( 'action_scheduler_timeout_period', '__return_zero' );
111
+		remove_filter('action_scheduler_timeout_period', '__return_zero');
112 112
 
113
-		$claim = $store->stake_claim( 10 );
114
-		$this->assertEqualSets( $created_actions, $claim->get_actions() );
113
+		$claim = $store->stake_claim(10);
114
+		$this->assertEqualSets($created_actions, $claim->get_actions());
115 115
 	}
116 116
 
117 117
 	public function test_do_not_reset_failed_action() {
118 118
 		$store = ActionScheduler::store();
119 119
 
120
-		$random   = md5( rand() );
121
-		$schedule = new ActionScheduler_SimpleSchedule( as_get_datetime_object( '1 day ago' ) );
120
+		$random   = md5(rand());
121
+		$schedule = new ActionScheduler_SimpleSchedule(as_get_datetime_object('1 day ago'));
122 122
 
123 123
 		$created_actions = array();
124
-		for ( $i = 0; $i < 5; $i++ ) {
125
-			$action            = new ActionScheduler_Action( $random, array( $random ), $schedule );
126
-			$created_actions[] = $store->save_action( $action );
124
+		for ($i = 0; $i < 5; $i++) {
125
+			$action            = new ActionScheduler_Action($random, array($random), $schedule);
126
+			$created_actions[] = $store->save_action($action);
127 127
 		}
128 128
 
129
-		$claim = $store->stake_claim( 10 );
130
-		foreach ( $claim->get_actions() as $action_id ) {
129
+		$claim = $store->stake_claim(10);
130
+		foreach ($claim->get_actions() as $action_id) {
131 131
 			// simulate the first action interrupted by an uncatchable fatal error
132
-			$store->log_execution( $action_id );
132
+			$store->log_execution($action_id);
133 133
 			break;
134 134
 		}
135 135
 
136
-		add_filter( 'action_scheduler_timeout_period', '__return_zero' ); // delete any finished job
137
-		$cleaner = new ActionScheduler_QueueCleaner( $store );
136
+		add_filter('action_scheduler_timeout_period', '__return_zero'); // delete any finished job
137
+		$cleaner = new ActionScheduler_QueueCleaner($store);
138 138
 		$cleaner->reset_timeouts();
139
-		remove_filter( 'action_scheduler_timeout_period', '__return_zero' );
139
+		remove_filter('action_scheduler_timeout_period', '__return_zero');
140 140
 
141
-		$new_claim = $store->stake_claim( 10 );
142
-		$this->assertCount( 4, $new_claim->get_actions() );
141
+		$new_claim = $store->stake_claim(10);
142
+		$this->assertCount(4, $new_claim->get_actions());
143 143
 
144
-		add_filter( 'action_scheduler_failure_period', '__return_zero' );
144
+		add_filter('action_scheduler_failure_period', '__return_zero');
145 145
 		$cleaner->mark_failures();
146
-		remove_filter( 'action_scheduler_failure_period', '__return_zero' );
146
+		remove_filter('action_scheduler_failure_period', '__return_zero');
147 147
 
148
-		$failed = $store->query_actions( array( 'status' => ActionScheduler_Store::STATUS_FAILED ) );
149
-		$this->assertEquals( $created_actions[0], $failed[0] );
150
-		$this->assertCount( 1, $failed );
148
+		$failed = $store->query_actions(array('status' => ActionScheduler_Store::STATUS_FAILED));
149
+		$this->assertEquals($created_actions[0], $failed[0]);
150
+		$this->assertCount(1, $failed);
151 151
 
152 152
 	}
153 153
 }
Please login to merge, or discard this patch.