TextTest.php 528 B

123456789101112131415161718192021222324
  1. <?php
  2. use Workerman\Connection\ConnectionInterface;
  3. use Workerman\Protocols\Text;
  4. test(Text::class, function () {
  5. $connection = Mockery::mock(ConnectionInterface::class);
  6. //::input
  7. //input without "\n"
  8. expect(Text::input('jhdxr', $connection))
  9. ->toBe(0);
  10. //input with "\n"
  11. expect(Text::input("jhdxr\n", $connection))
  12. ->toBe(6);
  13. //::encode
  14. expect(Text::encode('jhdxr'))
  15. ->toBe("jhdxr\n");
  16. //::decode
  17. expect(Text::decode("jhdxr\n"))
  18. ->toBe('jhdxr');
  19. });