Ver código fonte

test for Protocols\Frame

jhdxr 2 anos atrás
pai
commit
cdab473690
1 arquivos alterados com 20 adições e 0 exclusões
  1. 20 0
      tests/Unit/Protocols/FrameTest.php

+ 20 - 0
tests/Unit/Protocols/FrameTest.php

@@ -0,0 +1,20 @@
+<?php
+
+use Workerman\Protocols\Frame;
+
+it('tests ::input', function () {
+    expect(Frame::input('foo'))->toBe(0);
+    expect(Frame::input("\0\0\0*foobar"))
+        ->toBe(42);
+});
+
+it('tests ::decode', function () {
+    $buffer = pack('N', 5) . 'jhdxr';
+    expect(Frame::decode($buffer))
+        ->toBe('jhdxr');
+});
+
+it('tests ::encode', function () {
+    expect(Frame::encode('jhdxr'))
+        ->toBe(pack('N', 9) . 'jhdxr');
+});