| 344 | function test_duplicate_past_to_future_event() { |
| 345 | // duplicate events close together should be skipped |
| 346 | $hook = __FUNCTION__; |
| 347 | $args = array( 'arg1' ); |
| 348 | $ts1 = strtotime( '-5 minutes' ); |
| 349 | $ts2 = strtotime( '+3 minutes' ); |
| 350 | |
| 351 | |
| 352 | // first one works |
| 353 | $this->assertTrue( wp_schedule_single_event( $ts1, $hook, $args ) ); |
| 354 | // second one is ignored |
| 355 | $this->assertFalse( wp_schedule_single_event( $ts2, $hook, $args ) ); |
| 356 | |
| 357 | // the next event should be at -5 minutes |
| 358 | $this->assertEquals( $ts1, wp_next_scheduled( $hook, $args ) ); |
| 359 | } |
| 360 | |
| 361 | /** |
| 362 | * @ticket 44818 |
| 363 | */ |
| 364 | function test_not_duplicate_past_to_future_event() { |
| 365 | // duplicate events far apart should work normally |
| 366 | $hook = __FUNCTION__; |
| 367 | $args = array( 'arg1' ); |
| 368 | $ts1 = strtotime( '-5 minutes' ); |
| 369 | $ts2 = strtotime( '+6 minutes' ); |
| 370 | |
| 371 | // first one works |
| 372 | $this->assertTrue( wp_schedule_single_event( $ts1, $hook, $args ) ); |
| 373 | // second works too |
| 374 | $this->assertTrue( wp_schedule_single_event( $ts2, $hook, $args ) ); |
| 375 | |
| 376 | // the next event should be at -5 minutes, even though that one was scheduled second |
| 377 | $this->assertEquals( $ts1, wp_next_scheduled( $hook, $args ) ); |
| 378 | wp_unschedule_event( $ts1, $hook, $args ); |
| 379 | // following event at +6 minutes should be there too |
| 380 | $this->assertEquals( $ts2, wp_next_scheduled( $hook, $args ) ); |
| 381 | } |
| 382 | |
| 383 | /** |
| 384 | * @ticket 44818 |
| 385 | */ |