0
0
mirror of https://github.com/pmmp/ext-encoding.git synced 2025-09-21 18:39:37 +00:00
Files
ext-encoding/tests/reader/clone.phpt
Dylan K. Taylor eb9610a102 Split up ByteBuffer into reader & writer parts
closes #13

This prevents accidentally writing when reading is intended, and vice
versa.
It also allows specialising the APIs and constructors.
2025-09-06 17:12:57 +01:00

34 lines
703 B
PHP

--TEST--
Test that cloning ByteBufferReader works correctly
--DESCRIPTION--
byte_buffer->used wasn't being copied during clones, leading to the cloned object appearing to have an empty buffer
--FILE--
<?php
use pmmp\encoding\ByteBufferReader;
$buffer = new ByteBufferReader("Some Data");
$buffer2 = clone $buffer;
var_dump($buffer);
var_dump($buffer2);
var_dump($buffer->getData());
var_dump($buffer2->getData());
?>
--EXPECTF--
object(pmmp\encoding\ByteBufferReader)#%d (2) {
["buffer"]=>
string(9) "Some Data"
["offset"]=>
int(0)
}
object(pmmp\encoding\ByteBufferReader)#%d (2) {
["buffer"]=>
string(9) "Some Data"
["offset"]=>
int(0)
}
string(9) "Some Data"
string(9) "Some Data"