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