Commit Graph

251 Commits

Author SHA1 Message Date
Nicolas Grekas
90167c36f8 fix tests 2019-05-28 11:19:25 +02:00
Nicolas Grekas
cfeb5bee07 fix tests 2019-05-28 09:50:59 +02:00
Chris Wilkinson
b27b4199fc
Fix typo 2019-05-27 11:52:29 +01:00
Nicolas Grekas
0a640c53cb Reference individual contracts packages 2019-05-27 10:16:38 +02:00
Nicolas Grekas
f410691842 [Contracts] split in one package per sub-contracts 2019-05-22 14:23:29 +02:00
Nicolas Grekas
7a53e8d3f9 Merge branch '4.2' into 4.3
* 4.2:
  [Routing] Fixed unexpected 404 NoConfigurationException
  [DI] Removes number of elements information in debug mode
  [Contracts] Simplify implementation declarations
  Update PR template for 4.3
  [Intl] Add FallbackTrait for data generation
  [Console] Commands with an alias should not be recognized as ambiguous
  clarify the possible class/interface of the cache
2019-05-09 11:33:12 +02:00
Nicolas Grekas
7d51da36a7 [Contracts] Simplify implementation declarations 2019-05-09 09:39:53 +02:00
Mehdi Achour
c5819f444d
[HttpClient] fix typo 2019-04-27 15:29:50 +01:00
Nicolas Grekas
8f699541f5 [HttpClient] fix too high timeout in test 2019-04-15 19:24:46 +02:00
Alexander M. Turek
8acf29eaf5 There is no OB to flush. 2019-04-07 10:26:05 +02:00
Nicolas Grekas
847a9bb86d [Cache] add logs on early-recomputation and locking 2019-04-03 11:22:57 +02:00
Nicolas Grekas
0b21268bf5 [HttpClient][Contracts] rename "raw_headers" to "response_headers" 2019-04-02 12:06:39 +02:00
Fabien Potencier
07276642de fixed typo 2019-03-31 15:49:16 +02:00
Nicolas Grekas
a4ce08ec30 [Contracts][EventDispatcher] move the Event class to symfony/contracts 2019-03-29 19:47:03 +01:00
Mateusz Sip
aaf5422cfb [DI][Contracts] add and implement ServiceProviderInterface 2019-03-28 12:22:02 +01:00
Fabien Potencier
c949f9a282 feature #30691 [Contracts][EventDispatcher] add EventDispatcherInterface to symfony/contracts and use it where possible (nicolas-grekas)
This PR was merged into the 4.3-dev branch.

Discussion
----------

[Contracts][EventDispatcher] add EventDispatcherInterface to symfony/contracts and use it where possible

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

This PR adds a new `EventDispatcherInterface` in `Contracts`. This interface contains only one method: `dispatch($event, $eventName)`. That covers almost all use cases of the event dispatcher in components (some use add/removeListeners/Subscribers but they are a minority.)

While doing so, it allows dispatching any objects as events - not only instances of `Event`.

This allows decoupling e.g. `Messenger` from the `EventDispatcher` component.
Next steps could be about planning to remove the base `Event` class from some concrete event classes and/or moving `EventSubscriberInterface` to `symfony/contracts`. It would allow decoupling e.g. `Workflow` from the component - but that's too far away for now, let's think about it in 5.1.

Commits
-------

3c3db2f14a [Contracts][EventDispatcher] add EventDispatcherInterface to symfony/contracts and use it where possible
2019-03-27 07:28:10 +01:00
Gregor Harlan
226dbbc54f
[Contracts] fix phpdoc for http-client (user_data) 2019-03-26 00:17:13 +01:00
Nicolas Grekas
3c3db2f14a [Contracts][EventDispatcher] add EventDispatcherInterface to symfony/contracts and use it where possible 2019-03-25 18:18:00 +01:00
Fabien Potencier
dae5686722 [HttpClient] added CachingHttpClient 2019-03-22 16:52:17 +01:00
Fabien Potencier
d5d1b50cf7 feature #30604 [HttpClient] add MockHttpClient (nicolas-grekas)
This PR was merged into the 4.3-dev branch.

