| 1 |
<?php |
| 2 |
namespace GuzzleHttp\Tests\Psr7; |
| 3 |
|
| 4 |
use GuzzleHttp\Psr7\BufferStream; |
| 5 |
use GuzzleHttp\Psr7\DroppingStream; |
| 6 |
|
| 7 |
class DroppingStreamTest extends BaseTest |
| 8 |
{ |
| 9 |
public function testBeginsDroppingWhenSizeExceeded() |
| 10 |
{ |
| 11 |
$stream = new BufferStream(); |
| 12 |
$drop = new DroppingStream($stream, 5); |
| 13 |
$this->assertEquals(3, $drop->write('hel')); |
| 14 |
$this->assertEquals(2, $drop->write('lo')); |
| 15 |
$this->assertEquals(5, $drop->getSize()); |
| 16 |
$this->assertEquals('hello', $drop->read(5)); |
| 17 |
$this->assertEquals(0, $drop->getSize()); |
| 18 |
$drop->write('12345678910'); |
| 19 |
$this->assertEquals(5, $stream->getSize()); |
| 20 |
$this->assertEquals(5, $drop->getSize()); |
| 21 |
$this->assertEquals('12345', (string) $drop); |
| 22 |
$this->assertEquals(0, $drop->getSize()); |
| 23 |
$drop->write('hello'); |
| 24 |
$this->assertSame(0, $drop->write('test')); |
| 25 |
} |
| 26 |
} |
| 27 |
|