fix debug:autowiringcommand
This commit is contained in:
parent
9793522f6e
commit
fec4beaffc
@ -100,6 +100,7 @@ EOF
|
|||||||
$hasAlias = [];
|
$hasAlias = [];
|
||||||
$all = $input->getOption('all');
|
$all = $input->getOption('all');
|
||||||
$previousId = '-';
|
$previousId = '-';
|
||||||
|
$serviceIdsNb = 0;
|
||||||
foreach ($serviceIds as $serviceId) {
|
foreach ($serviceIds as $serviceId) {
|
||||||
$text = [];
|
$text = [];
|
||||||
if (0 !== strpos($serviceId, $previousId)) {
|
if (0 !== strpos($serviceId, $previousId)) {
|
||||||
@ -127,11 +128,22 @@ EOF
|
|||||||
$serviceLine .= ' - <fg=magenta>deprecated</>';
|
$serviceLine .= ' - <fg=magenta>deprecated</>';
|
||||||
}
|
}
|
||||||
} elseif (!$all) {
|
} elseif (!$all) {
|
||||||
|
++$serviceIdsNb;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$text[] = $serviceLine;
|
$text[] = $serviceLine;
|
||||||
$io->text($text);
|
$io->text($text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$io->newLine();
|
||||||
|
|
||||||
|
if (0 < $serviceIdsNb) {
|
||||||
|
$io->text(sprintf('%s more concrete service%s would be displayed when adding the "--all" option.', $serviceIdsNb, $serviceIdsNb > 1 ? 's' : ''));
|
||||||
|
}
|
||||||
|
if ($all) {
|
||||||
|
$io->text('Pro-tip: use interfaces in your type-hints instead of classes to benefit from the dependency inversion principle.');
|
||||||
|
}
|
||||||
|
|
||||||
$io->newLine();
|
$io->newLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,4 +72,29 @@ class DebugAutowiringCommandTest extends WebTestCase
|
|||||||
$this->assertContains('No autowirable classes or interfaces found matching "foo_fake"', $tester->getErrorOutput());
|
$this->assertContains('No autowirable classes or interfaces found matching "foo_fake"', $tester->getErrorOutput());
|
||||||
$this->assertEquals(1, $tester->getStatusCode());
|
$this->assertEquals(1, $tester->getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSearchNotAliasedService()
|
||||||
|
{
|
||||||
|
static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml']);
|
||||||
|
|
||||||
|
$application = new Application(static::$kernel);
|
||||||
|
$application->setAutoExit(false);
|
||||||
|
|
||||||
|
$tester = new ApplicationTester($application);
|
||||||
|
$tester->run(['command' => 'debug:autowiring', 'search' => 'redirect']);
|
||||||
|
|
||||||
|
$this->assertContains(' more concrete service would be displayed when adding the "--all" option.', $tester->getDisplay());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSearchNotAliasedServiceWithAll()
|
||||||
|
{
|
||||||
|
static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml']);
|
||||||
|
|
||||||
|
$application = new Application(static::$kernel);
|
||||||
|
$application->setAutoExit(false);
|
||||||
|
|
||||||
|
$tester = new ApplicationTester($application);
|
||||||
|
$tester->run(['command' => 'debug:autowiring', 'search' => 'redirect', '--all' => true]);
|
||||||
|
$this->assertContains('Pro-tip: use interfaces in your type-hints instead of classes to benefit from the dependency inversion principle.', $tester->getDisplay());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user