Skip to content

Commit c965a17

Browse files
sez-openAmrouche Hamza
authored andcommitted
fix debug:autowiringcommand
1 parent 9793522 commit c965a17

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
100100
$hasAlias = [];
101101
$all = $input->getOption('all');
102102
$previousId = '-';
103+
$serviceIdsNb = 0;
103104
foreach ($serviceIds as $serviceId) {
104105
$text = [];
105106
if (0 !== strpos($serviceId, $previousId)) {
@@ -127,11 +128,22 @@ protected function execute(InputInterface $input, OutputInterface $output)
127128
$serviceLine .= ' - <fg=magenta>deprecated</>';
128129
}
129130
} elseif (!$all) {
131+
$serviceIdsNb++;
130132
continue;
131133
}
132134
$text[] = $serviceLine;
133135
$io->text($text);
134136
}
137+
138+
$io->newLine();
139+
140+
if (0 < $serviceIdsNb) {
141+
$io->text(sprintf('%s more concrete service%s would be displayed when adding the --all option.', $serviceIdsNb, $serviceIdsNb > 1 ? 's' : ''));
142+
}
143+
if ($all) {
144+
$io->text('Pro-tip: use interfaces in your type-hints instead of classes to benefit from the dependency inversion principle.');
145+
}
146+
135147
$io->newLine();
136148
}
137149

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/DebugAutowiringCommandTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,29 @@ public function testSearchNoResults()
7272
$this->assertContains('No autowirable classes or interfaces found matching "foo_fake"', $tester->getErrorOutput());
7373
$this->assertEquals(1, $tester->getStatusCode());
7474
}
75+
76+
public function testSearchNotAliasedService()
77+
{
78+
static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml']);
79+
80+
$application = new Application(static::$kernel);
81+
$application->setAutoExit(false);
82+
83+
$tester = new ApplicationTester($application);
84+
$tester->run(['command' => 'debug:autowiring', 'search' => 'redirect']);
85+
86+
$this->assertContains(' more concrete service would be displayed when adding the --all option.', $tester->getDisplay());
87+
}
88+
89+
public function testSearchNotAliasedServiceWithAll()
90+
{
91+
static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml']);
92+
93+
$application = new Application(static::$kernel);
94+
$application->setAutoExit(false);
95+
96+
$tester = new ApplicationTester($application);
97+
$tester->run(['command' => 'debug:autowiring', 'search' => 'redirect', '--all' => true]);
98+
$this->assertContains('Pro-tip: use interfaces in your type-hints instead of classes to benefit from the dependency inversion principle.', $tester->getDisplay());
99+
}
75100
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy