mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-05 07:07:04 +00:00
Tests: Use more appropriate assertions in various tests.
This replaces instances of `assertTrue( ... > 0 )` with `assertGreaterThan()` to use native PHPUnit functionality. Follow-up to [51335], [51337], [51367], [51397], [51403], [51404], [51436], [51438], [51448], [51449], [51451], [51453]. See #53363. git-svn-id: https://develop.svn.wordpress.org/trunk@51454 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -126,15 +126,15 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
wp_schedule_single_event( strtotime( '+4 hour' ), $hook, $args );
|
||||
|
||||
// Make sure they're returned by wp_next_scheduled().
|
||||
$this->assertTrue( wp_next_scheduled( $hook ) > 0 );
|
||||
$this->assertTrue( wp_next_scheduled( $hook, $args ) > 0 );
|
||||
$this->assertGreaterThan( 0, wp_next_scheduled( $hook ) );
|
||||
$this->assertGreaterThan( 0, wp_next_scheduled( $hook, $args ) );
|
||||
|
||||
// Clear the schedule for the no args events and make sure it's gone.
|
||||
$hook_unscheduled = wp_clear_scheduled_hook( $hook );
|
||||
$this->assertSame( 2, $hook_unscheduled );
|
||||
$this->assertFalse( wp_next_scheduled( $hook ) );
|
||||
// The args events should still be there.
|
||||
$this->assertTrue( wp_next_scheduled( $hook, $args ) > 0 );
|
||||
$this->assertGreaterThan( 0, wp_next_scheduled( $hook, $args ) );
|
||||
|
||||
// Clear the schedule for the args events and make sure they're gone too.
|
||||
// Note: wp_clear_scheduled_hook() expects args passed directly, rather than as an array.
|
||||
@@ -165,14 +165,14 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
wp_schedule_single_event( strtotime( '+4 hour' ), $hook, $args );
|
||||
|
||||
// Make sure they're returned by wp_next_scheduled().
|
||||
$this->assertTrue( wp_next_scheduled( $hook ) > 0 );
|
||||
$this->assertTrue( wp_next_scheduled( $hook, $args ) > 0 );
|
||||
$this->assertGreaterThan( 0, wp_next_scheduled( $hook ) );
|
||||
$this->assertGreaterThan( 0, wp_next_scheduled( $hook, $args ) );
|
||||
|
||||
// Clear the schedule for the no args events and make sure it's gone.
|
||||
wp_clear_scheduled_hook( $hook );
|
||||
$this->assertFalse( wp_next_scheduled( $hook ) );
|
||||
// The args events should still be there.
|
||||
$this->assertTrue( wp_next_scheduled( $hook, $args ) > 0 );
|
||||
$this->assertGreaterThan( 0, wp_next_scheduled( $hook, $args ) );
|
||||
|
||||
// Clear the schedule for the args events and make sure they're gone too.
|
||||
// Note: wp_clear_scheduled_hook() used to expect args passed directly, rather than as an array pre WP 3.0.
|
||||
@@ -198,14 +198,14 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
wp_schedule_single_event( strtotime( '+6 hour' ), $multi_hook, $multi_args );
|
||||
|
||||
// Make sure they're returned by wp_next_scheduled().
|
||||
$this->assertTrue( wp_next_scheduled( $hook ) > 0 );
|
||||
$this->assertTrue( wp_next_scheduled( $hook, $args ) > 0 );
|
||||
$this->assertGreaterThan( 0, wp_next_scheduled( $hook ) );
|
||||
$this->assertGreaterThan( 0, wp_next_scheduled( $hook, $args ) );
|
||||
|
||||
// Clear the schedule for the no args events and make sure it's gone.
|
||||
wp_clear_scheduled_hook( $hook );
|
||||
$this->assertFalse( wp_next_scheduled( $hook ) );
|
||||
// The args events should still be there.
|
||||
$this->assertTrue( wp_next_scheduled( $hook, $args ) > 0 );
|
||||
$this->assertGreaterThan( 0, wp_next_scheduled( $hook, $args ) );
|
||||
|
||||
// Clear the schedule for the args events and make sure they're gone too.
|
||||
// wp_clear_scheduled_hook() should take args as an array like the other functions.
|
||||
@@ -232,8 +232,8 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
wp_schedule_single_event( strtotime( '+4 hour' ), $hook, $args );
|
||||
|
||||
// Make sure they're returned by wp_next_scheduled().
|
||||
$this->assertTrue( wp_next_scheduled( $hook ) > 0 );
|
||||
$this->assertTrue( wp_next_scheduled( $hook, $args ) > 0 );
|
||||
$this->assertGreaterThan( 0, wp_next_scheduled( $hook ) );
|
||||
$this->assertGreaterThan( 0, wp_next_scheduled( $hook, $args ) );
|
||||
|
||||
// Clear the schedule and make sure it's gone.
|
||||
$unschedule_hook = wp_unschedule_hook( $hook );
|
||||
|
||||
Reference in New Issue
Block a user