Esempio n. 1
0
 /**
  * @expectedException \RuntimeException
  * @expectedExceptionMessage Cannot write to a non-writable stream
  */
 public function testHandlesClose()
 {
     $s = Psr7\stream_for('foo');
     $wrapped = new NoSeekStream($s);
     $wrapped->close();
     $wrapped->write('foo');
 }
Esempio n. 2
0
 /**
  * @expectedException \RuntimeException
  */
 public function testCalculatesHashThrowsWhenSeekFails()
 {
     $s = new NoSeekStream(Psr7\stream_for('foobazbar'));
     $s->read(2);
     Psr7\hash($s, 'md5');
 }
 public function testDoesNotRewindUnseekableBody()
 {
     $body = Psr7\stream_for(str_repeat('x', 1024 * 1024 * 2));
     $body->seek(1024 * 1024);
     $body = new Psr7\NoSeekStream($body);
     $this->assertSame(1024 * 1024, $body->tell());
     $req = new Psr7\Request('POST', 'https://www.example.com', ['Content-Length' => 1024 * 1024], $body);
     $factory = new CurlFactory(1);
     $factory->create($req, []);
     $this->assertSame(1024 * 1024, $body->tell());
 }