close Warning: AdminModule failed with TracError: Unable to instantiate component <class 'trac.admin.web_ui.LoggingAdminPanel'> (super(type, obj): obj (type LoggingAdminPanel) is not an instance or subtype of type (Markup).)

source: externals/php/vendor/guzzlehttp/psr7/tests/BufferStreamTest.php@ d2faced

Last change on this file since d2faced was 01a620f, checked in by Joachim Langenbach <joachim.langenbach@…>, 11 years ago

Removed submodules for php externals and use composer to provide them and versioned them afterwards

  • Property mode set to 100644
File size: 1.9 KB
RevLine 
[01a620f]1<?php
2namespace GuzzleHttp\Tests\Psr7;
3
4use GuzzleHttp\Psr7\BufferStream;
5
6class BufferStreamTest extends \PHPUnit_Framework_TestCase
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}
Note: See TracBrowser for help on using the repository browser.