public function testCatchesExceptionsWhenCastingToString() { $s = $this->getMockBuilder('GuzzleHttp\\Stream\\StreamInterface')->setMethods(['read', 'isReadable', 'eof'])->getMockForAbstractClass(); $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); }