Skip to content

Commit

Permalink
Formatter tests fix (windows).
Browse files Browse the repository at this point in the history
  • Loading branch information
LastDragon-ru committed Oct 20, 2023
1 parent b1bf3a9 commit ab31d77
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions packages/formatter/src/FormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use PHPUnit\Framework\Attributes\CoversClass;

use function config;
use function str_replace;

/**
* @internal
Expand Down Expand Up @@ -125,8 +126,11 @@ public function testDuration(): void {
public function testTime(): void {
$time = DateTime::createFromFormat('H:i:s', '23:24:59') ?: null;

self::assertEquals('11:24 PM', $this->formatter->time($time));
self::assertEquals('2:24 AM', $this->formatter->time($time, null, 'Europe/Moscow'));
self::assertEquals('11:24 PM', str_replace("\u{202F}", ' ', $this->formatter->time($time)));
self::assertEquals(
'2:24 AM',
str_replace("\u{202F}", ' ', $this->formatter->time($time, null, 'Europe/Moscow')),
);
}

public function testTimeConfig(): void {
Expand All @@ -136,7 +140,7 @@ public function testTimeConfig(): void {

$time = DateTime::createFromFormat('H:i:s', '23:24:59') ?: null;

self::assertEquals('11:24:59 PM', $this->formatter->time($time));
self::assertEquals('11:24:59 PM', str_replace("\u{202F}", ' ', $this->formatter->time($time)));
}

public function testTimeCustomFormat(): void {
Expand Down Expand Up @@ -185,8 +189,11 @@ public function testDateCustomFormat(): void {
public function testDatetime(): void {
$datetime = DateTime::createFromFormat('d.m.Y H:i:s', '12.05.2005 23:00:00') ?: null;

self::assertEquals('5/12/05, 11:00 PM', $this->formatter->datetime($datetime));
self::assertEquals('5/13/05, 3:00 AM', $this->formatter->datetime($datetime, null, 'Europe/Moscow'));
self::assertEquals('5/12/05, 11:00 PM', str_replace("\u{202F}", ' ', $this->formatter->datetime($datetime)));
self::assertEquals(
'5/13/05, 3:00 AM',
str_replace("\u{202F}", ' ', $this->formatter->datetime($datetime, null, 'Europe/Moscow')),
);
}

public function testDatetimeConfig(): void {
Expand All @@ -196,7 +203,10 @@ public function testDatetimeConfig(): void {

$datetime = DateTime::createFromFormat('d.m.Y H:i:s', '12.05.2005 23:00:00') ?: null;

self::assertEquals('May 12, 2005, 11:00:00 PM', $this->formatter->datetime($datetime));
self::assertEquals(
'May 12, 2005, 11:00:00 PM',
str_replace("\u{202F}", ' ', $this->formatter->datetime($datetime)),
);
}

public function testDatetimeCustomFormat(): void {
Expand Down

0 comments on commit ab31d77

Please sign in to comment.