comparison vendor/psy/psysh/test/Readline/LibeditTest.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 5fb285c0d0e3
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
21 { 21 {
22 if (!Libedit::isSupported()) { 22 if (!Libedit::isSupported()) {
23 $this->markTestSkipped('Libedit not enabled'); 23 $this->markTestSkipped('Libedit not enabled');
24 } 24 }
25 25
26 $this->historyFile = tempnam(sys_get_temp_dir(), 'psysh_test_history'); 26 $this->historyFile = \tempnam(\sys_get_temp_dir(), 'psysh_test_history');
27 if (false === file_put_contents($this->historyFile, "_HiStOrY_V2_\n")) { 27 if (false === \file_put_contents($this->historyFile, "_HiStOrY_V2_\n")) {
28 $this->fail('Unable to write history file: ' . $this->historyFile); 28 $this->fail('Unable to write history file: ' . $this->historyFile);
29 } 29 }
30 // Calling readline_read_history before readline_clear_history 30 // Calling readline_read_history before readline_clear_history
31 // avoids segfault with PHP 5.5.7 & libedit v3.1 31 // avoids segfault with PHP 5.5.7 & libedit v3.1
32 readline_read_history($this->historyFile); 32 \readline_read_history($this->historyFile);
33 readline_clear_history(); 33 \readline_clear_history();
34 } 34 }
35 35
36 public function tearDown() 36 public function tearDown()
37 { 37 {
38 if (is_file($this->historyFile)) { 38 if (\is_file($this->historyFile)) {
39 unlink($this->historyFile); 39 \unlink($this->historyFile);
40 } 40 }
41 } 41 }
42 42
43 public function testHistory() 43 public function testHistory()
44 { 44 {
92 } 92 }
93 93
94 public function testListHistory() 94 public function testListHistory()
95 { 95 {
96 $readline = new Libedit($this->historyFile); 96 $readline = new Libedit($this->historyFile);
97 file_put_contents( 97 \file_put_contents(
98 $this->historyFile, 98 $this->historyFile,
99 "This is an entry\n\0This is a comment\nThis is an entry\0With a comment\n", 99 "This is an entry\n\0This is a comment\nThis is an entry\0With a comment\n",
100 FILE_APPEND 100 FILE_APPEND
101 ); 101 );
102 $this->assertSame([ 102 $this->assertSame([
111 * it doesn't support non-unix line separators. 111 * it doesn't support non-unix line separators.
112 */ 112 */
113 public function testLinebreaksSupport() 113 public function testLinebreaksSupport()
114 { 114 {
115 $readline = new Libedit($this->historyFile); 115 $readline = new Libedit($this->historyFile);
116 file_put_contents( 116 \file_put_contents(
117 $this->historyFile, 117 $this->historyFile,
118 "foo\rbar\nbaz\r\nw00t", 118 "foo\rbar\nbaz\r\nw00t",
119 FILE_APPEND 119 FILE_APPEND
120 ); 120 );
121 $this->assertSame([ 121 $this->assertSame([