/** * Creates a new terminal instance. * * It sets $_SERVER['TERM'] with the value of ``$global`` parameter, then * resolves a terminfo file name from the terminal name and creates terminfo * files accordingly. * * Finally, it creates a new Terminal instance. * * @param string $global The value for $_SERVER['TERM'], defaults to * 'xterm-256color'. * @param string $tty The tty name. * @param string $term The terminal name, defaults to 'xterm-256color'. * @param string $termFile The terminfo file name. * @return Terminfo The terminfo instance. * @see getTermFileForTerm() * @see setupTerminfoFiles() */ public static function getTerminalInstance($global = 'xterm-256color', $tty = null, $term = 'xterm-256color', $termFile = 'xterm-256color') { $_SERVER['TERM'] = $global; // $termFile = TerminfoTestUtil::getTermFileForTerm($term); TerminfoTestUtil::setupTerminfoFiles($termFile); return Terminal::instance($tty, $term); }
public function testCapabilityValues() { $terminfo = TerminfoTestUtil::getTerminfoInstance(); $keys = [Terminfo::KEY_BOOLEANS, Terminfo::KEY_NUMBERS, Terminfo::KEY_STRINGS]; $methods = [Terminfo::KEY_BOOLEANS => 'getBoolean', Terminfo::KEY_NUMBERS => 'getNumber', Terminfo::KEY_STRINGS => 'getString']; $expectedNames = TerminfoTestUtil::getCapabilityNames(); $expectedTerminfo = $terminfo->getParser()->parse()->getTerminfo(); foreach ($keys as $key) { for ($i = 0; $i < count($expectedNames[$key]); $i++) { $expected = isset($expectedTerminfo[$key][$i]) ? $expectedTerminfo[$key][$i] : null; $actual = call_user_func(array($terminfo, $methods[$key]), $expectedNames[$key][$i]); $this->assertEquals($expected, $actual); } } }