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

Failed Conditions
Pull Request — master (#1017)
by Dan
04:28
created

BaseIntegrationSpec::onNotSuccessfulTest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php declare(strict_types=1);
2
3
namespace SmrTest;
4
5
use mysqli;
6
use PHPUnit\Framework\TestCase;
7
use Smr\Container\DiContainer;
8
use Smr\MySqlProperties;
9
use Throwable;
10
11
class BaseIntegrationSpec extends TestCase {
12
	protected static mysqli $conn;
13
	private static $defaultPopulatedTables = array();
14
15
	public static function setUpBeforeClass(): void {
16
		if (!isset(self::$conn)) {
17
			$mysqlProperties = DiContainer::get(MySqlProperties::class);
0 ignored issues
show
Unused Code introduced by
The assignment to $mysqlProperties is dead and can be removed.
Loading history...
18
			self::$conn = DiContainer::make(mysqli::class);
19
			$query = "SELECT table_name FROM information_schema.tables WHERE table_rows > 0 AND TABLE_SCHEMA='smr_live'";
20
			$rs = self::$conn->query($query);
21
			$all = $rs->fetch_all();
22
			array_walk_recursive($all, function($a) {
23
				self::$defaultPopulatedTables[] = "'" . $a . "'";
24
			});
25
		}
26
	}
27
28
	protected function onNotSuccessfulTest(Throwable $t): void {
29
		$this->cleanUp();
30
		throw $t;
31
	}
32
33
	protected function tearDown(): void {
34
		$this->cleanUp();
35
	}
36
37
	protected function cleanUp() {
38
		$implode = implode(",", self::$defaultPopulatedTables);
39
		$query = "SELECT Concat('TRUNCATE TABLE ', TABLE_NAME, ';') FROM INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA = 'smr_live' and TABLE_NAME not in (${implode})";
40
		$rs = self::$conn->query($query);
41
		$all = $rs->fetch_all();
42
		foreach ($all as $truncate) {
43
			self::$conn->query($truncate[0]);
44
		}
45
	}
46
}
47