forked from symfony/symfony
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure mockclient if mock_response_factory has been set on a scope…
…d client. This makes it possible to use different mock response factories on different services and also to easily test services that uses http client endpoints. It also generates an extra test service http_client.mock_client.$name that can be used to configure the MockHttpClient instance if you want to inject a different responsefactory. We also change the framework.http_client.mock_client_factory attribute to allow for a boolean so you can just mock without injecting a responsefactory in the service setup.
- Loading branch information
Showing
17 changed files
with
208 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
12 changes: 12 additions & 0 deletions
12
...ndle/Tests/DependencyInjection/Fixtures/php/http_client_mock_response_factory_service.php
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
$container->loadFromExtension('framework', [ | ||
'annotations' => false, | ||
'http_method_override' => false, | ||
'handle_all_throwables' => true, | ||
'php_errors' => ['log' => true], | ||
'http_client' => [ | ||
'default_options' => null, | ||
'mock_response_factory' => 'my_response_factory', | ||
], | ||
]); |
20 changes: 20 additions & 0 deletions
20
...undle/Tests/DependencyInjection/Fixtures/php/http_client_scoped_mock_response_factory.php
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
$container->loadFromExtension('framework', [ | ||
'annotations' => false, | ||
'http_method_override' => false, | ||
'handle_all_throwables' => true, | ||
'php_errors' => ['log' => true], | ||
'http_client' => [ | ||
'default_options' => null, | ||
'scoped_clients' => [ | ||
'notMocked' => [ | ||
'base_uri' => 'https://symfony.com' | ||
], | ||
'mocked' => [ | ||
'base_uri' => 'https://symfony.com', | ||
'mock_response_factory' => true, | ||
], | ||
] | ||
], | ||
]); |
20 changes: 20 additions & 0 deletions
20
...sts/DependencyInjection/Fixtures/php/http_client_scoped_mock_response_factory_service.php
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
$container->loadFromExtension('framework', [ | ||
'annotations' => false, | ||
'http_method_override' => false, | ||
'handle_all_throwables' => true, | ||
'php_errors' => ['log' => true], | ||
'http_client' => [ | ||
'default_options' => null, | ||
'scoped_clients' => [ | ||
'notMocked' => [ | ||
'base_uri' => 'https://symfony.com' | ||
], | ||
'mocked' => [ | ||
'base_uri' => 'https://symfony.com', | ||
'mock_response_factory' => 'my_response_factory' | ||
], | ||
] | ||
], | ||
]); |
This file contains 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
15 changes: 15 additions & 0 deletions
15
...ndle/Tests/DependencyInjection/Fixtures/xml/http_client_mock_response_factory_service.xml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:framework="http://symfony.com/schema/dic/symfony" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd | ||
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> | ||
|
||
<framework:config http-method-override="false" handle-all-throwables="true"> | ||
<framework:annotations enabled="false" /> | ||
<framework:php-errors log="true" /> | ||
<framework:http-client mock-response-factory="my_response_factory"> | ||
<framework:default-options /> | ||
</framework:http-client> | ||
</framework:config> | ||
</container> |
17 changes: 17 additions & 0 deletions
17
...undle/Tests/DependencyInjection/Fixtures/xml/http_client_scoped_mock_response_factory.xml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:framework="http://symfony.com/schema/dic/symfony" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd | ||
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> | ||
|
||
<framework:config http-method-override="false" handle-all-throwables="true"> | ||
<framework:annotations enabled="false" /> | ||
<framework:php-errors log="true" /> | ||
<framework:http-client mock-response-factory="my_response_factory"> | ||
<framework:default-options /> | ||
<framework:scoped-client name="notMocked" base-uri="https://symfony.com" /> | ||
<framework:scoped-client name="mocked" base-uri="https://symfony.com" mock_response_factory="true" /> | ||
</framework:http-client> | ||
</framework:config> | ||
</container> |
16 changes: 16 additions & 0 deletions
16
...sts/DependencyInjection/Fixtures/xml/http_client_scoped_mock_response_factory_service.xml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:framework="http://symfony.com/schema/dic/symfony" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd | ||
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> | ||
<framework:config http-method-override="false" handle-all-throwables="true"> | ||
<framework:annotations enabled="false" /> | ||
<framework:php-errors log="true" /> | ||
<framework:http-client mock-response-factory="my_response_factory"> | ||
<framework:default-options /> | ||
<framework:scoped-client name="notMocked" base-uri="https://symfony.com" /> | ||
<framework:scoped-client name="mocked" base-uri="https://symfony.com" mock_response_factory="my_response_factory" /> | ||
</framework:http-client> | ||
</framework:config> | ||
</container> |
This file contains 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
9 changes: 9 additions & 0 deletions
9
...ndle/Tests/DependencyInjection/Fixtures/yml/http_client_mock_response_factory_service.yml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
framework: | ||
annotations: false | ||
http_method_override: false | ||
handle_all_throwables: true | ||
php_errors: | ||
log: true | ||
http_client: | ||
default_options: ~ | ||
mock_response_factory: my_response_factory |
16 changes: 16 additions & 0 deletions
16
...undle/Tests/DependencyInjection/Fixtures/yml/http_client_scoped_mock_response_factory.yml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
framework: | ||
annotations: false | ||
http_method_override: false | ||
handle_all_throwables: true | ||
php_errors: | ||
log: true | ||
http_client: | ||
default_options: ~ | ||
mock_response_factory: ~ | ||
|
||
scoped_clients: | ||
notMocked: | ||
base_uri: https://symfony.com | ||
mocked: | ||
base_uri: https://symfony.com | ||
mock_response_factory: true |
16 changes: 16 additions & 0 deletions
16
...sts/DependencyInjection/Fixtures/yml/http_client_scoped_mock_response_factory_service.yml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
framework: | ||
annotations: false | ||
http_method_override: false | ||
handle_all_throwables: true | ||
php_errors: | ||
log: true | ||
http_client: | ||
default_options: ~ | ||
mock_response_factory: ~ | ||
|
||
scoped_clients: | ||
notMocked: | ||
base_uri: https://symfony.com | ||
mocked: | ||
base_uri: https://symfony.com | ||
mock_response_factory: "my_response_factory" |
This file contains 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