-
Notifications
You must be signed in to change notification settings - Fork 145
Expand file tree
/
Copy pathStoreRegistryTest.php
More file actions
71 lines (56 loc) · 2.08 KB
/
Copy pathStoreRegistryTest.php
File metadata and controls
71 lines (56 loc) · 2.08 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
66
67
68
69
70
71
<?php
declare(strict_types=1);
namespace Tests\PHPCensor;
use PHPCensor\Common\Exception\RuntimeException;
use PHPCensor\DatabaseManager;
use PHPCensor\Store\BuildStore;
use PHPCensor\StoreRegistry;
use PHPUnit\Framework\TestCase;
class StoreRegistryTest extends TestCase
{
public function testConstructor(): void
{
/** @var DatabaseManager $databaseManager */
$databaseManager = $this
->getMockBuilder(DatabaseManager::class)
->disableOriginalConstructor()
->getMock();
$storeRegistry = new StoreRegistry($databaseManager);
self::assertInstanceOf(StoreRegistry::class, $storeRegistry);
}
public function testGetSuccess(): void
{
/** @var DatabaseManager $databaseManager */
$databaseManager = $this
->getMockBuilder(DatabaseManager::class)
->disableOriginalConstructor()
->getMock();
$storeRegistry = new StoreRegistry($databaseManager);
$buildStore = $storeRegistry->get('Build');
self::assertInstanceOf(BuildStore::class, $buildStore);
}
public function testGetSuccessFromCache(): void
{
/** @var DatabaseManager $databaseManager */
$databaseManager = $this
->getMockBuilder(DatabaseManager::class)
->disableOriginalConstructor()
->getMock();
$storeRegistry = new StoreRegistry($databaseManager);
$buildStore = $storeRegistry->get('Build');
$buildStore2 = $storeRegistry->get('Build');
self::assertInstanceOf(BuildStore::class, $buildStore2);
self::assertSame($buildStore, $buildStore2);
}
public function testGetNotFound(): void
{
self::expectException(RuntimeException::class);
/** @var DatabaseManager $databaseManager */
$databaseManager = $this
->getMockBuilder(DatabaseManager::class)
->disableOriginalConstructor()
->getMock();
$storeRegistry = new StoreRegistry($databaseManager);
$buildStore = $storeRegistry->get('NotExists');
}
}