mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-13 03:36:28 +09:00
797bc2fd98
git-subtree-dir: includes/lib/action-scheduler git-subtree-split: c828347715e6c3318c8ab8b4fea2d87b31d51aac
61 lines
1.3 KiB
PHP
61 lines
1.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Class ActionScheduler_UnitTestCase
|
|
*/
|
|
class ActionScheduler_UnitTestCase extends WP_UnitTestCase {
|
|
|
|
protected $existing_timezone;
|
|
|
|
/**
|
|
* Perform test set-up work.
|
|
*/
|
|
public function set_up() {
|
|
ActionScheduler_Callbacks::add_callbacks();
|
|
parent::set_up();
|
|
}
|
|
|
|
/**
|
|
* Perform test tear-down work.
|
|
*/
|
|
public function tear_down() {
|
|
ActionScheduler_Callbacks::remove_callbacks();
|
|
parent::tear_down();
|
|
}
|
|
|
|
/**
|
|
* Counts the number of test cases executed by run(TestResult result).
|
|
*
|
|
* @return int
|
|
*/
|
|
public function count(): int {
|
|
return 'UTC' == date_default_timezone_get() ? 2 : 3;
|
|
}
|
|
|
|
/**
|
|
* We want to run every test multiple times using a different timezone to make sure
|
|
* that they are unaffected by changes to PHP's timezone.
|
|
*/
|
|
public function run( PHPUnit\Framework\TestResult $result = NULL ): \PHPUnit\Framework\TestResult {
|
|
|
|
if ($result === NULL) {
|
|
$result = $this->createResult();
|
|
}
|
|
|
|
if ( 'UTC' != ( $this->existing_timezone = date_default_timezone_get() ) ) {
|
|
date_default_timezone_set( 'UTC' );
|
|
$result->run( $this );
|
|
}
|
|
|
|
date_default_timezone_set( 'Pacific/Fiji' ); // UTC+12
|
|
$result->run( $this );
|
|
|
|
date_default_timezone_set( 'Pacific/Tahiti' ); // UTC-10: it's a magical place
|
|
$result->run( $this );
|
|
|
|
date_default_timezone_set( $this->existing_timezone );
|
|
|
|
return $result;
|
|
}
|
|
}
|