Skip to content

Enhancement: Tag clients #348

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release.

## Unreleased

### Added

- Configured clients are now tagged with `'httplug.client'`

## 1.16.0 - 2019-06-05

### Changed
Expand Down
3 changes: 3 additions & 0 deletions src/DependencyInjection/HttplugExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
*/
class HttplugExtension extends Extension
{
public const HTTPLUG_CLIENT_TAG = 'httplug.client';

/**
* Used to check is the VCR plugin is installed.
*
Expand Down Expand Up @@ -419,6 +421,7 @@ function ($id) {
->addArgument([
'client_name' => $clientName,
])
->addTag(self::HTTPLUG_CLIENT_TAG)
;

if (is_bool($arguments['public'])) {
Expand Down
24 changes: 24 additions & 0 deletions tests/Unit/DependencyInjection/HttplugExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ protected function getContainerExtensions()
];
}

public function testConstants(): void
{
self::assertSame('httplug.client', HttplugExtension::HTTPLUG_CLIENT_TAG);
}

public function testConfigLoadDefault(): void
{
$this->load();
Expand Down Expand Up @@ -452,6 +457,25 @@ public function testBatchClientCanBePublic(): void
}
}

public function testClientIsTaggedWithHttplugClientTag(): void
{
$this->load([
'clients' => [
'acme' => null,
],
]);

$serviceId = 'httplug.client.acme';

$this->assertContainerBuilderHasService($serviceId);

$this->assertTrue($this->container->getDefinition($serviceId)->hasTag(HttplugExtension::HTTPLUG_CLIENT_TAG), sprintf(
'Failed asserting that client with service identifier "%s" has been tagged with "%s".',
$serviceId,
HttplugExtension::HTTPLUG_CLIENT_TAG
));
}

/**
* @dataProvider provideVcrPluginConfig
* @group vcr-plugin
Expand Down