You are here

public function AppendStreamTest::testCatchesExceptionsWhenCastingToString in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/guzzlehttp/psr7/tests/AppendStreamTest.php \GuzzleHttp\Tests\Psr7\AppendStreamTest::testCatchesExceptionsWhenCastingToString()

File

vendor/guzzlehttp/psr7/tests/AppendStreamTest.php, line 152

Class

AppendStreamTest

Namespace

GuzzleHttp\Tests\Psr7

Code

public function testCatchesExceptionsWhenCastingToString() {
  $s = $this
    ->getMockBuilder('Psr\\Http\\Message\\StreamInterface')
    ->setMethods([
    'isSeekable',
    'read',
    'isReadable',
    'eof',
  ])
    ->getMockForAbstractClass();
  $s
    ->expects($this
    ->once())
    ->method('isSeekable')
    ->will($this
    ->returnValue(true));
  $s
    ->expects($this
    ->once())
    ->method('read')
    ->will($this
    ->throwException(new \RuntimeException('foo')));
  $s
    ->expects($this
    ->once())
    ->method('isReadable')
    ->will($this
    ->returnValue(true));
  $s
    ->expects($this
    ->any())
    ->method('eof')
    ->will($this
    ->returnValue(false));
  $a = new AppendStream([
    $s,
  ]);
  $this
    ->assertFalse($a
    ->eof());
  $this
    ->assertSame('', (string) $a);
}