Commit Graph

47663 Commits

Author SHA1 Message Date
Nicolas Grekas
36536c94d2 [HttpClient] dont display any content when none has been collected 2020-02-02 18:36:34 +01:00
Nicolas Grekas
94bc1f7d3b [HttpKernel] allow using public aliases to reference controllers 2020-02-02 17:43:53 +01:00
Nicolas Grekas
6620f8afd9 [FrameworkBundle] remove mention of the old Controller class 2020-02-02 17:28:58 +01:00
Nicolas Grekas
00b6846978 feature #34871 [HttpClient] Allow pass array of callable to the mocking http client (Koc)
This PR was merged into the 5.1-dev branch.

Discussion
----------

[HttpClient] Allow pass array of callable to the mocking http client

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | not yet

For the now MockHttpClient allows pass closure as response factory. It useful for tests to perform assertions that expected request was sent. But If we are sending multiple sequental requests then it became a little bit tricky to perform assertions:

```php
<?php

$requestIndex = 0;
$expectedRequest = function ($method, $url, $options) use (&$requestIndex) {
    switch (++$requestIndex) {
        case 1:
            $this->assertSame('GET', $method);
            $this->assertSame('https://example.com/api/v1/customer', $url);

            return new MockResponse(CustomerFixture::CUSTOMER_RESPONSE);

        case 2:
            $this->assertSame('POST', $method);
            $this->assertSame('https://example.com/api/v1/customer/1/products', $url);
            $this->assertJsonStringEqualsJsonFile(CustomerFixture::CUSTOMER_PRODUCT_PAYLOAD, $options['json']);

            return new MockResponse();

        default:
            throw new \InvalidArgumentException('Too much requests');
    }
};

$client = new MockHttpClient($expectedRequest);
static::$container->set('http_client.example', $client);

$commandTester->execute(['--since' => '2019-01-01 00:05:00', '--until' => '2019-01-01 00:35:00']);

$this->assertSame(2, $requestIndex, 'All expected requests was sent.');
```

This PR introduces possibility to define multiple callable response factories and `getSentRequestsCount` method to make sure that each factory was called:

```php
<?php

$expectedRequests = [
    function ($method, $url, $options) {
        $this->assertSame('GET', $method);
        $this->assertSame('https://example.com/api/v1/customer', $url);

        return new MockResponse(CustomerFixture::CUSTOMER_RESPONSE);
    },
    function ($method, $url, $options) {
        $this->assertSame('POST', $method);
        $this->assertSame('https://example.com/api/v1/customer/1/products', $url);
        $this->assertJsonStringEqualsJsonFile(CustomerFixture::CUSTOMER_PRODUCT_PAYLOAD, $options['json']);

        return new MockResponse();
    },
];

$client = new MockHttpClient($expectedRequest);
static::$container->set('http_client.example', $client);

$commandTester->execute(['--since' => '2019-01-01 00:05:00', '--until' => '2019-01-01 00:35:00']);

$this->assertSame(2, $client->getSentRequestsCount(), 'All expected requests was sent.');
```

Also it adds a lot of tests.

Commits
-------

a36797d60e Allow pass array of callable to the mocking http client
2020-02-02 12:07:05 +01:00
Wouter J
f462285381 Show both missing packages in the same error message 2020-02-01 19:46:42 +01:00
Nicolas Grekas
985f64b5af Merge branch '5.0'
* 5.0:
  [Bridge/PhpUnit] dont conflict with phpunit 4.8
2020-02-01 16:58:03 +01:00
Nicolas Grekas
4cce23d9ca [Bridge/PhpUnit] dont conflict with phpunit 4.8 2020-02-01 16:57:56 +01:00
Julien Falque
963d0cce86
Fix HTTP client config handling 2020-02-01 16:41:49 +01:00
Nicolas Grekas
fb732df025 [FrameworkBundle] CS fix 2020-02-01 11:06:44 +01:00
Nicolas Grekas
ec8163d55f Merge branch '5.0'
* 5.0:
  Update PR template
  bumped Symfony version to 5.0.5
  updated VERSION for 5.0.4
  updated CHANGELOG for 5.0.4
  bumped Symfony version to 4.4.5
  updated VERSION for 4.4.4
  updated CHANGELOG for 4.4.4
