From aa5d790aa2ca82effcfee966a0f956b552d7bdb1 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Tue, 14 Apr 2026 12:07:23 +0000 Subject: [PATCH] fix phpunit.xml.Bootstrap has to run database and clear cache --- app/phpunit.xml | 2 -- app/tests/bootstrap.php | 64 ++++++++++++++++++++++------------------- 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/app/phpunit.xml b/app/phpunit.xml index ef62738b0..2be17125d 100644 --- a/app/phpunit.xml +++ b/app/phpunit.xml @@ -8,8 +8,6 @@ xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.3/phpunit.xsd"> - - diff --git a/app/tests/bootstrap.php b/app/tests/bootstrap.php index 329e53a2c..ce576d9fc 100644 --- a/app/tests/bootstrap.php +++ b/app/tests/bootstrap.php @@ -1,21 +1,9 @@ run(); \ No newline at end of file +/** + * Run a Cake CLI command in-process (no shelling out). + * + * @param list $argv + * @return int exit code + */ +$runCake = static function (array $argv): int { + $app = new Application(dirname(__DIR__) . '/config'); + $runner = new CommandRunner($app); + + return $runner->run($argv); +}; + +// 1) Clear caches (matches: ./bin/cake cache clear_all) +$exit = $runCake(['bin/cake', 'cache', 'clear_all']); +if ($exit !== 0) { + throw new \RuntimeException('Failed running: bin/cake cache clear_all (exit=' . $exit . ')'); +} + +// 2) Apply database schema (matches: ./bin/cake database) +$exit = $runCake(['bin/cake', 'database']); +if ($exit !== 0) { + throw new \RuntimeException('Failed running: bin/cake database (exit=' . $exit . ')'); +} \ No newline at end of file