-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainerTest.php
More file actions
59 lines (49 loc) · 1.29 KB
/
ContainerTest.php
File metadata and controls
59 lines (49 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
declare(strict_types=1);
namespace Firehed\API;
use Psr\Container as Psr;
/**
* @coversDefaultClass Firehed\API\Container
* @covers ::<protected>
* @covers ::<private>
*/
class ContainerTest extends \PHPUnit\Framework\TestCase
{
/** @var Container */
private $c;
public function setUp(): void
{
$this->c = new Container(['key' => 'value']);
}
/** @covers ::__construct */
public function testConstruct()
{
$this->assertInstanceOf(Psr\ContainerInterface::class, $this->c);
}
/** @covers ::has */
public function testHas()
{
$this->assertTrue($this->c->has('key'));
$this->assertFalse($this->c->has('nokey'));
}
/** @covers ::get */
public function testGet()
{
$this->assertSame('value', $this->c->get('key'));
}
/** @covers ::get */
public function testGetDoesNotEvaluateCallables()
{
$loader = function () {
return new Container([]);
};
$container = new Container(['loader' => $loader]);
$this->assertSame($loader, $container->get('loader'));
}
/** @covers ::get */
public function testGetThrowsOnMissingKey()
{
$this->expectException(Psr\NotFoundExceptionInterface::class);
$this->c->get('nokey');
}
}