public function testHandleCommand() { $args = new Args(new ArgsFormat()); $io = new BufferedIO("line1\nline2"); $command = new Command(new CommandConfig('command')); $handler = new CallbackHandler(function (Args $passedArgs, IO $io, Command $passedCommand) use($args, $command) { PHPUnit_Framework_Assert::assertSame($args, $passedArgs); PHPUnit_Framework_Assert::assertSame($command, $passedCommand); $io->write($io->readLine()); $io->error($io->readLine()); return 123; }); $this->assertSame(123, $handler->handle($args, $io, $command)); $this->assertSame("line1\n", $io->fetchOutput()); $this->assertSame('line2', $io->fetchErrors()); }
public function testClearInput() { $io = new BufferedIO(); $io->setInput('Lorem ipsum'); $this->assertSame('Lorem', $io->read(5)); $io->clearInput(); $this->assertNull($io->readLine()); }