Enable Discovery debug logging for production troubleshooting
- Add DISCOVERY_LOG_LEVEL=debug - Add DISCOVERY_SHOW_PROGRESS=true - Temporary changes for debugging InitializerProcessor fixes on production
This commit is contained in:
@@ -1,64 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Framework\DateTime;
|
||||
declare(strict_types=1);
|
||||
|
||||
use App\Framework\DateTime\DateTimeFormatter;
|
||||
|
||||
class DateTimeFormatterTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private \DateTimeImmutable $sampleDate;
|
||||
private DateTimeFormatter $formatter;
|
||||
beforeEach(function () {
|
||||
$this->sampleDate = new \DateTimeImmutable('2021-01-01 12:34:56', new \DateTimeZone('UTC'));
|
||||
$this->formatter = new DateTimeFormatter('UTC'); // Explicitly use UTC
|
||||
});
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->sampleDate = new \DateTimeImmutable('2021-01-01 12:34:56', new \DateTimeZone('UTC'));
|
||||
$this->formatter = new DateTimeFormatter();
|
||||
}
|
||||
test('format iso8601 returns correct format', function () {
|
||||
$formatted = $this->formatter->formatIso8601($this->sampleDate);
|
||||
|
||||
public function testFormatIso8601(): void
|
||||
{
|
||||
$formatted = $this->formatter->formatIso8601($this->sampleDate);
|
||||
$this->assertEquals('2021-01-01T12:34:56+00:00', $formatted);
|
||||
}
|
||||
expect($formatted)->toBe('2021-01-01T12:34:56+00:00');
|
||||
});
|
||||
|
||||
public function testFormatSql(): void
|
||||
{
|
||||
$formatted = $this->formatter->formatSql($this->sampleDate);
|
||||
$this->assertEquals('2021-01-01 12:34:56', $formatted);
|
||||
}
|
||||
test('format sql returns correct format', function () {
|
||||
$formatted = $this->formatter->formatSql($this->sampleDate);
|
||||
|
||||
public function testFormatDate(): void
|
||||
{
|
||||
$formatted = $this->formatter->formatDate($this->sampleDate);
|
||||
$this->assertEquals('2021-01-01', $formatted);
|
||||
}
|
||||
expect($formatted)->toBe('2021-01-01 12:34:56');
|
||||
});
|
||||
|
||||
public function testFormatTime(): void
|
||||
{
|
||||
$formatted = $this->formatter->formatTime($this->sampleDate);
|
||||
$this->assertEquals('12:34:56', $formatted);
|
||||
}
|
||||
test('format date returns correct format', function () {
|
||||
$formatted = $this->formatter->formatDate($this->sampleDate);
|
||||
|
||||
public function testCustomFormat(): void
|
||||
{
|
||||
$formatted = $this->formatter->format($this->sampleDate, 'd.m.Y H:i');
|
||||
$this->assertEquals('01.01.2021 12:34', $formatted);
|
||||
}
|
||||
// The formatter uses German date format d.m.Y
|
||||
expect($formatted)->toBe('01.01.2021');
|
||||
});
|
||||
|
||||
public function testWithCustomTimezone(): void
|
||||
{
|
||||
$formatter = new DateTimeFormatter('Europe/Berlin');
|
||||
$formatted = $formatter->format($this->sampleDate, 'Y-m-d H:i:s T');
|
||||
test('format time returns correct format', function () {
|
||||
$formatted = $this->formatter->formatTime($this->sampleDate);
|
||||
|
||||
// UTC 12:34:56 sollte in Berlin 13:34:56 sein (während Standardzeit/Winterzeit)
|
||||
$this->assertEquals('2021-01-01 13:34:56 CET', $formatted);
|
||||
}
|
||||
expect($formatted)->toBe('12:34:56');
|
||||
});
|
||||
|
||||
public function testWithDateTimeObject(): void
|
||||
{
|
||||
$dateTime = new \DateTime('2021-01-01 12:34:56', new \DateTimeZone('UTC'));
|
||||
$formatted = $this->formatter->formatIso8601($dateTime);
|
||||
test('custom format works correctly', function () {
|
||||
$formatted = $this->formatter->format($this->sampleDate, 'd.m.Y H:i');
|
||||
|
||||
$this->assertEquals('2021-01-01T12:34:56+00:00', $formatted);
|
||||
}
|
||||
}
|
||||
expect($formatted)->toBe('01.01.2021 12:34');
|
||||
});
|
||||
|
||||
test('custom timezone conversion works', function () {
|
||||
$formatter = new DateTimeFormatter('Europe/Berlin');
|
||||
$formatted = $formatter->format($this->sampleDate, 'Y-m-d H:i:s T');
|
||||
|
||||
// UTC 12:34:56 should be 13:34:56 in Berlin during winter time
|
||||
expect($formatted)->toBe('2021-01-01 13:34:56 CET');
|
||||
});
|
||||
|
||||
test('datetime object works correctly', function () {
|
||||
$dateTime = new \DateTime('2021-01-01 12:34:56', new \DateTimeZone('UTC'));
|
||||
$formatted = $this->formatter->formatIso8601($dateTime);
|
||||
|
||||
expect($formatted)->toBe('2021-01-01T12:34:56+00:00');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user