public function testHideAndShow() { $tool = ToolTestUtil::getCursorToolInstance(); $output = new PipedOutputStream(); $buffer = new \Threaded(); $monitor = new PipedInputStream($buffer, $output); $terminal = $tool->getTerminal(); $terminal->setOutput($output); $tool->hide(); $monitor->read($bytes, 6); $this->assertEquals("[?25l", $bytes); $tool->show(); $monitor->read($bytes, 9); $this->assertEquals("[?12;25h", $bytes); }
/** * @dataProvider dataForTestColorize */ public function testColorize($color, $cmd, $index, $type) { $reflection = new \ReflectionClass($this->screenToolFQN); $method = $reflection->getMethod('colorize'); $method->setAccessible(true); $tool = ToolTestUtil::getScreenToolInstance(); $output = new PipedOutputStream(); $buffer = new \Threaded(); $monitor = new PipedInputStream($buffer, $output); $terminal = $tool->getTerminal(); $terminal->setOutput($output); $offsets = [30, 40]; foreach ($offsets as $offset) { if ('alias' === $type) { $command = sprintf($cmd, $index + $offset); } else { $command = sprintf($cmd, 8 + $offset, $index); } $method->invokeArgs($tool, [$color, $offset]); $monitor->read($bytes, strlen($command)); $this->assertEquals($command, $bytes); } }