소스 검색

test for Protocols\Frame

jhdxr 2 년 전
부모
커밋
cdab473690
1개의 변경된 파일20개의 추가작업 그리고 0개의 파일을 삭제
  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');
+});