/** * @dataProvider data_combine */ public function test_derive($field1, $value1, $field2, $value2, $field3, $value3, $field4, $value4, $query, $expectedVal) { $str = ""; $dtfb = new DateTimeFormatterBuilder(); $dtfb->appendValue($field1)->appendLiteral('-'); $str .= $value1 . "-"; if ($field2 != null) { $dtfb->appendValue($field2)->appendLiteral('-'); $str .= $value2 . "-"; } if ($field3 != null) { $dtfb->appendValue($field3)->appendLiteral('-'); $str .= $value3 . "-"; } if ($field4 != null) { $dtfb->appendValue($field4)->appendLiteral('-'); $str .= $value4 . "-"; } $parsed = $dtfb->toFormatter()->parse($str); if ($query == LocalDate::class) { if ($expectedVal != null) { $this->assertEquals($parsed->query(LocalDate::fromQuery()), $expectedVal); } else { try { $parsed->query(LocalDate::fromQuery()); $this->fail(); } catch (DateTimeException $ex) { // expected } } } else { throw new IllegalArgumentException(); } }