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,54 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Framework\DateTime;
|
||||
declare(strict_types=1);
|
||||
|
||||
use App\Framework\DateTime\Clock;
|
||||
use App\Framework\Config\AppConfig;
|
||||
use App\Framework\DateTime\ClockInitializer;
|
||||
use App\Framework\DateTime\FrozenClock;
|
||||
use App\Framework\DateTime\SystemClock;
|
||||
use App\Framework\DateTime\SystemTimer;
|
||||
use App\Framework\DateTime\Timezone;
|
||||
|
||||
class ClockInitializerTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testDefaultInitialization(): void
|
||||
{
|
||||
$initializer = new ClockInitializer();
|
||||
$clock = $initializer();
|
||||
beforeEach(function () {
|
||||
$this->config = new AppConfig(
|
||||
timezone: Timezone::UTC
|
||||
);
|
||||
$this->initializer = new ClockInitializer($this->config);
|
||||
});
|
||||
|
||||
$this->assertInstanceOf(SystemClock::class, $clock);
|
||||
$this->assertEquals('UTC', $clock->now()->getTimezone()->getName());
|
||||
}
|
||||
test('default initialization creates system clock with UTC', function () {
|
||||
$clock = ($this->initializer)();
|
||||
|
||||
public function testCustomTimezone(): void
|
||||
{
|
||||
$initializer = new ClockInitializer('Europe/Berlin');
|
||||
$clock = $initializer();
|
||||
expect($clock)->toBeInstanceOf(SystemClock::class)
|
||||
->and($clock->now()->getTimezone()->getName())->toBe('UTC');
|
||||
});
|
||||
|
||||
$this->assertInstanceOf(SystemClock::class, $clock);
|
||||
$this->assertEquals('Europe/Berlin', $clock->now()->getTimezone()->getName());
|
||||
}
|
||||
test('custom timezone in config is respected', function () {
|
||||
$config = new AppConfig(
|
||||
timezone: Timezone::EuropeBerlin
|
||||
);
|
||||
$initializer = new ClockInitializer($config);
|
||||
$clock = $initializer();
|
||||
|
||||
public function testFrozenClockInitialization(): void
|
||||
{
|
||||
$initializer = new ClockInitializer(
|
||||
useFrozenClock: true,
|
||||
frozenTime: '2021-01-01 12:00:00'
|
||||
);
|
||||
$clock = $initializer();
|
||||
expect($clock)->toBeInstanceOf(SystemClock::class)
|
||||
->and($clock->now()->getTimezone()->getName())->toBe('Europe/Berlin');
|
||||
});
|
||||
|
||||
$this->assertInstanceOf(FrozenClock::class, $clock);
|
||||
$this->assertEquals('2021-01-01 12:00:00', $clock->now()->format('Y-m-d H:i:s'));
|
||||
}
|
||||
test('timer initialization works', function () {
|
||||
$timer = $this->initializer->initTimer();
|
||||
|
||||
public function testFrozenClockWithCustomTimezone(): void
|
||||
{
|
||||
$initializer = new ClockInitializer(
|
||||
timezone: 'Europe/Berlin',
|
||||
useFrozenClock: true,
|
||||
frozenTime: '2021-01-01 12:00:00'
|
||||
);
|
||||
$clock = $initializer();
|
||||
|
||||
$this->assertInstanceOf(FrozenClock::class, $clock);
|
||||
$this->assertEquals('Europe/Berlin', $clock->now()->getTimezone()->getName());
|
||||
}
|
||||
}
|
||||
expect($timer)->toBeInstanceOf(SystemTimer::class);
|
||||
});
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Framework\DateTime;
|
||||
|
||||
use App\Framework\DateTime\DateRange;
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
@@ -19,14 +19,8 @@ class DateTimeTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function testNowReturnsCurrentDateTime(): void
|
||||
{
|
||||
$now = DateTime::now();
|
||||
|
||||
$this->assertInstanceOf(\DateTimeImmutable::class, $now);
|
||||
$this->assertEquals('UTC', $now->getTimezone()->getName());
|
||||
$this->assertLessThanOrEqual(2, abs(time() - $now->getTimestamp()));
|
||||
}
|
||||
// Removed: now() functionality is provided by Clock implementations
|
||||
// See SystemClockTest and FrozenClockTest for equivalent functionality
|
||||
|
||||
public function testFromTimestamp(): void
|
||||
{
|
||||
@@ -101,38 +95,19 @@ class DateTimeTest extends TestCase
|
||||
DateTime::createInterval('invalid interval');
|
||||
}
|
||||
|
||||
// Removed: setDefaultTimezone, today, tomorrow, yesterday functionality
|
||||
// is provided by Clock implementations
|
||||
// See SystemClockTest and FrozenClockTest for equivalent functionality
|
||||
|
||||
public function testSetDefaultTimezone(): void
|
||||
{
|
||||
// Test the setDefaultTimezone method that actually exists
|
||||
DateTime::setDefaultTimezone('Europe/Berlin');
|
||||
$now = DateTime::now();
|
||||
|
||||
$this->assertEquals('Europe/Berlin', $now->getTimezone()->getName());
|
||||
}
|
||||
$timezone = DateTime::getDefaultTimezone();
|
||||
$this->assertEquals('Europe/Berlin', $timezone->getName());
|
||||
|
||||
public function testToday(): void
|
||||
{
|
||||
$today = DateTime::today();
|
||||
$expected = (new \DateTimeImmutable('today'))->format('Y-m-d');
|
||||
|
||||
$this->assertEquals($expected, $today->format('Y-m-d'));
|
||||
$this->assertEquals('00:00:00', $today->format('H:i:s'));
|
||||
}
|
||||
|
||||
public function testTomorrow(): void
|
||||
{
|
||||
$tomorrow = DateTime::tomorrow();
|
||||
$expected = (new \DateTimeImmutable('tomorrow'))->format('Y-m-d');
|
||||
|
||||
$this->assertEquals($expected, $tomorrow->format('Y-m-d'));
|
||||
$this->assertEquals('00:00:00', $tomorrow->format('H:i:s'));
|
||||
}
|
||||
|
||||
public function testYesterday(): void
|
||||
{
|
||||
$yesterday = DateTime::yesterday();
|
||||
$expected = (new \DateTimeImmutable('yesterday'))->format('Y-m-d');
|
||||
|
||||
$this->assertEquals($expected, $yesterday->format('Y-m-d'));
|
||||
$this->assertEquals('00:00:00', $yesterday->format('H:i:s'));
|
||||
// Reset to UTC for other tests
|
||||
DateTime::setDefaultTimezone('UTC');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Framework\DateTime;
|
||||
|
||||
use App\Framework\DateTime\FrozenClock;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Framework\DateTime;
|
||||
|
||||
use App\Framework\DateTime\SystemClock;
|
||||
|
||||
Reference in New Issue
Block a user