Commit Graph

11620 Commits

Author SHA1 Message Date
Fabien Potencier
5699a342ed Merge branch '2.0' into 2.1
* 2.0:
  Revert "merged branch egeloen/f-2.0-terminal-width (PR #6571)"
2013-01-05 21:32:41 +01:00
Fabien Potencier
151f2c17bf Revert "merged branch egeloen/f-2.0-terminal-width (PR #6571)"
This reverts commit 515769385a, reversing
changes made to cd0a9d7a1d.
2013-01-05 21:32:06 +01:00
Fabien Potencier
24534ce00c merged branch gigablah/terminal-dimensions-fix (PR #6581)
This PR was merged into the 2.1 branch.

Commits
-------

8f21f89 [2.1] [Console] Added getTerminalDimensions() with fix for osx/freebsd

Discussion
----------

[2.1] [Console] Added getTerminalDimensions() with fix for osx/freebsd

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Fixes the following tickets: -
Todo: -
License of the code: MIT
Documentation PR: -

For non-windows systems, the Console component makes use of `stty -a` to grab the dimensions of the terminal when formatting exception output. The regex pattern assumes a string like the following:

`speed 38400 baud; rows 25; columns 80; line = 0;`

However on OSX (and FreeBSD) the pattern is different:

`speed 38400 baud; 25 rows; 80 columns;`

This patch adds a fix to match the correct pattern on darwin/freebsd systems, and consolidates the code in `getTerminalWidth()` and `getTerminalHeight()` into a general `getTerminalDimensions()` function. I've also taken the liberty of changing the curly brace regex delimiters to forward slashes for consistency with the rest of the codebase.
2013-01-05 19:25:37 +01:00
Chris Heng
8f21f89eaf [2.1] [Console] Added getTerminalDimensions() with fix for osx/freebsd 2013-01-06 01:54:53 +08:00
Fabien Potencier
d50df09406 merged branch stloyd/bugfix/monolog_restrict (PR #6570)
This PR was merged into the 2.1 branch.

Commits
-------

4abd5bf Restrict Monolog version to be in version `<1.3`. Because of conflict between `HttpKernel/Log/LoggerInterface` and `Psr\Log\LoggerInterface` (PSR-3)

Discussion
----------

[2.1] Restrict Monolog to be in version `<1.3`.

Because of conflict between `HttpKernel\Log\LoggerInterface` and `Psr\Log\LoggerInterface` (PSR-3).

---------------------------------------------------------------------------

by stof at 2013-01-05T13:09:29Z

This should even be done in the 2.0 branch

---------------------------------------------------------------------------

by stloyd at 2013-01-05T14:00:35Z

@stof See #6572.

---------------------------------------------------------------------------

by stloyd at 2013-01-05T14:05:39Z

@fabpot This is still valid PR (even when `2.0` will be merged to `2.1`) as main `composer.json` is pointing to invalid version.
2013-01-05 16:36:37 +01:00
Fabien Potencier
f1d2fe9d5d Merge branch '2.0' into 2.1
* 2.0:
  Restrict Monolog version to be in version <1.3
  [Console] Make getTerminalWith & getTerminalHeight public
  [DependencyInjection] fixed PhpDumper optimizations when an inlined service depends on the current one indirectly
  [DependencyInjection] fixed PhpDumper when an inlined service definition has some properties
  [DependencyInjection] added some tests for PhpDumper when the container is compiled
  [DependencyInjection] fixed CS
  [Locale] Adjust `StubIntlDateFormatter` to have new methods added in PHP 5.5
  [Locale] Fix failing `StubIntlDateFormatter` tests in PHP 5.5
  [Locale] Fix failing `StubIntlDateFormatter` in PHP 5.5
  [Form] Fix failing `MonthChoiceList` in PHP 5.5
  Update .travis.yml

Conflicts:
	src/Symfony/Bridge/Monolog/composer.json
	src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php
	src/Symfony/Component/Form/Extension/Core/ChoiceList/MonthChoiceList.php
	tests/Symfony/Tests/Component/DependencyInjection/Fixtures/yaml/services9.yml
2013-01-05 16:31:25 +01:00
Fabien Potencier
5258edbe9e merged branch fabpot/container-dumper-fixes (PR #6565)
This PR was merged into the 2.0 branch.

Commits
-------

e0923ae [DependencyInjection] fixed PhpDumper optimizations when an inlined service depends on the current one indirectly
cd15390 [DependencyInjection] fixed PhpDumper when an inlined service definition has some properties
e939a42 [DependencyInjection] added some tests for PhpDumper when the container is compiled
3827e3e [DependencyInjection] fixed CS

Discussion
----------

[DependencyInjection] Fixed PhpDumper when compiling inlined services
2013-01-05 16:22:59 +01:00
Fabien Potencier
4f7791d850 merged branch stloyd/patch-1 (PR #6572)
This PR was merged into the 2.0 branch.

Commits
-------

ba2d035 Restrict Monolog version to be in version <1.3

Discussion
----------

[2.0] Restrict Monolog version to be in version <1.3

Because of conflict between `HttpKernel\Log\LoggerInterface` and `Psr\Log\LoggerInterface` (PSR-3).

Main `composer.json` already restricts to proper version, but bridge allows also conflicting version.

---------------------------------------------------------------------------

by Seldaek at 2013-01-05T14:58:18Z

Looks fine, I will try to wrap up the 1.3.0 soon so you can migrate the code to use it (well it can already be done I guess in the master branch).
2013-01-05 16:16:35 +01:00
Joseph Bielawski
ba2d035348 Restrict Monolog version to be in version <1.3
Because of conflict between `HttpKernel\Log\LoggerInterface` and `Psr\Log\LoggerInterface` (PSR-3)
2013-01-05 14:59:12 +01:00
Fabien Potencier
515769385a merged branch egeloen/f-2.0-terminal-width (PR #6571)
This PR was merged into the 2.0 branch.

Commits
-------

f299bd0 [Console] Make getTerminalWith & getTerminalHeight public

Discussion
----------

[Console] Make getTerminalWith & getTerminalHeight public

Bug fix: yes
Feature addition: yes
Backwards compatibility break: no
Fixes the following tickets: ~
Todo: -
License of the code: MIT
Documentation PR: ~

After demand in #6567, I open an other one on the 2.0 branch.
2013-01-05 14:38:35 +01:00
Eric GELOEN
f299bd0968 [Console] Make getTerminalWith & getTerminalHeight public 2013-01-05 14:32:58 +01:00
Joseph Bielawski
4abd5bf071 Restrict Monolog version to be in version <1.3.
Because of conflict between `HttpKernel/Log/LoggerInterface` and `Psr\Log\LoggerInterface` (PSR-3)
2013-01-05 12:53:24 +01:00
Fabien Potencier
e0923ae1d0 [DependencyInjection] fixed PhpDumper optimizations when an inlined service depends on the current one indirectly 2013-01-05 10:18:27 +01:00
Fabien Potencier
cd153901ea [DependencyInjection] fixed PhpDumper when an inlined service definition has some properties 2013-01-05 10:03:43 +01:00
Fabien Potencier
e939a4236c [DependencyInjection] added some tests for PhpDumper when the container is compiled 2013-01-05 09:50:47 +01:00
Fabien Potencier
3827e3ed1e [DependencyInjection] fixed CS 2013-01-05 09:01:42 +01:00
Fabien Potencier
94aacec717 merged branch romainneutron/StreamSelect (PR #6540)
This PR was merged into the 2.1 branch.

Commits
-------

fa6fb6f [Process] Do not reset stdout/stderr pipes on Interrupted system call

Discussion
----------

[Process][2.1] Do not reset stdout/stderr pipes on stream_select failure

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
License of the code: MIT

When `stream_select` is called and failed, pipes are currently reset to an empty array. As a result, both error-output and output are empty whereas the exitcode is 0 (successful process).

There is no reason (at least I don't see it) to reset pipes when an error occurs.

---------------------------------------------------------------------------

by fabpot at 2013-01-04T08:18:03Z

This behavior was introduced by @Seldaek in bcf8cf91. Any reason?

---------------------------------------------------------------------------

by Seldaek at 2013-01-04T17:22:33Z

The rationale was that if stream_select failed, it will fail every time (maybe this is an incorrect assumption and I introduced a bug there). Since the while loop checks for $this->pipes being not empty, if the process dies off and stream_select() starts failing, it will be stuck in the while loop forever. That's what I was fixing there. As far as I can tell, your fix reintroduces that problem. Can you explain a bit more what you mean by "error-output and output are empty"? Maybe adding a test for the case you are seeing would help too?

---------------------------------------------------------------------------

by romainneutron at 2013-01-04T17:47:00Z

Hi !

I'm actually using `Process` in a amqp client using PhpAmqpLib. Sometimes both output and error-output of a process are empty whereas the process returned with an exitcode equal to 0.

By *empty*, I mean that the output of both `$process->getOuptut()` and `$process->getErrorOuptut()` are equal to `''`.

I removed the `@` before the `stream_select` and realized that some calls where failing :

```
stream_select(): unable to select [4]: Interrupted system call (max_fd=13) in .../vendor/symfony/process/Symfony/Component/Process/Process.php on line 341
```

With my patch, it appears that if a `stream_select` call fails one time, it can be called with success a second time.

Adding a test case that triggers this error does not seem easy as it seems system related.

What do you think about it ?

---------------------------------------------------------------------------

by Seldaek at 2013-01-04T17:52:04Z

Ok I see. So I guess your fix makes sense since stream_select can fail legitimately, but it's not the whole story. If it fails because the process died off (or whatever the cause was on windows) we shouldn't keep trying forever. Maybe just adding a limit of N retries that is reset whenever a call succeeds would be enough to go over the odd system call being interrupted without allowing infinite loops. Not sure what N makes sense.

---------------------------------------------------------------------------

by igorw at 2013-01-04T17:53:45Z

As per the `stream_select` manpage it can return false when interrupted by a system call. That does not indicate that something is broken. However, I'm not sure if it is possible to distinguish between actual errors and interrupts without capturing and parsing the error message.

---------------------------------------------------------------------------

by romainneutron at 2013-01-04T18:50:56Z

I've updated the PR to consider the error message as it's currently the only solution to find out why `stream_select` failed

---------------------------------------------------------------------------

by romainneutron at 2013-01-04T18:59:15Z

Merged fixes suggested by @stloyd  and @Seldaek
2013-01-04 22:46:41 +01:00
Romain Neutron
fa6fb6fa80 [Process] Do not reset stdout/stderr pipes on Interrupted system call
When `stream_select` is called and return false because of an `Interrupted
system call`, pipes are currently reset to an empty array.
As a result, both error-output and output are empty whereas the
exitcode is 0 (successful process).
2013-01-04 19:58:07 +01:00
Fabien Potencier
cd0a9d7a1d merged branch stloyd/feature/travis_php55 (PR #6552)
This PR was merged into the 2.0 branch.

Commits
-------

73d9cef [Locale] Adjust `StubIntlDateFormatter` to have new methods added in PHP 5.5
b2ce983 [Locale] Fix failing `StubIntlDateFormatter` tests in PHP 5.5
913b564 [Locale] Fix failing `StubIntlDateFormatter` in PHP 5.5
8ae773b [Form] Fix failing `MonthChoiceList` in PHP 5.5
f4ce2f1 Update .travis.yml

Discussion
----------

[2.0] Add testing of PHP 5.5 on Travis-CI & fix failing code
2013-01-04 18:25:14 +01:00
Fabien Potencier
ea09a538f2 merged branch dbu/2.1-requestmatcher-httputils (PR #6553)
This PR was merged into the 2.1 branch.

Commits
-------

d601b13 use the right RequestMatcherInterface

Discussion
----------

use the right RequestMatcherInterface

this fixes #6470 by using the right interface
2013-01-04 18:17:24 +01:00
Fabien Potencier
8349816dc5 Merge branch '2.0' into 2.1
* 2.0:
  updated license year
  Update src/Symfony/Component/HttpFoundation/Response.php
  [Console] fixed unitialized properties (closes #5935)
  [Bundle] [FrameworkBundle] fixed typo in phpdoc of the SessionListener.
  bumped Symfony version to 2.0.21-DEV
  updated VERSION for 2.0.21
  updated CHANGELOG for 2.0.21

Conflicts:
	src/Symfony/Bundle/SwiftmailerBundle/LICENSE
	src/Symfony/Component/Filesystem/LICENSE
	src/Symfony/Component/HttpFoundation/Response.php
	src/Symfony/Component/HttpKernel/Kernel.php
2013-01-04 18:00:54 +01:00
Fabien Potencier
df5c171490 updated license year 2013-01-04 17:59:43 +01:00
Joseph Bielawski
73d9cef188 [Locale] Adjust StubIntlDateFormatter to have new methods added in PHP 5.5 2013-01-04 16:12:31 +01:00
David Buchmann
d601b1377c use the right RequestMatcherInterface 2013-01-04 15:29:54 +01:00
Joseph Bielawski
b2ce983596 [Locale] Fix failing StubIntlDateFormatter tests in PHP 5.5 2013-01-04 14:10:03 +01:00
Joseph Bielawski
913b564da1 [Locale] Fix failing StubIntlDateFormatter in PHP 5.5 2013-01-04 13:44:28 +01:00
Joseph Bielawski
8ae773b486 [Form] Fix failing MonthChoiceList in PHP 5.5 2013-01-04 13:43:58 +01:00
Joseph Bielawski
f4ce2f1a40 Update .travis.yml
Add PHP 5.5 to Travis-CI testing and allow it to fail.
2013-01-04 09:48:20 +01:00
Fabien Potencier
66b5818cf9 merged branch jorgemaiden/patch-1 (PR #6525)
This PR was submitted for the master branch but it was merged into the 2.0 branch instead (closes #6525).

Commits
-------

0b5f1e3 Update src/Symfony/Component/HttpFoundation/Response.php

Discussion
----------

Update src/Symfony/Component/HttpFoundation/Response.php

Fix phpdoc typo
2013-01-03 20:29:37 +01:00
Jorge Maiden
d337ad5133 Update src/Symfony/Component/HttpFoundation/Response.php 2013-01-03 20:29:37 +01:00
Fabien Potencier
9153f1980d merged branch jakzal/date-type-fix (PR #6543)
This PR was merged into the 2.1 branch.

Commits
-------

6c5e615 [Form] Fixed DateType when used with the intl extension disabled.

Discussion
----------

[Form] Fixed DateType when used with the intl extension disabled

DateType's month select box returns timestamps when used with intl extension disabled (see #6485).

The reason for this is that stubbed formats use *L* instead of *M* for month representation. My fix is simply taking this into account when building array for the select box.

I didn't provide unit tests since they're disabled when intl extension is not enabled. I've only manually verified if the months array contains correct data.

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #6485
Todo: -
License of the code: MIT
Documentation PR: -

---------------------------------------------------------------------------

by bschussek at 2013-01-03T17:41:47Z

Doesn't this call for fixing the stub instead of changing the Form component?

---------------------------------------------------------------------------

by stof at 2013-01-03T17:50:49Z

@bschussek L and M are both valid for the month in Intl

---------------------------------------------------------------------------

by jakzal at 2013-01-03T17:52:41Z

[StubIntlDateFormatter uses FullTransformer](https://github.com/symfony/symfony/blob/2.1/src/Symfony/Component/Locale/Stub/StubIntlDateFormatter.php#L206) to format the date. [FullTransformer supports both *L* and *M*](https://github.com/symfony/symfony/blob/2.1/src/Symfony/Component/Locale/Stub/DateFormat/FullTransformer.php#L50) formats. Both formats are treated interchangeably.
2013-01-03 20:25:35 +01:00
Fabien Potencier
14be3e014d merged branch bschussek/issue5428 (PR #6545)
This PR was merged into the 2.1 branch.

Commits
-------

c526ad9 [Form] Fixed inheritance of "error_bubbling" in RepeatedType

Discussion
----------

[Form] Fixed inheritance of "error_bubbling" in RepeatedType

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: -
License of the code: MIT
Documentation PR: -
2013-01-03 20:23:22 +01:00
Bernhard Schussek
c526ad9db6 [Form] Fixed inheritance of "error_bubbling" in RepeatedType 2013-01-03 18:55:30 +01:00
Jakub Zalas
6c5e615c0b [Form] Fixed DateType when used with the intl extension disabled. 2013-01-03 18:07:53 +01:00
Fabien Potencier
114bbce806 merged branch Tobion/expires-header (PR #6535)
This PR was merged into the 2.1 branch.

Commits
-------

10b01c9 [HttpFoundation] fix return types and handling of zero in Response
75952af [HttpFoundation] better fix for non-parseable Expires header date

Discussion
----------

[HttpFoundation] Response fixes

First commit is a better solution for #6471 and also fixes several phpdocs.
The second commit fixes the return types and handling of zero.

---------------------------------------------------------------------------

by Tobion at 2013-01-02T21:16:25Z

@dlsniper cc
2013-01-02 22:19:05 +01:00
Tobias Schultze
10b01c9159 [HttpFoundation] fix return types and handling of zero in Response 2013-01-02 22:06:26 +01:00
Tobias Schultze
75952af0c3 [HttpFoundation] better fix for non-parseable Expires header date
It also fixes several phpdocs
2013-01-02 22:03:29 +01:00
Fabien Potencier
25f970a6d7 merged branch andreabreu98/master (PR #6534)
This PR was submitted for the master branch but it was merged into the 2.1 branch instead (closes #6534).

Commits
-------

a5e7fdf Fixed missing plural message in portuguese validator

Discussion
----------

[Validator] Fixed missing plural message

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Fixes the following tickets: #6151
Todo: -
License of the code: -
Documentation PR: -
2013-01-02 16:51:07 +01:00
andreabreu98
ba5cd6ad2b Fixed missing plural message in portuguese validator 2013-01-02 16:51:06 +01:00
Fabien Potencier
d9a55ed8cf merged branch dlsniper/fix-expiry (PR #6471)
This PR was squashed before being merged into the 2.1 branch (closes #6471).

Commits
-------

87b6cc2 Fix Expires when the header is -1

Discussion
----------

Fix Expires when the header is -1

This fixes the issue described in #6469.

Let me know if I've missed something.

Thanks.

---------------------------------------------------------------------------

by blaugueux at 2012-12-27T20:22:23Z

@dlsniper how can i help here, i really need to fix this issue

---------------------------------------------------------------------------

by dlsniper at 2012-12-27T20:28:53Z

I think @fabpot needs to get me some feedback on this but meanwhile you should try the proposed patch and let me know if it fixes the problem for you or I should add more tests to this.

Thanks!

---------------------------------------------------------------------------

by blaugueux at 2012-12-30T14:37:58Z

@dlsniper your patch is working great for me but it breaks tests. I agree that @fabpot point of view is required.

---------------------------------------------------------------------------

by dlsniper at 2012-12-30T18:38:38Z

@blaugueux Can you let me know what tests are failing? the one included in this PR or some custom ones from you? If it's the later, can you share some so that I can add them?

Thanks!

---------------------------------------------------------------------------

by arendjantetteroo at 2013-01-02T12:45:48Z

The headerbag fix works here. I'm not sure if the extra check in Response is really necessary, it works here without it.
2013-01-02 14:34:47 +01:00
Florin Patan
87b6cc2e19 Fix Expires when the header is -1 2013-01-02 14:34:47 +01:00
Fabien Potencier
36627c4c3c merged branch tammyd/bugfix/memcache-port-0 (PR #6529)
This PR was merged into the 2.1 branch.

Commits
-------

c282a2b [DoctrineBridge] Allowing memcache port to be 0 to support memcache unix domain sockets.

Discussion
----------

[DoctrineBridge] Allowing memcache port to be 0 to support memcache unix domain sockets.

[DoctrineBridge] Allowing memcache port to be 0 to support memcache unix domain sockets.

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Fixes the following tickets: #6527
Todo: -
License of the code: MIT
Documentation PR: ~
2013-01-02 10:33:53 +01:00
Fabien Potencier
eb3eaf6f5b merged branch fabpot/console-5935 (PR #6523)
This PR was merged into the 2.0 branch.

Commits
-------

2fc41a1 [Console] fixed unitialized properties (closes #5935)

Discussion
----------

[Console] fixed unitialized properties (closes #5935)
2013-01-02 10:32:01 +01:00
Fabien Potencier
13f0a807b1 merged branch dbu/2.1-requestmatcher-httputils (PR #6470)
This PR was merged into the 2.1 branch.

Commits
-------

bfccd28 HttpUtils must handle RequestMatcher too

Discussion
----------

HttpUtils must handle RequestMatcher too

2.1 introduced the RequestMatcher as alternative to UrlMatcher. but HttpUtils was not adjusted.

---------------------------------------------------------------------------

by lsmith77 at 2013-01-01T18:15:13Z

@fabpot could you have a look at this PR? would like to know if this will be addressed in core or if we need to find another solution inside the CMF routing.
2013-01-02 10:30:52 +01:00
Tammy D
c282a2bf15 [DoctrineBridge] Allowing memcache port to be 0 to support memcache unix domain sockets. 2012-12-31 09:26:26 -08:00
Fabien Potencier
2fc41a1ac8 [Console] fixed unitialized properties (closes #5935) 2012-12-30 21:29:27 +01:00
Fabien Potencier
bf468ca0e6 merged branch jakzal/process-test-fix (PR #6520)
This PR was merged into the 2.1 branch.

Commits
-------

a5aeb21 [Process] Prevented test from failing when pcntl extension is not enabled.

Discussion
----------

[Process] Prevented test from failing when pcntl extension is not enabled

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: -

*SIGTERM* constant is only defined if pcntl extension is present. Extension is not needed to use the Process component though.
2012-12-30 16:37:53 +01:00
Jakub Zalas
a5aeb21b84 [Process] Prevented test from failing when pcntl extension is not enabled.
SIGTERM constant is only defined if pcntl extension is present. Extension is not needed to use the Process component though.
2012-12-30 13:18:39 +01:00
Fabien Potencier
477ddfb44d merged branch jakzal/stub-tests (PR #6515)
This PR was merged into the 2.1 branch.

Commits
-------

ef6f241 [Locale] Fixed the StubLocaleTest for ICU versions lower than 4.8.

Discussion
----------

[Locale] Fixed the StubLocaleTest for ICU versions lower than 4.8

Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: no but for other reason in an another component
Fixes the following tickets: #5517
Todo: -
License of the code: MIT
Documentation PR: -

Symbol for Brazilian Real is BR$ only in ICU 4.8. All previous and later versions use R$.

Links to the relevant data files:
* http://source.icu-project.org/repos/icu/icu/tags/release-4-8/source/data/curr/en.txt
* http://source.icu-project.org/repos/icu/icu/tags/release-4-4/source/data/curr/en.txt
* http://source.icu-project.org/repos/icu/icu/tags/release-49-1/source/data/curr/en.txt

---------------------------------------------------------------------------

by jakzal at 2012-12-29T19:23:25Z

Note that currently *USE_ICU_DATA_VERSION* is required for some tests to pass. This is inconsistent with *Locale::getIcuDataVersion()* which returns *Locale::ICU_DATA_VERSION* if *USE_ICU_DATA_VERSION* is not set. Technically intl extension shouldn't be needed to run the stub tests.

Following code could fix the issue for StubLocale tests:

```php
class StubLocaleTest extends LocaleTestCase
{
    // ...
    protected function getIntlExtensionIcuVersion()
    {
        // Locale::getIcuDataVersion(), which is used to determine the directory of stubs,
        // uses Locale::ICU_DATA_VERSION if USE_INTL_ICU_DATA_VERSION is not given
        if (!getenv('USE_INTL_ICU_DATA_VERSION')) {
            return Locale::ICU_DATA_VERSION;
        }

        return parent::getIntlExtensionIcuVersion();
    }
}
```

This code cannot be placed in the LocaleTestCase as intl tests need the icu data version from the intl extension.

I'm not sure if this is desired and therefore I didn't include it in my PR. Let me know your thoughts and wether I should create another PR for this, use the current PR or forget about it.
2012-12-29 23:37:16 +01:00
Fabien Potencier
f4f2ba8e40 merged branch jakzal/form-tests-fix (PR #6517)
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.
2012-12-29 23:36:52 +01:00