ungetch('A'); self::assertSame(65, $res); $res = $g->getch(); self::assertSame(65, $res); $res = ungetch(65); self::assertSame(65, $res); $res = $g->getch(); self::assertSame(65, $res); } public function testTypeError() { $g = new Getch(); $this->expectException(\TypeError::class); $g->ungetch(new \stdClass()); } public function testForFun() { foreach(\str_split(\strrev('Hello World!')) as $char) { ungetch($char); } $result = ''; do { $ord = getch(); $result .= \chr($ord); } while($ord !== ord('!')); self::assertSame('Hello World!', $result); } }