WordPress.org

Make WordPress Core

Ticket #18997: 18997-tests.patch

File 18997-tests.patch, 1.1 KB (added by mordauk, 5 years ago)
  • tests/phpunit/tests/cron.php

     
    124124                $this->assertFalse( wp_next_scheduled($hook, $args) );
    125125        }
    126126
     127        function test_unschedule_hook() {
     128                $hook = rand_str();
     129                $args = array(rand_str());
     130
     131                // schedule several events with and without arguments
     132                wp_schedule_single_event( strtotime('+1 hour'), $hook );
     133                wp_schedule_single_event( strtotime('+2 hour'), $hook );
     134                wp_schedule_single_event( strtotime('+3 hour'), $hook, $args );
     135                wp_schedule_single_event( strtotime('+4 hour'), $hook, $args );
     136
     137                // make sure they're returned by wp_next_scheduled()
     138                $this->assertTrue( wp_next_scheduled($hook) > 0 );
     139                $this->assertTrue( wp_next_scheduled($hook, $args) > 0 );
     140
     141                // clear the schedule for the no args events and make sure it's gone
     142                wp_unschedule_hook($hook);
     143                $this->assertFalse( wp_next_scheduled($hook) );
     144        }
     145
    127146        function test_clear_schedule_multiple_args() {
    128147                $hook = rand_str();
    129148                $args = array(rand_str(), rand_str());