injectableFactory = $this->createMock(InjectableFactory::class); $this->metadata = $this->createMock(Metadata::class); $this->manager = new CommandManager($this->injectableFactory, $this->metadata); $this->command = $this->createMock(Command::class); } private function initTest(array $argv) { $className = 'Test'; $this->metadata ->expects($this->once()) ->method('get') ->with(['app', 'consoleCommands', 'commandName', 'className']) ->willReturn($className); $this->injectableFactory ->expects($this->once()) ->method('create') ->with($className) ->willReturn($this->command); $expectedParams = new Params( [ 'optionOne' => 'test', ], ['flag', 'flagA', 'f'], ['a1', 'a2'] ); $io = new IO(); $this->command ->expects($this->once()) ->method('run') ->with($expectedParams, $io); $this->manager->run($argv); } public function testWithCommandPhp() { $argv = ['command.php', 'command-name', 'a1', 'a2', '--flag', '--flag-a', '-f', '--option-one=test']; $this->initTest($argv); } public function testWithoutCommandPhp() { $argv = ['bin/command', 'command-name', 'a1', 'a2', '--flag', '--flag-a', '-f', '--option-one=test']; $this->initTest($argv); } }