Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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
fabpot merged 1 commit intosymfony:2.1fromjakzal:form-tests-fix
Dec 29, 2012

Conversation

@jakzal
Copy link
Contributor

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:

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:

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.

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.
@fabpotfabpot merged commit81967f6 intosymfony:2.1Dec 29, 2012
@jakzaljakzal deleted the form-tests-fix branchDecember 29, 2012 22:51
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@jakzal@fabpot

[8]ページ先頭

©2009-2025 Movatter.jp