|
@ -58,7 +58,7 @@ class DateTest extends \PHPUnit\Framework\TestCase { |
|
|
/** @dataProvider provideParsableStrings */ |
|
|
/** @dataProvider provideParsableStrings */ |
|
|
public function testCreateADateFromAString(string $input, ?string $exp): void { |
|
|
public function testCreateADateFromAString(string $input, ?string $exp): void { |
|
|
$act = Date::createFromString($input); |
|
|
$act = Date::createFromString($input); |
|
|
if (!$exp) { |
|
|
if (!$exp) { |
|
|
$this->assertNull($act); |
|
|
$this->assertNull($act); |
|
|
} else { |
|
|
} else { |
|
|
$this->assertSame($exp, (string) $act); |
|
|
$this->assertSame($exp, (string) $act); |
|
@ -68,14 +68,13 @@ class DateTest extends \PHPUnit\Framework\TestCase { |
|
|
public function provideParsableStrings(): iterable { |
|
|
public function provideParsableStrings(): iterable { |
|
|
foreach (new \GlobIterator(__DIR__."/test-*.yaml", \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::KEY_AS_FILENAME) as $file => $path) { |
|
|
foreach (new \GlobIterator(__DIR__."/test-*.yaml", \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::KEY_AS_FILENAME) as $file => $path) { |
|
|
foreach ((new YamlParser)->parseFile($path, Yaml::PARSE_OBJECT_FOR_MAP) as $description => $test) { |
|
|
foreach ((new YamlParser)->parseFile($path, Yaml::PARSE_OBJECT_FOR_MAP) as $description => $test) { |
|
|
if (!is_null($test->output) && substr($test->output, -6) === "-00:00") { |
|
|
if (!is_null($test->output) && substr($test->output, -6) === "-00:00") { |
|
|
// PHP does not preserve the -0000 timezone |
|
|
// PHP does not preserve the -0000 timezone |
|
|
$test->output[-6] = "+"; |
|
|
$test->output[-6] = "+"; |
|
|
} |
|
|
} |
|
|
if (is_array($test->input)) { |
|
|
if (is_array($test->input)) { |
|
|
foreach($test->input as $input) { |
|
|
foreach ($test->input as $input) { |
|
|
yield "$description ($input)" => [$input, $test->output]; |
|
|
yield "$description ($input)" => [$input, $test->output]; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
yield "$description" => [$test->input, $test->output]; |
|
|
yield "$description" => [$test->input, $test->output]; |
|
|