Skip to content

Commit 59879ea

Browse files
committed
Add unit-test for Server constructor.
1 parent 4e27161 commit 59879ea

1 file changed

Lines changed: 50 additions & 5 deletions

File tree

tests/unit/ServerTest.php

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,60 @@
44
*/
55
namespace Pdsinterop\Solid\Resources;
66

7+
use ArgumentCountError;
8+
use EasyRdf\Graph;
9+
use League\Flysystem\FilesystemInterface;
710
use PHPUnit\Framework\TestCase;
11+
use Psr\Http\Message\ResponseInterface;
812

13+
/**
14+
* @coversDefaultClass \Pdsinterop\Solid\Resources\Server
15+
* @covers ::__construct
16+
*/
917
class ServerTest extends TestCase
1018
{
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()
1541
{
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);
1762
}
1863
}

0 commit comments

Comments
 (0)