2020-02-01 11:02:10 +01:00
Nicolas Grekas
bf6d38412a Merge branch '4.4' into 5.0
* 4.4:
  Update PR template
  bumped Symfony version to 4.4.5
  updated VERSION for 4.4.4
  updated CHANGELOG for 4.4.4
2020-02-01 11:01:49 +01:00
Nicolas Grekas
6f29d8d508 Merge branch '3.4' into 4.4
* 3.4:
  Update PR template
2020-02-01 11:01:17 +01:00
Nicolas Grekas
e02e74d036 Update PR template 2020-02-01 11:00:56 +01:00
Grégoire Pineau
a1e4222ee8 feature #30704 [PropertyInfo] Add accessor and mutator extractor interface and implementation on reflection (joelwurtz, Korbeil)
This PR was merged into the 5.1-dev branch.

Discussion
----------

[PropertyInfo] Add accessor and mutator extractor interface and implementation on reflection

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #30248, partially: #22190, #18016, #5013, #9336, #5219,
| License       | MIT
| Doc PR        | TODO

This PR brings accessor / mutator extraction on the PropertyInfo component,

There is no link to existing code, as IMO it should be in another PR as this will add a dependency on property access to the property info component and not sure this is something wanted (although, it will reduce a lot of code base on the property access component as a lot of code seems to be duplicated)

Code is extracted from #30248 also there is some new features (that can be removed if not wanted)

 * Allow extracting private accessor / mutator (will do a new PR that improve private extraction on reflection latter)
 * Allow extracting static accessor / mutators
 * Allow extracting constructor mutators

Current implementation try to be as close as the PropertyAccess implementation and i did not reuse some methods already available in the class as there is some differences in implementation, but maybe it will be a good time to make this consistent (Looking forward to your input) ?

Things that should be done in a new PR:

 * Linking property info to property access to remove a lot of duplicate code
 * Add a new system that allow adding Virtual Property based on this extractor

Commits
-------

