SimplenewsSchedulerDaylightSavingSwitchTest.php in Simplenews Scheduler 2.0.x
File
tests/src/Functional/SimplenewsSchedulerDaylightSavingSwitchTest.php
View source
<?php
namespace Drupal\Tests\simplenews_scheduler\Functional;
class SimplenewsSchedulerDaylightSavingSwitchTest extends SimplenewsSchedulerTestBase {
function testDSTMonthly() {
$timezone_name = date_default_timezone_get();
$last_run_date = new \DateTime("01-Mar-12 12:00:00");
$now_date = date_create("05-Apr-12 12:00:00");
$newsletter_parent_data = (object) array(
'last_run' => $last_run_date
->getTimestamp(),
'send_interval' => 'month',
'interval_frequency' => 1,
);
$edition_time = simplenews_scheduler_calculate_edition_time($newsletter_parent_data, $now_date
->getTimestamp());
$edition_date = date_create('@' . $edition_time);
$edition_time_formatted = \Drupal::service('date.formatter')
->format($edition_time, 'custom', DATE_ATOM);
$edition_hour_formatted = \Drupal::service('date.formatter')
->format($edition_time, 'custom', 'H:i');
$this
->assertEqual($edition_hour_formatted, '12:00', t('Edition time is at 12:00 in the local timezone; full edition time is %time.', array(
'%time' => $edition_time_formatted,
)));
}
}