NullStreamTest.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace GuzzleHttp\Tests\Stream;
  3. use GuzzleHttp\Stream\NullStream;
  4. class NullStreamTest extends \PHPUnit_Framework_TestCase
  5. {
  6. public function testDoesNothing()
  7. {
  8. $b = new NullStream();
  9. $this->assertEquals('', $b->read(10));
  10. $this->assertEquals(4, $b->write('test'));
  11. $this->assertEquals('', (string) $b);
  12. $this->assertNull($b->getMetadata('a'));
  13. $this->assertEquals([], $b->getMetadata());
  14. $this->assertEquals(0, $b->getSize());
  15. $this->assertEquals('', $b->getContents());
  16. $this->assertEquals(0, $b->tell());
  17. $this->assertTrue($b->isReadable());
  18. $this->assertTrue($b->isWritable());
  19. $this->assertTrue($b->isSeekable());
  20. $this->assertFalse($b->seek(10));
  21. $this->assertTrue($b->eof());
  22. $b->detach();
  23. $this->assertTrue($b->eof());
  24. $b->close();
  25. }
  26. /**
  27. * @expectedException \GuzzleHttp\Stream\Exception\CannotAttachException
  28. */
  29. public function testCannotAttach()
  30. {
  31. $p = new NullStream();
  32. $p->attach('a');
  33. }
  34. }