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

Passed
Pull Request — master (#951)
by
unknown
04:36
created

MySqlDatabaseTest::test__construct_invalid_character_set_throws_exception()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 8
rs 10
1
<?php
2
3
namespace SmrTest\lib\DefaultGame;
4
5
use DI\Container;
6
use MySqlDatabase;
7
use mysqli;
8
use PHPUnit\Framework\TestCase;
9
use Smr\Container\DiContainer;
10
use Smr\MySqlProperties;
11
12
class MySqlDatabaseTest extends TestCase {
13
	private Container $container;
14
	private $mysql;
15
16
	protected function setUp(): void {
17
		DiContainer::initializeContainer();
18
		$this->container = DiContainer::getContainer();
19
		$this->mysql = $this->createMock(mysqli::class);
20
		// Replace the factory definition for mysqli object with our mock, so when
21
		// requesting a mysqli instance, it will always return a mock for this test
22
		$this->container->set(mysqli::class, $this->mysql);
23
	}
24
25
	public function test_mysql_factory() {
26
		// Given mysql properties are retrieved from the container
27
		$mysqlProperties = $this->container->get(MySqlProperties::class);
28
		// When using the factory to retrieve a mysqli instance
29
		$mysqlDatabase = MySqlDatabase::mysqliFactory($mysqlProperties);
30
		// Then the connection is successful
31
		self::assertNotNull($mysqlDatabase->server_info);
32
	}
33
34
	public function test__construct_happy_path() {
35
		$mysqlDatabase = $this->container->get(MySqlDatabase::class);
36
		$this->assertNotNull($mysqlDatabase);
37
	}
38
39
	public function test_getInstance_always_returns_new_instance() {
40
		// Given a MySqlDatabase object
41
		$original = MySqlDatabase::getInstance();
42
		// When calling getInstance again
43
		$second = MySqlDatabase::getInstance();
44
		self::assertNotSame($second, $original);
45
	}
46
}
47