Discussion
----------

[HttpClient] add MockHttpClient

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

This PR introduces `MockHttpClient` and `MockResponse`, to be used for testing classes that need an HTTP client without making actual HTTP requests.

`MockHttpClient` is configured via its constructor: you provide it either with an iterable or a callable, and these will be used to provide responses as the consumer requests them.

Example:
```php
$responses = [
    new MockResponse($body1, $info1),
    new MockResponse($body2, $info2),
];

$client = new MockHttpClient($responses);
$response1 = $client->request(...); // created from $responses[0]
$response2 = $client->request(...); // created from $responses[1]
```

Or alternatively:
```php
$callback = function ($method, $url, $options) {
    return new MockResponse(...);
};

$client = new MockHttpClient($callback);
$response = $client->request(...); // calls $callback internal
```

The responses provided to the client don't have to be instances of `MockResponse` - any `ResponseInterface` works (e.g. `$this->getMockBuilder(ResponseInterface::class)->getMock()`).

Using `MockResponse` allows simulating chunked responses and timeouts:
```php
$body = function () {
    yield 'hello';
    yield ''; // the empty string is turned into a timeout so that they are easy to test
    yield 'world';
};
$mockResponse = new Mockresponse($body);
```

Last but not least, the implementation simulates the full lifecycle of a properly behaving `HttpClientInterface` contracts implementation: error handling, progress function, etc. This is "proved" by `MockHttpClientTest`, who implements and passes the reference test suite in `HttpClientTestCase`.

Commits
-------

8fd7584158 [HttpClient] add MockHttpClient
2019-03-19 19:41:07 +01:00
Nicolas Grekas
8fd7584158 [HttpClient] add MockHttpClient 2019-03-19 19:38:55 +01:00
Anton Chernikov
103448cc67 [HttpClient] exceptions carry response 2019-03-19 08:49:42 +01:00
Kévin Dunglas
8d5096a638
[HttpClient] Allow to pass user/pw as an array 2019-03-14 08:32:36 +01:00
Kévin Dunglas
f79ef21458 [HttpClient] Add new bearer option 2019-03-14 08:15:49 +01:00
Nicolas Grekas
e11ef7ed12 [HttpClient] yield a last chunk for completed responses also 2019-03-11 12:00:28 +01:00
Nicolas Grekas
f54c89c530 [HttpClient] add missing test case 2019-03-10 23:05:39 +01:00
Nicolas Grekas
4619ae483d feature #30499 [HttpClient] add ResponseInterface::toArray() (nicolas-grekas)
This PR was merged into the 4.3-dev branch.

Discussion
----------

[HttpClient] add ResponseInterface::toArray()

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

I'd like we discuss adding a `toArray()` method to `ResponseInterface`.

JSON responses are so common when doing server-side requests that this may help remove boilerplate - especially the logic dealing with errors.

WDYT?

(about flags, I don't think we should make them configurable: if one really needs to deal with custom flags, there's always `ResponseInterface::getContent()` - but it should be very rare.).

Commits
-------

