SuggestMissingPackageSubscriber example

public function testSuggestingPackagesWithPartialMatchAndAlternatives()
    {
        $result = $this->createEventForSuggestingPackages('server', ['server:run']);
        $this->assertDoesNotMatchRegularExpression('/You may be looking for a command provided by/', $result);
    }

    private function createEventForSuggestingPackages(string $command, array $alternatives = []): string
    {
        $error = new CommandNotFoundException('', $alternatives);
        $event = new ConsoleErrorEvent(new ArrayInput([$command])new NullOutput()$error);
        $subscriber = new SuggestMissingPackageSubscriber();
        $subscriber->onConsoleError($event);

        return $event->getError()->getMessage();
    }

    private function getKernel(array $bundles$useDispatcher = false)
    {
        $container = $this->createMock(ContainerInterface::class);

        if ($useDispatcher) {
            $dispatcher = $this->createMock(EventDispatcherInterface::class);
            
Home | Imprint | This part of the site doesn't use cookies.