getMockBuilder(PluginInterface::class)->onlyMethods(['getName', 'getPath'])->getMock(); $plugin1->expects($this->exactly(3))->method('getName')->willReturn('Test-Bundle'); $plugin1->expects($this->once())->method('getPath')->willReturn(__DIR__); $plugin2 = $this->getMockBuilder(PluginInterface::class)->onlyMethods(['getName', 'getPath'])->getMock(); $plugin2->expects($this->exactly(3))->method('getName')->willReturn('Another one'); $plugin2->expects($this->once())->method('getPath')->willReturn('BundleDirectory'); $commandTester = $this->getCommandTester([$plugin1, $plugin2], []); $output = $commandTester->getDisplay(); $this->assertStringContainsString(__DIR__, $output); $this->assertStringContainsString('BundleDirectory', $output); $this->assertStringContainsString('Test-Bundle', $output); $this->assertStringContainsString('Another one', $output); } protected function getCommandTester(array $plugins, array $options = []) { $kernel = self::bootKernel(); $this->application = new Application($kernel); $this->application->add(new PluginCommand(new PluginManager($plugins))); $command = $this->application->find('kimai:plugins'); $commandTester = new CommandTester($command); $inputs = array_merge(['command' => $command->getName()], $options); $commandTester->execute($inputs); return $commandTester; } }