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 (#924)
by
unknown
04:35
created

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 RuntimeException;
10
use Smr\Container\DiContainer;
11
12
class MySqlDatabaseTest extends TestCase {
13
	private Container $container;
14
	private mysqli $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__construct_happy_path() {
26
		$this->mysql
27
			->expects(self::once())
0 ignored issues
show
Bug introduced by
The method expects() does not exist on mysqli. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

27
			->/** @scrutinizer ignore-call */ 
28
     expects(self::once())

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
28
			->method("character_set_name")
29
			->willReturn("utf8");
30
		$mysqlDatabase = $this->container->get(MySqlDatabase::class);
31
		$this->assertNotNull($mysqlDatabase);
32
	}
33
34
	public function test__construct_invalid_character_set_throws_exception() {
35
		$this->expectException(RuntimeException::class);
36
		$this->mysql
37
			->expects(self::once())
38
			->method("character_set_name")
39
			->willReturn("invalid character set");
40
		// MySqlDatabase::getInstance() is also a valid way to retrieve the managed class instance.
41
		MySqlDatabase::getInstance();
42
	}
43
}
44