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

BaseIntegrationTest::cleanUp()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 7
c 1
b 0
f 1
nc 2
nop 0
dl 0
loc 8
rs 10
1
<?php
2
/**
3
 * > set global general_log_file = "/var/log/mysql/queries.log";
4
 * > set global general_log = "ON";
5
 * [wait some time, hit some pages, whatever]
6
 * > set global general_log = "OFF";
7
 */
8
9
namespace SmrTest;
10
11
use mysqli;
12
use PHPUnit\Framework\TestCase;
13
use Throwable;
14
15
16
class BaseIntegrationTest extends TestCase {
17
	protected static mysqli $conn;
18
	private static $defaultPopulatedTables = array();
19
20
	public static function setUpBeforeClass(): void {
21
		exec("docker-compose run --rm flyway-integration-test 1>&2");
22
		$conn = self::$conn = mysqli_connect(
23
			constant("OVERRIDE_MYSQL_HOST"),
24
			constant("OVERRIDE_MYSQL_USER"),
25
			constant("OVERRIDE_MYSQL_PASSWORD"),
26
			"smr_live",
27
			(int)constant("OVERRIDE_MYSQL_PORT")
28
		);
29
		$query = "SELECT table_name FROM information_schema.tables WHERE table_rows > 0 AND TABLE_SCHEMA='smr_live'";
30
		$rs = $conn->query($query);
31
		$all = $rs->fetch_all();
32
		array_walk_recursive($all, function ($a) {
33
			self::$defaultPopulatedTables[] = "'" . $a . "'";
34
		});
35
	}
36
37
	protected function onNotSuccessfulTest(Throwable $t): void {
38
		$this->cleanUp();
39
		throw $t;
40
	}
41
42
	protected function tearDown(): void {
43
		$this->cleanUp();
44
	}
45
46
	private function cleanUp() {
47
		echo "Cleaning non-default populated tables for next test...";
48
		$implode = implode(",", self::$defaultPopulatedTables);
49
		$query = "SELECT Concat('TRUNCATE TABLE ', TABLE_NAME, ';') FROM INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA = 'smr_live' and TABLE_NAME not in (${implode})";
50
		$rs = self::$conn->query($query);
51
		$all = $rs->fetch_all();
52
		foreach ($all as $truncate) {
53
			self::$conn->query($truncate[0]);
54
		}
55
	}
56
}
57