-
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
/** | ||
* Test: Latte\Essential\Filters::localDate() | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
use Latte\Essential\Filters; | ||
use Tester\Assert; | ||
|
||
require __DIR__ . '/../bootstrap.php'; | ||
|
||
|
||
test('no locale', function () { | ||
$filters = new Filters; | ||
|
||
$filters->localDate(0); | ||
}); | ||
|
||
|
||
test('types of value', function () { | ||
$filters = new Filters; | ||
$filters->locale = 'cs_CZ'; | ||
|
||
Assert::null($filters->localDate(null)); | ||
Assert::same("23.\u{a0}1.\u{a0}1978", $filters->localDate(254_400_000)); | ||
Assert::same("5.\u{a0}5.\u{a0}1978", $filters->localDate('1978-05-05')); | ||
Assert::same("5.\u{a0}5.\u{a0}1978", $filters->localDate(new DateTime('1978-05-05'))); | ||
}); | ||
|
||
|
||
test('date/time formats', function () { | ||
$filters = new Filters; | ||
$filters->locale = 'cs_CZ'; | ||
|
||
// date format | ||
Assert::same('05.05.78', $filters->localDate(new DateTime('1978-05-05'), 'short')); | ||
Assert::same("5.\u{a0}5.\u{a0}1978", $filters->localDate(new DateTime('1978-05-05'), 'medium')); | ||
Assert::same("5.\u{a0}května 1978", $filters->localDate(new DateTime('1978-05-05'), 'long')); | ||
Assert::same("pátek 5.\u{a0}května 1978", $filters->localDate(new DateTime('1978-05-05'), 'full')); | ||
|
||
// time format | ||
Assert::same('12:13', $filters->localDate(new DateTime('12:13:14'), 'time')); | ||
Assert::same('12:13:14', $filters->localDate(new DateTime('12:13:14'), 'time+sec')); | ||
|
||
// combined | ||
Assert::same('05.05.78 12:13', $filters->localDate(new DateTime('1978-05-05 12:13:14'), 'short+time')); | ||
Assert::same('05.05.78 12:13:14', $filters->localDate(new DateTime('1978-05-05 12:13:14'), 'short+time+sec')); | ||
}); |