NullStreamTest.php 1.1 KB

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