Changeset 39554
- Timestamp:
- 12/09/2016 11:11:28 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/cron.php
r38763 r39554 250 250 } 251 251 } 252 253 /*254 * Disable the WP Cron running test for the moment as it kills the whole test suite.255 * TODO - Fix it to work with the new cron implementation in trunk256 *257 class WPTestCronRunning extends _WPEmptyBlog {258 function setUp() {259 parent::setUp();260 // make sure the schedule is clear261 _set_cron_array(array());262 }263 264 function tearDown() {265 parent::tearDown();266 // make sure the schedule is clear267 _set_cron_array(array());268 }269 function _do_cron() {270 // FIXME: wp-cron.php is difficult to test, could be wrapped in a function271 $_GET['check'] = wp_hash('187425');272 require(ABSPATH.'/wp-cron.php');273 }274 275 function test_run_schedule_single() {276 // schedule an event, run it, and make sure the hook is called277 $hook = __FUNCTION__;278 $args = array(rand_str());279 $timestamp = strtotime('-1 second');280 281 // register a test action282 $a = new MockAction();283 add_action($hook, array(&$a, 'action'));284 285 // schedule an event for 1 second ago286 wp_schedule_single_event( $timestamp, $hook, $args );287 $this->assertEquals( $timestamp, wp_next_scheduled($hook, $args) );288 289 // run cron jobs290 $this->_do_cron();291 292 // our action should have been called once with the correct args293 $this->assertEquals( 1, $a->get_call_count() );294 $this->assertEquals( array($args), $a->get_args() );295 296 // it shouldn't appear in the schedule anymore297 $this->assertFalse( wp_next_scheduled($hook, $args) );298 299 }300 301 function test_run_schedule_recurring() {302 // schedule a recurring event, run it, and make sure the hook is called303 $hook = __FUNCTION__;304 $args = array(rand_str());305 $timestamp = strtotime('-1 second');306 $recur = 'hourly';307 308 // register a test action309 $a = new MockAction();310 add_action($hook, array(&$a, 'action'));311 312 // schedule an event for 1 second ago313 wp_schedule_event( $timestamp, $recur, $hook, $args );314 $this->assertEquals( $timestamp, wp_next_scheduled($hook, $args) );315 $this->assertEquals( $recur, wp_get_schedule($hook, $args) );316 317 // run cron jobs318 $this->_do_cron();319 320 // our action should have been called once with the correct args321 $this->assertEquals( 1, $a->get_call_count() );322 $this->assertEquals( array($args), $a->get_args() );323 324 // it should appear in the schedule to run again in an hour's time325 $this->assertEquals( $timestamp + 3600, wp_next_scheduled($hook, $args) );326 327 }328 }329 */
Note: See TracChangeset
for help on using the changeset viewer.