3 class Date_Test extends PHPUnit\Framework\TestCase
27 "Formatted" =>
"1999-09-19",
28 "BeginDate" =>
"1999-09-19",
33 [
"1999-9-19",
"0000-00-00"],
34 [
"9-19-1999",
"0000-00-00"],
35 [
"19-9-1999",
"0000-00-00"],
36 [
"Sep 19 1999",
"0000-00-00"],
37 [
"Sep 19, 1999",
"0000-00-00"],
38 [
"Sep 19th, 1999",
"0000-00-00"],
39 [
"19990919",
"0000-00-00"],
40 [
"19-Sep-1999",
"0000-00-00"],
41 [
"19 Sep 1999",
"0000-00-00"],
46 "Formatted" =>
"1999-09-19",
47 "BeginDate" =>
"1999-09-19",
52 [
"2010-9-19",
"0000-00-00"],
53 [
"9-19-2010",
"0000-00-00"],
54 [
"19-9-2010",
"0000-00-00"],
55 [
"Sep 19 2010",
"0000-00-00"],
56 [
"Sep 19, 2010",
"0000-00-00"],
57 [
"Sep 19th, 2010",
"0000-00-00"],
58 [
"20100919",
"0000-00-00"],
59 [
"19-Sep-2010",
"0000-00-00"],
60 [
"19 Sep 2010",
"0000-00-00"],
65 "Formatted" =>
"2010-09-19",
66 "BeginDate" =>
"2010-09-19",
77 "Formatted" =>
"2001-09-19",
78 "BeginDate" =>
"2001-09-19",
90 "Formatted" =>
"1999-09",
91 "BeginDate" =>
"1999-09-01",
114 "Formatted" =>
"c1999",
115 "BeginDate" =>
"1999-01-01",
120 foreach ($FormatsToTest as $Format)
122 foreach ($Format[
"Inputs"] as $InputArgs)
124 if (!is_array($InputArgs)) { $InputArgs = [ $InputArgs ]; }
125 $TestDate = (
new ReflectionClass(
"Date"))->newInstanceArgs($InputArgs);
126 $Input = join($InputArgs,
", ");
128 $this->assertInstanceOf(Date::class, $TestDate,
130 $this->assertEquals($Format[
"BeginDate"], $TestDate->BeginDate(),
131 "Testing BeginDate() with input \"".$Input.
"\"");
132 $this->assertEquals($Format[
"EndDate"], $TestDate->EndDate(),
133 "Testing EndDate() with input \"".$Input.
"\"");
134 $this->assertEquals($Format[
"Precision"], $TestDate->Precision(),
135 "Testing Precision() with input \"".$Input.
"\"");
136 $this->assertEquals($Format[
"Formatted"], $TestDate->Formatted(),
137 "Testing Formatted() with input \"".$Input.
"\"");
testInputFormats()
Test date input formats we are supposed to handle, to make sure they result in the right precision an...