for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Install GitHub App
<?php declare(strict_types=1);
namespace SmrTest;
use mysqli;
use PHPUnit\Framework\TestCase;
use Smr\Container\DiContainer;
use Smr\MySqlProperties;
use Throwable;
class BaseIntegrationSpec extends TestCase {
protected static mysqli $conn;
private static $defaultPopulatedTables = array();
public static function setUpBeforeClass(): void {
if (!isset(self::$conn)) {
$mysqlProperties = DiContainer::get(MySqlProperties::class);
$mysqlProperties
self::$conn = DiContainer::make(mysqli::class);
$query = "SELECT table_name FROM information_schema.tables WHERE table_rows > 0 AND TABLE_SCHEMA='smr_live'";
$rs = self::$conn->query($query);
$all = $rs->fetch_all();
array_walk_recursive($all, function($a) {
self::$defaultPopulatedTables[] = "'" . $a . "'";
});
}
protected function onNotSuccessfulTest(Throwable $t): void {
$this->cleanUp();
throw $t;
protected function tearDown(): void {
protected function cleanUp() {
$implode = implode(",", self::$defaultPopulatedTables);
$query = "SELECT Concat('TRUNCATE TABLE ', TABLE_NAME, ';') FROM INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA = 'smr_live' and TABLE_NAME not in (${implode})";
foreach ($all as $truncate) {
self::$conn->query($truncate[0]);