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:04
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\MockObject\MockObject;
9
use PHPUnit\Framework\TestCase;
10
use RuntimeException;
11
use Smr\Container\DiContainer;
12
13
class MySqlDatabaseTest extends TestCase {
14
	private Container $container;
15
	/**
16
	 * @var mysqli|MockObject
17
	 */
18
	private mysqli $mysql;
19
20
	protected function setUp(): void {
21
		DiContainer::initializeContainer();
22
		$this->container = DiContainer::getContainer();
23
		$this->mysql = $this->createMock(mysqli::class);
24
		// Replace the factory definition for mysqli object with our mock, so when
25
		// requesting a mysqli instance, it will always return a mock for this test
26
		$this->container->set(mysqli::class, $this->mysql);
27
	}
28
29
	public function test__construct_happy_path() {
30
		$this->mysql
31
			->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

31
			->/** @scrutinizer ignore-call */ 
32
     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...
32
			->method("character_set_name")
33
			->willReturn("utf8");
34
		$mysqlDatabase = $this->container->get(MySqlDatabase::class);
35
		$this->assertNotNull($mysqlDatabase);
36
	}
37
38
	public function test__construct_invalid_character_set_throws_exception() {
39
		$this->expectException(RuntimeException::class);
40
		$this->mysql
41
			->expects(self::once())
42
			->method("character_set_name")
43
			->willReturn("invalid character set");
44
		// MySqlDatabase::getInstance() is also a valid way to retrieve the managed class instance.
45
		MySqlDatabase::getInstance();
46
	}
47
}
48