1 | <?php |
||
2 | declare(strict_types=1); |
||
3 | |||
4 | namespace SPSS\Tests; |
||
5 | |||
6 | |||
7 | use SPSS\Buffer; |
||
8 | use SPSS\ByteCodeReader; |
||
9 | use SPSS\ByteCodeWriter; |
||
10 | |||
11 | class ByteCodeTest extends TestCase |
||
12 | { |
||
13 | |||
14 | public function provider() |
||
15 | { |
||
16 | return [ |
||
17 | ['test'], |
||
18 | [str_repeat('abcdf', 1000)], |
||
19 | ['ᚠᛇᚻ᛫ᛒᛦᚦ᛫ᚠᚱᚩᚠᚢᚱ᛫ᚠᛁᚱᚪ᛫ᚷᛖᚻᚹᛦᛚᚳᚢᛗ'] |
||
20 | |||
21 | ]; |
||
22 | } |
||
23 | |||
24 | /** |
||
25 | * @param $data |
||
26 | * @throws \Exception |
||
27 | * @dataProvider provider |
||
28 | */ |
||
29 | public function testWrite($data) |
||
30 | { |
||
31 | $stream = fopen('php://memory', 'r+'); |
||
32 | $buffer = Buffer::factory($stream); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
33 | $writer = new ByteCodeWriter($buffer); |
||
34 | $writer->append($data); |
||
35 | $writer->flush(); |
||
36 | $buffer->rewind(); |
||
37 | $reader = new ByteCodeReader($buffer); |
||
38 | $this->assertSame($data, trim($reader->read(strlen($data)))); |
||
39 | } |
||
40 | } |