public function testQueryDateFormatter() { $dateFromDateTime = OpenExchangeRates::getFormattedQueryDate(DateTime::createFromFormat('Y-m-d', '2015-12-31')); $this->assertEquals('2015-12-31', $dateFromDateTime); $dateFromTimestamp = OpenExchangeRates::getFormattedQueryDate($time = time()); $this->assertEquals(date('Y-m-d', $time), $dateFromTimestamp); $dateFromString = OpenExchangeRates::getFormattedQueryDate('2015-05-10'); $this->assertEquals('2015-05-10', $dateFromString); if (!interface_exists('DateTimeInterface')) { eval(' interface DateTimeInterface { public function format($format); } class MyDate extends DateTime implements DateTimeInterface {} '); $dateTimeImplementation = new MyDate(); $dateTimeImplementation->setTimestamp($mytime = time()); $this->assertEquals(date('Y-m-d', $mytime), OpenExchangeRates::getFormattedQueryDate($dateTimeImplementation)); } }