[Form] Fixed failing tests for DateTimeToStringTransformer#6517
Merged
fabpot merged 1 commit intosymfony:2.1from Dec 29, 2012
Merged
[Form] Fixed failing tests for DateTimeToStringTransformer#6517fabpot merged 1 commit intosymfony:2.1from
fabpot merged 1 commit intosymfony:2.1from
Conversation
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 request
Dec 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 DateTimeToStringTransformer 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: ```php var_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: ```php var_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.
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
Sign up for free
to 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.