0a92dab753 Rebase, fix tests, review & update CHANGELOG
fc250863a8 [PropertyInfo] Add accessor and mutator extractor interface and implementation on reflection
2020-01-31 15:04:25 +01:00
Fabien Potencier
5a96cf1df8 bumped Symfony version to 5.0.5 2020-01-31 13:54:52 +01:00
Fabien Potencier
03e6126338
Merge pull request #35541 from fabpot/release-5.0.4
released v5.0.4
2020-01-31 13:49:53 +01:00
Fabien Potencier
3c21b0270c updated VERSION for 5.0.4 2020-01-31 13:49:38 +01:00
Fabien Potencier
dca60a125e updated CHANGELOG for 5.0.4 2020-01-31 13:49:30 +01:00
Fabien Potencier
e3561cc2a3 bumped Symfony version to 4.4.5 2020-01-31 13:48:55 +01:00
Fabien Potencier
488093b6fb
Merge pull request #35540 from fabpot/release-4.4.4
released v4.4.4
2020-01-31 13:45:22 +01:00
Fabien Potencier
eac640a21a updated VERSION for 4.4.4 2020-01-31 13:45:06 +01:00
Fabien Potencier
f7021e4bd4 updated CHANGELOG for 4.4.4 2020-01-31 13:44:59 +01:00
Fabien Potencier
9d7e622e5b bug #35538 [FrameworkBundle] fixed suggesting deprecated WebServerBundle (jrushlow)
This PR was squashed before being merged into the 5.1-dev branch (closes #35538).

Discussion
----------

[FrameworkBundle] fixed suggesting deprecated WebServerBundle

| Q             | A
| ------------- | ---
| Branch?       | 5.0
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #35495
| License       | MIT
| Doc PR        |

Removed suggestion to install `symfony/web-server-bundle` in console missing packages suggestions. The web server bundle was deprecated and no longer works with Symfony 5.x, .

Commits
-------

134129b5ad [FrameworkBundle] fixed suggesting deprecated WebServerBundle
2020-01-31 13:35:48 +01:00
Jesse Rushlow
134129b5ad [FrameworkBundle] fixed suggesting deprecated WebServerBundle 2020-01-31 13:35:43 +01:00
Adrien Wilmet
1b1ab2991a [FrameworkBundle] Use MailerAssertionsTrait in KernelTestCase 2020-01-31 11:33:37 +01:00
Nicolas Grekas
9b0a75cdf3 Merge branch '5.0'
* 5.0:
  Bump phpunit-bridge cache
2020-01-31 10:56:46 +01:00
Nicolas Grekas
ec587f431a Merge branch '4.4' into 5.0
* 4.4:
  Bump phpunit-bridge cache
2020-01-31 10:56:42 +01:00
Nicolas Grekas
3a69b8c53d Merge branch '4.3' into 4.4
* 4.3:
  Bump phpunit-bridge cache
2020-01-31 10:56:34 +01:00
Nicolas Grekas
6514fa3cc7 Merge branch '3.4' into 4.3
* 3.4:
  Bump phpunit-bridge cache
2020-01-31 10:56:21 +01:00
Nicolas Grekas
b2339b5e32 Bump phpunit-bridge cache 2020-01-31 10:55:33 +01:00
Nicolas Grekas
44e86a3f96 Merge branch '5.0'
* 5.0:
  [DI] fix CheckTypeDeclarationsPass
2020-01-31 10:49:48 +01:00
Nicolas Grekas
ecf3a53069 Merge branch '4.4' into 5.0
* 4.4:
  [DI] fix CheckTypeDeclarationsPass
2020-01-31 10:49:43 +01:00
Nicolas Grekas
103c460e4c [DI] fix CheckTypeDeclarationsPass 2020-01-31 10:49:27 +01:00
Nicolas Grekas
c3ad3eef65 Merge branch '5.0'
* 5.0:
  [Validator] fix access to uninitialized property when getting value
  [HttpClient] Fix regex bearer
  [Translator] Default value for 'sort' option in translation:update should be 'asc'
  [HttpKernel] Fix stale-if-error behavior, add tests
  [Intl] Provide more locale translations
  [Mailer] Fix STARTTLS support for Postmark and Mandrill
  [Messenger] Check for all serialization exceptions during message dec…
  [Messenger] Fix bug when using single route with XML config
  Fix exception message in Doctrine Messenger
  [DI]  CheckTypeDeclarationsPass now checks if value is type of parameter type
  [SecurityBundle] fix security.authentication.provider.ldap_bind arguments
  Improved error message when no supported user provider is found
  Mysqli doesn't support the named parameters used by PdoAdapter
  Added debug argument to decide if debug page should be shown or not
  Mysqli doesn't support the named parameters used by PdoStore
  Properly handle phpunit arguments for configuration file
  [Mailer] add tests for http transports
2020-01-31 10:20:53 +01:00
Nicolas Grekas
b0fc56477a Merge branch '4.4' into 5.0
* 4.4:
  [Validator] fix access to uninitialized property when getting value
  [HttpClient] Fix regex bearer
  [Translator] Default value for 'sort' option in translation:update should be 'asc'
  [HttpKernel] Fix stale-if-error behavior, add tests
  [Intl] Provide more locale translations
  [Mailer] Fix STARTTLS support for Postmark and Mandrill
  [Messenger] Check for all serialization exceptions during message dec…
  [Messenger] Fix bug when using single route with XML config
  Fix exception message in Doctrine Messenger
  [DI]  CheckTypeDeclarationsPass now checks if value is type of parameter type
  [SecurityBundle] fix security.authentication.provider.ldap_bind arguments
  Improved error message when no supported user provider is found
  Mysqli doesn't support the named parameters used by PdoAdapter
  Added debug argument to decide if debug page should be shown or not
  Mysqli doesn't support the named parameters used by PdoStore
  Properly handle phpunit arguments for configuration file
  [Mailer] add tests for http transports
2020-01-31 10:13:47 +01:00
Nicolas Grekas
f24320dd10 Merge branch '4.3' into 4.4
* 4.3:
  [Validator] fix access to uninitialized property when getting value
  [HttpClient] Fix regex bearer
  [HttpKernel] Fix stale-if-error behavior, add tests
  Improved error message when no supported user provider is found
  Properly handle phpunit arguments for configuration file
2020-01-31 10:11:17 +01:00
Nicolas Grekas
0f13d5a5fc Merge branch '3.4' into 4.3
* 3.4:
  [Validator] fix access to uninitialized property when getting value
  [HttpKernel] Fix stale-if-error behavior, add tests
  Improved error message when no supported user provider is found
2020-01-31 10:10:37 +01:00
Nicolas Grekas
e39d66eeee bug #35530 [HttpClient] Fix regex bearer (noniagriconomie)
This PR was merged into the 4.3 branch.

Discussion
----------

[HttpClient] Fix regex bearer

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #34919
| License       | MIT
| Doc PR        | none

Small fix related to https://github.com/symfony/symfony/issues/34919#issuecomment-571145590

Commits
-------

cd0db78ab5 [HttpClient] Fix regex bearer
2020-01-31 10:08:14 +01:00
Fabien Potencier
aeea451433 bug #35532 [Validator] fix access to uninitialized property when getting value (greedyivan)
This PR was squashed before being merged into the 3.4 branch (closes #35532).

Discussion
----------

[Validator] fix access to uninitialized property when getting value

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #35454
| License       | MIT
| Doc PR        |

In PHP 7.4, the type-hinted property is [uninitialized](https://wiki.php.net/rfc/typed_properties_v2#uninitialized_and_unset_properties) by default. So it needs to be checked before use.

Commits
-------

1edecf77c1 [Validator] fix access to uninitialized property when getting value
2020-01-31 09:56:30 +01:00
Ivan Grigoriev
1edecf77c1 [Validator] fix access to uninitialized property when getting value 2020-01-31 09:56:24 +01:00
Fabien Potencier
09bdaf5553 feature #35525 [Mailer] Randomize the first transport used by the RoundRobin transport (fabpot)
This PR was merged into the 5.1-dev branch.

Discussion
----------

[Mailer] Randomize the first transport used by the RoundRobin transport

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Fix #33723 <!-- prefix each issue number with "Fix #", if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

When not using Messenger, and so sending only one message, the RoundRobin class does not work as the first transport is always used. This PR randomizes the first transport used by the class to mitigate that problem.

Commits
-------

6ebe83c14e [Mailer] Randomize the first transport used by the RoundRobin transport
2020-01-31 09:29:43 +01:00
Fabien Potencier
1bb485b1c7 feature #35116 [Validator] Add alpha3 option to country constraint (maxperrimond)
This PR was squashed before being merged into the 5.1-dev branch (closes #35116).

Discussion
----------

[Validator] Add alpha3 option to country constraint

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        | https://github.com/symfony/symfony-docs/pull/12857

A following of #33791 and #32988 to add `alpha3` option also to `Country` constraint in the validator component.

Commits
-------

d6f34a5df6 [Validator] Add alpha3 option to country constraint
2020-01-31 09:29:05 +01:00
maxime.perrimond
d6f34a5df6 [Validator] Add alpha3 option to country constraint 2020-01-31 09:29:00 +01:00
Fabien Potencier
94efc957f3 feature #29139 [FrameworkBundle][TranslationDebug] Return non-zero exit code on failure (DAcodedBEAT)
This PR was squashed before being merged into the 5.1-dev branch (closes #29139).

Discussion
----------

[FrameworkBundle][TranslationDebug] Return non-zero exit code on failure

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | TBD

This PR introduces non-zero exit codes upon failure for the `debug:translations` command.  The addition can be useful for projects which wish to determine results easily in CI.

The exit code returned can be interpreted as a bit array and to determine what failed, one could Bitwise AND the returned exit code to determine what failed.

Exit Codes:

| Failure Reason   | bit array | integer |
| ----------------  | --------- | --------- |
| General Failure (i.e no translations at all) | `1000000` | 64 |
| Missing Translations | `1000001` | 65 |
| Unused Translations | `1000010` | 66 |
| Fallback Translations | `1000100` | 68 |

Example: Given there are missing and unused translations, the expected status code would be `TranslationDebugCommand::EXIT_CODE_MISSING | TranslationDebugCommand::EXIT_CODE_UNUSED`, which would be evaluated to `67`.

Commits
-------

0baafd8bc5 [FrameworkBundle][TranslationDebug] Return non-zero exit code on failure
2020-01-31 09:27:52 +01:00
Arun Philip
0baafd8bc5 [FrameworkBundle][TranslationDebug] Return non-zero exit code on failure 2020-01-31 09:27:45 +01:00
Konstantin Myakshin
a36797d60e Allow pass array of callable to the mocking http client 2020-01-30 21:18:32 +02:00
noniagriconomie
cd0db78ab5 [HttpClient] Fix regex bearer 2020-01-30 17:47:09 +01:00
Fabien Potencier
55df55e4f6 bug #35486 [Translator] Default value for 'sort' option in translation:update should be 'asc' (versgui)
This PR was squashed before being merged into the 4.4 branch (closes #35486).

Discussion
----------

[Translator] Default value for 'sort' option in translation:update should be 'asc'

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

The value for 'sort' option for `bin/console translation:update --sort` is optional, but no default value is defined. So the list isn't sorted if no value is explicitly defined.
This MR brings a default value "asc" if no value is defined, so the list is correctly sorted.

Commits
-------

fdb13c8ab8 [Translator] Default value for 'sort' option in translation:update should be 'asc'
2020-01-30 17:24:07 +01:00
Guillaume Verstraete
fdb13c8ab8 [Translator] Default value for 'sort' option in translation:update should be 'asc' 2020-01-30 17:24:00 +01:00
Fabien Potencier
81abb4e156 feature #35050 [Mailer] added tag/metadata support (kbond)
This PR was merged into the 5.1-dev branch.

Discussion
----------

[Mailer] added tag/metadata support

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | Fix #35047
| License       | MIT
| Doc PR        | todo

This is an alternative to #34766 for adding tag and metadata support in a more generalized way.

Most transports allow for open/click tracking headers - maybe this should be handled in a similar way?

I added implementations for the Postmark (SMTP and API) and Mailgun (SMTP and API) transports. I can add others and tests/docs if this is acceptable.

### Example:

```php
use Symfony\Component\Mailer\Header\MetadataHeader;
use Symfony\Component\Mailer\Header\TagHeader;

$email->getHeaders()->add(new TagHeader('password-reset'));
$email->getHeaders()->add(new MetadataHeader('Color', 'blue'));
$email->getHeaders()->add(new MetadataHeader('Client-ID', '12345'));
```

The Postmark/Mailgun providers will parse these into their own headers/payload. For transports that don't support tags/metadata, these are just added as custom headers:

```
X-Tag: password-reset
X-Metadata-Color: blue
X-Metadata-Client-ID: 12345
```

Commits
-------

f2cdafcae0 [Mailer] added tag/metadata support
2020-01-30 17:06:55 +01:00