Skip to content

Commit

Permalink
Merge pull request #14499 from dadarya0/set-timezone-to-fix-test-cases
Browse files Browse the repository at this point in the history
Set timezone to fix test cases
  • Loading branch information
escopecz authored Jan 24, 2025
2 parents b36cc9d + 6532516 commit 1959c1c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/bundles/CoreBundle/Test/MauticMysqlTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ protected function setUp(): void
*/
final protected function tearDown(): void
{
date_default_timezone_set('UTC');
$this->restoreLocalConfig();
$customFieldsReset = $this->resetCustomFields();
$this->beforeTearDown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ public function testGeneratedDateColumn(): void

public function testPhpOrderingInCompleteTimeDataHour(): void
{
$this->dateFrom = new \DateTime('2020-12-01 00:00:00.000000');
$this->dateTo = new \DateTime('2020-12-02 13:31:55.492167');
$this->dateFrom = new \DateTime('2020-12-01 00:00:00.000000', new \DateTimeZone('UTC'));
$this->dateTo = new \DateTime('2020-12-02 13:31:55.492167', new \DateTimeZone('UTC'));
$this->unit = 'H';
$expectedResult = [
0 => 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ class FormatterHelperTest extends \PHPUnit\Framework\TestCase
*/
private \PHPUnit\Framework\MockObject\MockObject $coreParametersHelper;

private string $previousTimeZone;

protected function setUp(): void
{
$this->previousTimeZone = date_default_timezone_get();
$this->translator = $this->createMock(TranslatorInterface::class);
$this->coreParametersHelper = $this->createMock(CoreParametersHelper::class);
$this->dateHelper = new DateHelper(
Expand All @@ -40,6 +43,11 @@ protected function setUp(): void
$this->formatterHelper = new FormatterHelper($this->dateHelper, $this->translator);
}

protected function tearDown(): void
{
date_default_timezone_set($this->previousTimeZone);
}

public function testStrictHtmlFormatIsRemovingScriptTags(): void
{
$sample = '<a href="/s/webhooks/view/31" data-toggle="ajax">test</a> has been stopped because the response HTTP code was 410, which means the reciever doesn\'t want us to send more requests.<script>console.log(\'script is running\');</script><SCRIPT>console.log(\'CAPITAL script is running\');</SCRIPT>';
Expand Down

0 comments on commit 1959c1c

Please sign in to comment.