forked from nlemoine/page-for-custom-post-type
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainerTest.php
More file actions
65 lines (50 loc) · 1.92 KB
/
Copy pathContainerTest.php
File metadata and controls
65 lines (50 loc) · 1.92 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
60
61
62
63
64
65
<?php
declare(strict_types=1);
namespace n5s\PageForCustomPostType\Tests\Unit;
use InvalidArgumentException;
use n5s\PageForCustomPostType\Container;
use n5s\PageForCustomPostType\Core\Api;
use n5s\PageForCustomPostType\Core\RewriteManager;
use n5s\PageForCustomPostType\Integration\AdvancedCustomFields\AdvancedCustomFields;
use n5s\PageForCustomPostType\Tests\Fixtures\TestCase;
class ContainerTest extends TestCase
{
private Container $container;
protected function setUp(): void
{
parent::setUp();
$this->container = new Container();
}
public function testGetReturnsCorrectTypeForApi(): void
{
$service = $this->container->get(Api::class);
$this->assertInstanceOf(Api::class, $service);
}
public function testGetReturnsCorrectTypeForAdvancedCustomFieldsIntegration(): void
{
$service = $this->container->get(AdvancedCustomFields::class);
$this->assertInstanceOf(AdvancedCustomFields::class, $service);
}
public function testGetReturnsSameInstanceOnRepeatedCalls(): void
{
$first = $this->container->get(Api::class);
$second = $this->container->get(Api::class);
$this->assertSame($first, $second);
}
public function testHasReturnsTrueForKnownServices(): void
{
$this->assertTrue($this->container->has(Api::class));
$this->assertTrue($this->container->has(RewriteManager::class));
$this->assertTrue($this->container->has(AdvancedCustomFields::class));
}
public function testHasReturnsFalseForUnknownServices(): void
{
$this->assertFalse($this->container->has('NonExistent\\Service'));
$this->assertFalse($this->container->has(\stdClass::class));
}
public function testGetThrowsInvalidArgumentExceptionForUnknownService(): void
{
$this->expectException(InvalidArgumentException::class);
$this->container->get('NonExistent\\Service');
}
}