Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Form] Fixed failing tests for DateTimeToStringTransformer#6517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Tests were only failing at the end of the month. PHP uses current day if it is not passed. Since February was used in the test cases, date was being moved to the next month (February has less days than other months).
fabpot added a commit that referenced this pull requestDec 29, 2012
This PR was merged into the 2.1 branch.Commits-------81967f6 [Form] Fixed failing tests for DateTimeToStringTransformer.Discussion----------[Form] Fixed failing tests for DateTimeToStringTransformerBug fix: noFeature addition: noBackwards compatibility break: noSymfony2 tests pass: yesFixes the following tickets: -Todo: -License of the code: MITDocumentation PR: -Tests were only failing at the end of the month. Since February was used in the test cases, date was being moved to the next month (February has less days than other months).If a day is not passed, \DateTime's constructor will set it to the first day of the month:```phpvar_dump(new \DateTime('2010-02'));object(DateTime)#1 (3) { ["date"]=> string(19) "2010-02-01 00:00:00" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London"}```\DateTime is used in the test assertions.However, DateTimeToStringTransformer::reverseTransform() uses \DateTime::createFromFormat(), which sets a missing day to the current day:```phpvar_dump(\DateTime::createFromFormat("Y-m", '2010-02'));object(DateTime)#1 (3) { ["date"]=> string(19) "2010-03-01 20:09:26" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London"}```I changed the date in the test case to avoid failures. If we need to be sure that month's not going to be changed, I'll update my PR.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: -
License of the code: MIT
Documentation PR: -
Tests were only failing at the end of the month. Since February was used in the test cases, date was being moved to the next month (February has less days than other months).
If a day is not passed, \DateTime's constructor will set it to the first day of the month:
\DateTime is used in the test assertions.
However, DateTimeToStringTransformer::reverseTransform() uses \DateTime::createFromFormat(), which sets a missing day to the current day:
I changed the date in the test case to avoid failures. If we need to be sure that month's not going to be changed, I'll update my PR.