fix tests issues
Tests / PHPUnit (push) Failing after 1m16s

This commit is contained in:
root
2026-07-13 00:24:00 -04:00
parent 439a695727
commit a56aca4342
17 changed files with 349 additions and 40 deletions
+91 -2
View File
@@ -31,7 +31,12 @@ jobs:
env:
GIT_SSL_NO_VERIFY: 'true'
CI_ENVIRONMENT: testing
database.tests.hostname: 127.0.0.1
TEST_DB_HOST: mysql
TEST_DB_PORT: 3306
TEST_DB_NAME: alrahma_test
TEST_DB_USER: alrahma
TEST_DB_PASSWORD: alrahma
database.tests.hostname: mysql
database.tests.database: alrahma_test
database.tests.username: alrahma
database.tests.password: alrahma
@@ -75,8 +80,92 @@ jobs:
touch writable/cache/testing/.ci-write-test
rm writable/cache/testing/.ci-write-test
- name: Verify database configuration
run: |
php -d variables_order=EGPCS -r '
define("FCPATH", __DIR__ . "/public/");
define("ENVIRONMENT", getenv("CI_ENVIRONMENT") ?: "production");
require "app/Config/Paths.php";
$paths = new Config\Paths();
require $paths->systemDirectory . "/Boot.php";
CodeIgniter\Boot::bootConsole($paths);
$database = config("Database");
$dbConfig = $database->{$database->defaultGroup};
echo "Environment: " . ENVIRONMENT . PHP_EOL;
echo "DB group: " . $database->defaultGroup . PHP_EOL;
echo "DB host: " . $dbConfig["hostname"] . PHP_EOL;
echo "DB port: " . $dbConfig["port"] . PHP_EOL;
echo "DB name: " . $dbConfig["database"] . PHP_EOL;
'
- name: Wait for MariaDB
run: |
for attempt in $(seq 1 30); do
php -r '
mysqli_report(MYSQLI_REPORT_OFF);
$db = @new mysqli(
getenv("TEST_DB_HOST"),
getenv("TEST_DB_USER"),
getenv("TEST_DB_PASSWORD"),
getenv("TEST_DB_NAME"),
(int) getenv("TEST_DB_PORT")
);
exit($db->connect_errno === 0 ? 0 : 1);
' && break
echo "Waiting for MariaDB, attempt ${attempt}/30"
sleep 2
done
php -r '
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
new mysqli(
getenv("TEST_DB_HOST"),
getenv("TEST_DB_USER"),
getenv("TEST_DB_PASSWORD"),
getenv("TEST_DB_NAME"),
(int) getenv("TEST_DB_PORT")
);
echo "MariaDB connection successful\n";
'
- name: Import baseline schema
run: php tests/_support/import_baseline.php Database_Dump/u280815660_school_12072025
- name: Run database migrations
run: php spark migrate --all --no-interaction
run: |
php -d variables_order=EGPCS spark migrate --all --no-interaction
php -r '
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$db = new mysqli(
getenv("TEST_DB_HOST"),
getenv("TEST_DB_USER"),
getenv("TEST_DB_PASSWORD"),
getenv("TEST_DB_NAME"),
(int) getenv("TEST_DB_PORT")
);
$tables = [];
$result = $db->query("SHOW TABLES");
while ($row = $result->fetch_array(MYSQLI_NUM)) {
$tables[$row[0]] = true;
}
foreach (["users", "students", "attendance_data"] as $table) {
if (!isset($tables[$table])) {
fwrite(STDERR, "Migration schema missing required table: {$table}\n");
exit(1);
}
}
echo "Migration schema verified\n";
'
- name: Run tests
run: composer test