2015-05-23 22:41:16 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @author Jim Wigginton <terrafrost@php.net>
|
|
|
|
* @copyright 2014 Jim Wigginton
|
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
|
|
|
*/
|
|
|
|
|
2015-05-23 23:23:40 +00:00
|
|
|
use phpseclib\File\ANSI;
|
2015-05-23 22:41:16 +00:00
|
|
|
|
|
|
|
class Unit_File_ANSITest extends PhpseclibTestCase
|
|
|
|
{
|
|
|
|
public function testCase1()
|
|
|
|
{
|
|
|
|
$str = "\x1B[07m"; // turn reverse video on
|
|
|
|
$str.= "aaaaaaaaaaaaaaaaaa";
|
|
|
|
$str.= "\x1B[10D"; // move cursor left 10 lines
|
|
|
|
$str.= "\x1B[m"; // reset everything
|
|
|
|
$str.= "bbb";
|
|
|
|
|
2015-05-23 23:23:40 +00:00
|
|
|
$ansi = new ANSI();
|
2015-05-23 22:41:16 +00:00
|
|
|
$ansi->appendString($str);
|
|
|
|
|
|
|
|
$expected = '<pre width="80" style="color: white; background: black">';
|
|
|
|
$expected.= '<span style="color: black"><span style="background: white">aaaaaaaa</span></span>';
|
|
|
|
$expected.= 'bbb';
|
|
|
|
$expected.= '<span style="color: black"><span style="background: white">aaaaaaa</span></span>';
|
|
|
|
$expected.= '</pre>';
|
|
|
|
|
|
|
|
$this->assertSame($ansi->getScreen(), $expected);
|
|
|
|
}
|
2017-08-09 01:47:19 +00:00
|
|
|
|
|
|
|
public function testLineOverflow()
|
|
|
|
{
|
|
|
|
$str = '';
|
|
|
|
foreach (range('a', 'y') as $char) {
|
|
|
|
$str.= "$char\r\n";
|
|
|
|
}
|
|
|
|
$str.= str_repeat('z', 100);
|
|
|
|
|
|
|
|
$ansi = new File_ANSI();
|
|
|
|
$ansi->appendString($str);
|
|
|
|
|
|
|
|
$screen = $ansi->getScreen();
|
|
|
|
|
|
|
|
$lines = explode("\r\n", $screen);
|
|
|
|
$this->assertSame(24, count($lines));
|
|
|
|
$this->assertSame(str_repeat('z', 80), $lines[22]);
|
|
|
|
}
|
2015-05-23 22:41:16 +00:00
|
|
|
}
|