Files
ultimatemember/tests/phpunit/jobstore/ActionScheduler_DBStoreMigrator_Test.php
T
Yurii Nalivaiko 797bc2fd98 Squashed 'includes/lib/action-scheduler/' content from commit c82834771
git-subtree-dir: includes/lib/action-scheduler
git-subtree-split: c828347715e6c3318c8ab8b4fea2d87b31d51aac
2024-09-03 12:28:53 +02:00

27 lines
1.0 KiB
PHP

<?php
/**
* Class ActionScheduler_DBStoreMigrator_Test
* @group tables
*/
class ActionScheduler_DBStoreMigrator_Test extends ActionScheduler_UnitTestCase {
public function test_create_action_with_last_attempt_date() {
$scheduled_date = as_get_datetime_object( strtotime( '-24 hours' ) );
$last_attempt_date = as_get_datetime_object( strtotime( '-23 hours' ) );
$action = new ActionScheduler_FinishedAction( ActionScheduler_Callbacks::HOOK_WITH_CALLBACK, [], new ActionScheduler_SimpleSchedule( $scheduled_date ) );
$store = new ActionScheduler_DBStoreMigrator();
$action_id = $store->save_action( $action, null, $last_attempt_date );
$action_date = $store->get_date( $action_id );
$this->assertEquals( $last_attempt_date->format( 'U' ), $action_date->format( 'U' ) );
$action_id = $store->save_action( $action, $scheduled_date, $last_attempt_date );
$action_date = $store->get_date( $action_id );
$this->assertEquals( $last_attempt_date->format( 'U' ), $action_date->format( 'U' ) );
}
}