Skip to content

Commit f92cd2a

Browse files
committed
Enhancement: Tag clients
1 parent 5de6c34 commit f92cd2a

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/DependencyInjection/HttplugExtension.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
*/
3838
class HttplugExtension extends Extension
3939
{
40+
public const HTTPLUG_CLIENT_TAG = 'httplug.client';
41+
4042
/**
4143
* Used to check is the VCR plugin is installed.
4244
*
@@ -419,6 +421,7 @@ function ($id) {
419421
->addArgument([
420422
'client_name' => $clientName,
421423
])
424+
->addTag(self::HTTPLUG_CLIENT_TAG)
422425
;
423426

424427
if (is_bool($arguments['public'])) {

tests/Unit/DependencyInjection/HttplugExtensionTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ protected function getContainerExtensions()
3131
];
3232
}
3333

34+
public function testConstants(): void
35+
{
36+
self::assertSame('httplug.client', HttplugExtension::HTTPLUG_CLIENT_TAG);
37+
}
38+
3439
public function testConfigLoadDefault()
3540
{
3641
$this->load();
@@ -452,6 +457,25 @@ public function testBatchClientCanBePublic()
452457
}
453458
}
454459

460+
public function testClientIsTaggedWithHttplugClientTag(): void
461+
{
462+
$this->load([
463+
'clients' => [
464+
'acme' => null,
465+
],
466+
]);
467+
468+
$serviceId = 'httplug.client.acme';
469+
470+
$this->assertContainerBuilderHasService($serviceId);
471+
472+
$this->assertTrue($this->container->getDefinition($serviceId)->hasTag(HttplugExtension::HTTPLUG_CLIENT_TAG), sprintf(
473+
'Failed asserting that client with service identifier "%s" has been tagged with "%s".',
474+
$serviceId,
475+
HttplugExtension::HTTPLUG_CLIENT_TAG
476+
));
477+
}
478+
455479
/**
456480
* @dataProvider provideVcrPluginConfig
457481
* @group vcr-plugin

0 commit comments

Comments
 (0)