[Locale] Fixed error resetting in StubIntlDateFormatter::parse()

This commit is contained in:
Bernhard Schussek 2012-07-11 09:53:08 +02:00
parent 50109ebcc2
commit b7aae48a74
3 changed files with 23 additions and 4 deletions

View File

@ -151,6 +151,9 @@ class FullTransformer
}
}
// reset error code and message
StubIntl::setError(StubIntl::U_ZERO_ERROR);
return $this->calculateUnixTimestamp($dateTime, $options);
}

View File

@ -378,10 +378,8 @@ class StubIntlDateFormatter
$timestamp = $transformer->parse($dateTime, $value);
// behave like the intl extension. FullTransformer::parse() set the proper error
if (false === $timestamp) {
$this->errorCode = StubIntl::getErrorCode();
$this->errorMessage = StubIntl::getErrorMessage();
}
$this->errorCode = StubIntl::getErrorCode();
$this->errorMessage = StubIntl::getErrorMessage();
return $timestamp;
}

View File

@ -859,6 +859,24 @@ class StubIntlDateFormatterTest extends LocaleTestCase
);
}
/*
* https://github.com/symfony/symfony/issues/4242
*/
public function testParseAfterErrorIntl()
{
$this->testParseErrorIntl('y-MMMMM-d', '1970-J-1');
$this->testParseIntl('y-M-d', '1970-1-1', 0);
}
/*
* https://github.com/symfony/symfony/issues/4242
*/
public function testParseAfterErrorStub()
{
$this->testParseErrorStub('y-MMMMM-d', '1970-J-1');
$this->testParseStub('y-M-d', '1970-1-1', 0);
}
/**
* Just to document the differences between the stub and the intl implementations. The intl can parse
* any of the tested formats alone. The stub does not implement them as it would be needed to add more