/** * @dataProvider formatProvider * * @param string $expected * @param TimeValue $timeValue * @param string $languageCode */ public function testFormat($expected, TimeValue $timeValue, $languageCode = 'en') { $options = new FormatterOptions(array(ValueFormatter::OPT_LANG => $languageCode)); $formatter = new MwTimeIsoFormatter($options); $actual = $formatter->format($timeValue); $this->assertSame($expected, $actual, 'Testing ' . $timeValue->getTime() . ', precision ' . $timeValue->getPrecision()); }
/** * @dataProvider precisionDayProvider */ public function testPrecisionDayRoundtrip(TimeValue $timeValue, $formatted, $languageCode) { $formatterOptions = new FormatterOptions(array(ValueFormatter::OPT_LANG => $languageCode)); $formatter = new MwTimeIsoFormatter($formatterOptions); $parserOptions = new ParserOptions(array(ValueParser::OPT_LANG => $languageCode, IsoTimestampParser::OPT_PRECISION => $timeValue->getPrecision(), IsoTimestampParser::OPT_CALENDAR => $timeValue->getCalendarModel())); $factory = $this->newTimeParserFactory($parserOptions); $parser = $factory->getTimeParser(); $this->assertSame($formatted, $formatter->format($timeValue)); $this->assertEquals($timeValue, $parser->parse($formatted)); }