PluginProbe
StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more / 2.5.1
StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more v2.5.1
3.7.2 3.7.1 3.7.0 3.6.0 3.6.1 3.5.2 trunk 2.0 2.1 2.2 2.3 2.4 2.4.1 2.4.2 2.4.3 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.6.0 2.6.1 All 73 releases
stockpack / vendor / guzzlehttp / psr7 / tests / BufferStreamTest.php

BufferStreamTest.php in StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more 2.5.1, at vendor/guzzlehttp/psr7/tests/BufferStreamTest.php

64 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace GuzzleHttp\Tests\Psr7;
3
4 use GuzzleHttp\Psr7\BufferStream;
5
6 class BufferStreamTest extends BaseTest
7 {
8 public function testHasMetadata()
9 {
10 $b = new BufferStream(10);
11 $this->assertTrue($b->isReadable());
12 $this->assertTrue($b->isWritable());
13 $this->assertFalse($b->isSeekable());
14 $this->assertEquals(null, $b->getMetadata('foo'));
15 $this->assertEquals(10, $b->getMetadata('hwm'));
16 $this->assertEquals([], $b->getMetadata());
17 }
18
19 public function testRemovesReadDataFromBuffer()
20 {
21 $b = new BufferStream();
22 $this->assertEquals(3, $b->write('foo'));
23 $this->assertEquals(3, $b->getSize());
24 $this->assertFalse($b->eof());
25 $this->assertEquals('foo', $b->read(10));
26 $this->assertTrue($b->eof());
27 $this->assertEquals('', $b->read(10));
28 }
29
30 /**
31 * @expectedException \RuntimeException
32 * @expectedExceptionMessage Cannot determine the position of a BufferStream
33 */
34 public function testCanCastToStringOrGetContents()
35 {
36 $b = new BufferStream();
37 $b->write('foo');
38 $b->write('baz');
39 $this->assertEquals('foo', $b->read(3));
40 $b->write('bar');
41 $this->assertEquals('bazbar', (string) $b);
42 $b->tell();
43 }
44
45 public function testDetachClearsBuffer()
46 {
47 $b = new BufferStream();
48 $b->write('foo');
49 $b->detach();
50 $this->assertTrue($b->eof());
51 $this->assertEquals(3, $b->write('abc'));
52 $this->assertEquals('abc', $b->read(10));
53 }
54
55 public function testExceedingHighwaterMarkReturnsFalseButStillBuffers()
56 {
57 $b = new BufferStream(5);
58 $this->assertEquals(3, $b->write('hi '));
59 $this->assertFalse($b->write('hello'));
60 $this->assertEquals('hi hello', (string) $b);
61 $this->assertEquals(4, $b->write('test'));
62 }
63 }
64