aabd1d455e [HttpClient] add ResponseInterface::toArray()
2019-03-10 18:25:55 +01:00
Nicolas Grekas
aabd1d455e [HttpClient] add ResponseInterface::toArray() 2019-03-09 17:49:48 +01:00
Nicolas Grekas
0e2ea87199 [HttpClient] Remove dead code 2019-03-09 17:08:21 +01:00
Nicolas Grekas
3eca2b448d [HttpClient] fixes 2019-03-08 17:57:56 +01:00
Nicolas Grekas
d2d63a28e1 [Contracts] introduce HttpClient contracts 2019-03-07 17:16:38 +01:00
Nicolas Grekas
aa6a60ead6 [Contracts] bump branch alias 2019-03-04 11:50:13 +01:00
Fabien Potencier
e03db43894 fixed CS 2019-01-16 22:31:25 +01:00
Fabien Potencier
d2098d7e5d fixed CS 2019-01-16 21:35:37 +01:00
Christian Flothmann
36110b1e95 update years in license files 2019-01-03 10:09:06 +01:00
Nicolas Grekas
73e4a1a5ff [Contracts] extract LocaleAwareInterface out of TranslatorInterface 2018-12-05 08:06:11 +00:00
Nicolas Grekas
302b8446a7 [Contracts][Cache] allow retrieving metadata of cached items 2018-11-24 10:35:08 +01:00
Nicolas Grekas
07e2cc2858 [Contracts] clarify the README 2018-11-21 19:26:39 +01:00
Nicolas Grekas
fd74951405 Merge branch '4.1'
* 4.1:
  [Form] Hardened test suite for empty data
  Bump phpunit XSD version to 5.2
  [Fwb][EventDispatcher][HttpKernel] Fix getClosureScopeClass usage to describe callables
  Add required key attribute
2018-11-11 20:52:12 +01:00
Nicolas Grekas
321d7f4be0 [Cache] allow to skip saving the computed value when using CacheInterface::get() 2018-10-31 09:00:32 +01:00
Fabien Potencier
51f39b9999 feature #28718 [Cache] add CacheInterface::delete() + improve CacheTrait (nicolas-grekas)
This PR was merged into the 4.2-dev branch.

Discussion
----------

[Cache] add CacheInterface::delete() + improve CacheTrait

| Q             | A
| ------------- | ---
| Branch?       | 4.2
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

I've been hesitating a lot on this topic, but I think we should add a `delete()` method to `CacheInterface`.
Deleting is a very common invalidation strategy and invalidating by passing `$beta=INF` to `get()` has the drawback of requiring a fetch+unserialize+save-with-past-expiration. That's complexity that a delete removes.

This PR fixes an issue found meanwhile on `get()`: passing an `ItemInterface` to its callback makes it harder than required to implement on top of PSR-6. Let's pass a `CacheItemInterface`.

Lastly, the early expiration logic can be moved from the component to the trait shipped on contracts.

Here we are for all these steps.

Commits
-------

c6cf690b2f [Cache] add CacheInterface::delete() + improve CacheTrait
2018-10-10 02:20:36 -07:00
Nicolas Grekas
dc5f3bfff7 Make trans + %count% parameter resolve plurals 2018-10-06 18:22:22 +02:00
Nicolas Grekas
c6cf690b2f [Cache] add CacheInterface::delete() + improve CacheTrait 2018-10-06 16:52:09 +02:00
Nyholm
d870a850bd [Translator] Deprecated transChoice and moved it away from contracts 2018-10-06 09:58:31 +02:00
Nicolas Grekas
8a11e76c14 [Contracts] fine tune composer.json declarations for suggest/provide 2018-09-20 15:44:19 +02:00
Nyholm
06cd8dca8f [Cache][Contracts] We must save the item or the trait does not have any effect 2018-09-17 20:09:31 +02:00
Nicolas Grekas
675abdcfee [Contracts] Add traits+interfaces from the DI component 2018-09-04 10:20:02 +02:00
Nicolas Grekas
ca6478bbbb [Contracts] Add Cache contract to extend PSR-6 with tag invalidation, callback-based computation and stampede protection 2018-09-04 09:16:03 +02:00
Nicolas Grekas
064e369e06 [Contracts] Add Translation\TranslatorInterface + decouple symfony/validator from symfony/translation 2018-09-03 15:19:33 +02:00
Christian Flothmann
ec795cca78 fix compatibility with older Cache versions
FrameworkBundle 4.2 will be compatible with older versions of the Cache
component. In those versions adapters don't implement `ResetInterface`.
For backwards compatibility they still need to be tagged.
2018-07-14 10:12:57 +02:00
Fabien Potencier
682836da9c renamed Contract to Contracts 2018-07-13 19:06:58 +02:00