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