|
4 | 4 | */ |
5 | 5 | namespace Pdsinterop\Solid\Resources; |
6 | 6 |
|
| 7 | +use ArgumentCountError; |
| 8 | +use EasyRdf\Graph; |
| 9 | +use League\Flysystem\FilesystemInterface; |
7 | 10 | use PHPUnit\Framework\TestCase; |
| 11 | +use Psr\Http\Message\ResponseInterface; |
8 | 12 |
|
| 13 | +/** |
| 14 | + * @coversDefaultClass \Pdsinterop\Solid\Resources\Server |
| 15 | + * @covers ::__construct |
| 16 | + */ |
9 | 17 | class ServerTest extends TestCase |
10 | 18 | { |
11 | | - /** |
12 | | - * @coversNothing |
13 | | - */ |
14 | | - public function testDummy(): void |
| 19 | + /** @testdox Server should complain when instantiated without File System */ |
| 20 | + public function testInstatiationWithoutFileSystem() |
| 21 | + { |
| 22 | + $this->expectException(ArgumentCountError::class); |
| 23 | + $this->expectExceptionMessageMatches('/Too few arguments .+ 0 passed/'); |
| 24 | + |
| 25 | + new Server(); |
| 26 | + } |
| 27 | + |
| 28 | + /** @testdox Server should complain when instantiated without Response */ |
| 29 | + public function testInstatiationWithoutResponse() |
| 30 | + { |
| 31 | + $this->expectException(ArgumentCountError::class); |
| 32 | + $this->expectExceptionMessageMatches('/Too few arguments .+ 1 passed/'); |
| 33 | + |
| 34 | + $mockFileSystem = $this->getMockBuilder(FilesystemInterface::class)->getMock(); |
| 35 | + |
| 36 | + new Server($mockFileSystem); |
| 37 | + } |
| 38 | + |
| 39 | + /** @testdox Server should be instantiated when constructed without Graph */ |
| 40 | + public function testInstatiationWithoutGraph() |
15 | 41 | { |
16 | | - $this->assertTrue(true); |
| 42 | + $mockFileSystem = $this->getMockBuilder(FilesystemInterface::class)->getMock(); |
| 43 | + $mockResponse = $this->getMockBuilder(ResponseInterface::class)->getMock(); |
| 44 | + |
| 45 | + $actual = new Server($mockFileSystem, $mockResponse); |
| 46 | + $expected = Server::class; |
| 47 | + |
| 48 | + $this->assertInstanceOf($expected, $actual); |
| 49 | + } |
| 50 | + |
| 51 | + /** @testdox Server should be instantiated when constructed with Graph */ |
| 52 | + public function testInstatiationWithGraph() |
| 53 | + { |
| 54 | + $mockFileSystem = $this->getMockBuilder(FilesystemInterface::class)->getMock(); |
| 55 | + $mockResponse = $this->getMockBuilder(ResponseInterface::class)->getMock(); |
| 56 | + $mockGraph = $this->getMockBuilder(Graph::class)->getMock(); |
| 57 | + |
| 58 | + $actual = new Server($mockFileSystem, $mockResponse, $mockGraph); |
| 59 | + $expected = Server::class; |
| 60 | + |
| 61 | + $this->assertInstanceOf($expected, $actual); |
17 | 62 | } |
18 | 63 | } |
0 commit comments