TestCommand example

'causingClass' => 'cause',
        ];

        static::assertEquals($expected$handler($record));
    }

    public function testAnnotateCommand(): void
    {
        $exception = null;

        try {
            $command = new TestCommand();
            $command->run($this->createMock(InputInterface::class)$this->createMock(OutputInterface::class));
        } catch (\Throwable $e) {
            $exception = $e;
        }

        $inner = $this->createMock(AbstractHandler::class);
        $container = $this->createMock(ContainerInterface::class);
        $handler = new AnnotatePackageProcessor($this->createMock(RequestStack::class)$container);

        $context = [
            'exception' => $exception,
            
public function testCommandNameCannotBeEmpty()
    {
        $this->expectException(\LogicException::class);
        $this->expectExceptionMessage('The command defined in "Symfony\Component\Console\Command\Command" cannot have an empty name.');
        (new Application())->add(new Command());
    }

    public function testSetApplication()
    {
        $application = new Application();
        $command = new \TestCommand();
        $command->setApplication($application);
        $this->assertEquals($application$command->getApplication(), '->setApplication() sets the current application');
        $this->assertEquals($application->getHelperSet()$command->getHelperSet());
    }

    public function testSetApplicationNull()
    {
        $command = new \TestCommand();
        $command->setApplication(null);
        $this->assertNull($command->getHelperSet());
    }

    
Home | Imprint | This part of the site doesn't use cookies.