Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Push — master ( 0656bd...6aded6 )
by Dan
25s queued 18s
created

DiContainerTest::test_container_get_and_make()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 9
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 17
rs 9.9666
1
<?php declare(strict_types=1);
2
3
namespace SmrTest\Container;
4
5
use PHPUnit\Framework\TestCase;
6
use Smr\Container\DiContainer;
7
use Smr\MySqlProperties;
8
9
/**
10
 * Class DiContainerTest
11
 * @package SmrTest\Container
12
 * @covers \Smr\Container\DiContainer
13
 */
14
class DiContainerTest extends TestCase {
15
	private const PHPDI_COMPILED_CONTAINER_FILE = "/tmp/CompiledContainer.php";
16
17
	protected function setUp(): void {
18
		if (file_exists(self::PHPDI_COMPILED_CONTAINER_FILE)) {
19
			unlink(self::PHPDI_COMPILED_CONTAINER_FILE);
20
		}
21
	}
22
23
	public function test_compilation_enabled_true() {
24
		// Given environment variable is turned off
25
		unset($_ENV["DISABLE_PHPDI_COMPILATION"]);
26
		// And the container is built
27
		DiContainer::initializeContainer();
28
		// Then
29
		self::assertFileExists(self::PHPDI_COMPILED_CONTAINER_FILE);
30
	}
31
32
	public function test_compilation_enabled_false() {
33
		// Given environment variable is turned on
34
		$_ENV["DISABLE_PHPDI_COMPILATION"] = "true";
35
		// And the container is built
36
		DiContainer::initializeContainer();
37
		// Then
38
		self::assertFileDoesNotExist(self::PHPDI_COMPILED_CONTAINER_FILE);
39
	}
40
41
	public function test_container_get_and_make() {
42
		// Start with a fresh container
43
		DiContainer::initializeContainer();
44
45
		// The first get should construct a new object
46
		$class = MySqlProperties::class;
47
		$instance1 = DiContainer::get($class);
48
		self::assertInstanceOf($class, $instance1);
49
50
		// Getting the same class should now give the exact same object
51
		$instance2 = DiContainer::get($class);
52
		self::assertSame($instance1, $instance2);
53
54
		// Using make should construct a new object
55
		$instance3 = DiContainer::make($class);
56
		self::assertNotSame($instance1, $instance3);
57
		self::assertEquals($instance1, $instance3);
58
	}
59
60
}
61