Skip to content

Commit f02dd30

Browse files
committed
Test data events
1 parent 37785c3 commit f02dd30

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/ReadlineTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,27 @@ public function testMovingCursorWithoutEchoDoesNotNeedToRedraw()
191191
$this->assertSame($this->readline, $this->readline->moveCursorBy(2));
192192
}
193193

194+
public function testDataEventWillBeEmittedForCompleteLine()
195+
{
196+
$this->readline->on('data', $this->expectCallableOnceWith('hello'));
197+
198+
$this->pushInputBytes($this->readline, "hello\n");
199+
}
200+
201+
public function testDataEventWillNotBeEmittedForIncompleteLine()
202+
{
203+
$this->readline->on('data', $this->expectCallableNever());
204+
205+
$this->pushInputBytes($this->readline, "hello");
206+
}
207+
208+
public function testDataEventWillBeEmittedForEmptyLine()
209+
{
210+
$this->readline->on('data', $this->expectCallableOnceWith(''));
211+
212+
$this->pushInputBytes($this->readline, "\n");
213+
}
214+
194215
public function testWriteSimpleCharWritesOnce()
195216
{
196217
$this->output->expects($this->once())->method('write')->with($this->equalTo("\r\033[K" . "k"));

0 commit comments

Comments
 (0)