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

source: externals/php/vendor/guzzlehttp/psr7/tests/PumpStreamTest.php@ 519df6e

Last change on this file since 519df6e 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: 2.1 KB
Line 
1<?php
2namespace GuzzleHttp\Tests\Psr7;
3
4use GuzzleHttp\Psr7\LimitStream;
5use GuzzleHttp\Psr7\PumpStream;
6use GuzzleHttp\Psr7;
7
8class PumpStreamTest extends \PHPUnit_Framework_TestCase
9{
10 public function testHasMetadataAndSize()
11 {
12 $p = new PumpStream(function () {}, [
13 'metadata' => ['foo' => 'bar'],
14 'size' => 100
15 ]);
16
17 $this->assertEquals('bar', $p->getMetadata('foo'));
18 $this->assertEquals(['foo' => 'bar'], $p->getMetadata());
19 $this->assertEquals(100, $p->getSize());
20 }
21
22 public function testCanReadFromCallable()
23 {
24 $p = Psr7\stream_for(function ($size) {
25 return 'a';
26 });
27 $this->assertEquals('a', $p->read(1));
28 $this->assertEquals(1, $p->tell());
29 $this->assertEquals('aaaaa', $p->read(5));
30 $this->assertEquals(6, $p->tell());
31 }
32
33 public function testStoresExcessDataInBuffer()
34 {
35 $called = [];
36 $p = Psr7\stream_for(function ($size) use (&$called) {
37 $called[] = $size;
38 return 'abcdef';
39 });
40 $this->assertEquals('a', $p->read(1));
41 $this->assertEquals('b', $p->read(1));
42 $this->assertEquals('cdef', $p->read(4));
43 $this->assertEquals('abcdefabc', $p->read(9));
44 $this->assertEquals([1, 9, 3], $called);
45 }
46
47 public function testInifiniteStreamWrappedInLimitStream()
48 {
49 $p = Psr7\stream_for(function () { return 'a'; });
50 $s = new LimitStream($p, 5);
51 $this->assertEquals('aaaaa', (string) $s);
52 }
53
54 public function testDescribesCapabilities()
55 {
56 $p = Psr7\stream_for(function () {});
57 $this->assertTrue($p->isReadable());
58 $this->assertFalse($p->isSeekable());
59 $this->assertFalse($p->isWritable());
60 $this->assertNull($p->getSize());
61 $this->assertEquals('', $p->getContents());
62 $this->assertEquals('', (string) $p);
63 $p->close();
64 $this->assertEquals('', $p->read(10));
65 $this->assertTrue($p->eof());
66
67 try {
68 $this->assertFalse($p->write('aa'));
69 $this->fail();
70 } catch (\RuntimeException $e) {}
71 }
72}
Note: See TracBrowser for help on using the repository browser.