Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

require __DIR__ . '/../vendor/autoload.php';

date_default_timezone_set( 'Europe/Berlin' );

// The check is to ensure we don't use .env in production
if ( !isset( $_SERVER['APP_ENV'] ) && !isset( $_ENV['APP_ENV'] ) ) {
if ( !class_exists( Dotenv::class ) ) {
Expand Down
4 changes: 2 additions & 2 deletions src/Utils/CampaignConfigurationLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ private function buildCampaignFromData( string $campaignName, array $campaignDat

return new Campaign(
$campaignName,
new \DateTime( $start ),
new \DateTime( $end ),
new \DateTime( $start, new \DateTimeZone( 'Europe/Berlin' ) ),
new \DateTime( $end, new \DateTimeZone( 'Europe/Berlin' ) ),
$trafficLimit,
$category,
new SystemRandomIntegerGenerator(),
Expand Down
10 changes: 10 additions & 0 deletions tests/Unit/Utils/CampaignConfigurationLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ public function test_given_campaigns_are_loaded_then_loaded_campaign_data_is_cor
$this->assertEquals( 'B18WPDE_02_180511_top_ctrl_last', $bucketA->getBanner( 10 ) );
}

public function test_loaded_campaign_start_end_dates_are_in_CET_Berlin_timezone(): void {
$loader = new CampaignConfigurationLoader( self::TEST_VALID_CAMPAIGN_CONFIGURATION_FILE );
$collection = $loader->getCampaignCollection();

$campaign = $collection->getCampaign( new DateTime( "2018-11-31 01:23:45" ) );

$this->assertNotNull( $campaign );
$this->assertSame( 'Europe/Berlin', $campaign->getEnd()->getTimezone()->getName() );
}

public function test_given_broken_bucket_campaign_configuration_then_errors_are_caught(): void {
$loader = new CampaignConfigurationLoader(
self::TEST_BROKEN_BUCKET_CAMPAIGN_CONFIGURATION_FILE
Expand Down
2 changes: 2 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

require dirname( __DIR__ ) . '/vendor/autoload.php';

date_default_timezone_set( 'Europe/Berlin' );

if ( file_exists( dirname( __DIR__ ) . '/config/bootstrap.php' ) ) {
require dirname( __DIR__ ) . '/config/bootstrap.php';
} elseif ( method_exists( Dotenv::class, 'bootEnv' ) ) {
Expand Down