From f3dfaa75d242eef3899aa47a60aa2bd5bf23a98b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Jou=C3=9Fen?= Date: Mon, 9 Nov 2026 11:54:45 +0100 Subject: [PATCH] Math/ResourceStorage: Fix Tests After PHPUnit 13.4 See: https://github.com/ILIAS-eLearning/ILIAS/commit/ec794e3c50a0b875e9f18495fd54d7fca7db5eef The checks workflow on release_12 fails since the 12.0 Beta 1 commit. The dependency update in 958865f9de0 pulled PHPUnit 13.4 and sebastian/diff 9.0, which removed UnifiedDiffOutputBuilder. The Math adapter tests built their failure message with that class, so every numeric assertion errored before comparing the values. The comparison now reports the two numbers directly and no longer depends on a PHPUnit internal class. The parameter order of assertEqualNumbers() is corrected to expected, actual. CollectionRepositoryTest expected manipulateF() twice with the same arguments. PHPUnit 13.4 rejects a second identical expectation, while CollectionDBRepository::update() calls the method only once. The duplicated expectation is removed. --- .../ILIAS/Math/tests/ilMathBaseAdapterTestCase.php | 13 ++++++------- .../tests/Collection/CollectionRepositoryTest.php | 4 ---- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/components/ILIAS/Math/tests/ilMathBaseAdapterTestCase.php b/components/ILIAS/Math/tests/ilMathBaseAdapterTestCase.php index 8de1e1a821a2..9aec4314047f 100644 --- a/components/ILIAS/Math/tests/ilMathBaseAdapterTestCase.php +++ b/components/ILIAS/Math/tests/ilMathBaseAdapterTestCase.php @@ -17,8 +17,6 @@ *********************************************************************/ use PHPUnit\Framework\TestCase; -use SebastianBergmann\Diff\Differ; -use SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder; /** * @author Michael Jansen @@ -45,15 +43,16 @@ protected function setUp(): void * In PHPUnit 8 the ScalarComparators uses a strict string comparison, so numbers with a different amount of trailing * 0 decimals are not equal anymore * @see \SebastianBergmann\Comparator\ScalarComparator - * @param string $actual * @param string $expected + * @param string $actual */ - private function assertEqualNumbers(string $actual, string $expected): void + private function assertEqualNumbers(string $expected, string $actual): void { - $differ = new Differ(new UnifiedDiffOutputBuilder("\n--- Expected\n+++ Actual\n")); - /** @noinspection PhpUnitTestsInspection */ - $this->assertTrue($actual == $expected, $differ->diff($actual, $expected)); + $this->assertTrue( + $actual == $expected, + sprintf("Failed asserting that '%s' is numerically equal to '%s'.", $actual, $expected) + ); } #[\PHPUnit\Framework\Attributes\DataProvider('addData')] diff --git a/components/ILIAS/ResourceStorage/tests/Collection/CollectionRepositoryTest.php b/components/ILIAS/ResourceStorage/tests/Collection/CollectionRepositoryTest.php index 17229ada9a0d..db276b4c51f3 100755 --- a/components/ILIAS/ResourceStorage/tests/Collection/CollectionRepositoryTest.php +++ b/components/ILIAS/ResourceStorage/tests/Collection/CollectionRepositoryTest.php @@ -71,10 +71,6 @@ public function testStore(): void ->method('manipulateF') ->with('DELETE FROM il_resource_rca WHERE rcid = %s AND rid NOT IN("rid_one", "rid_one")'); - $this->db_mock->expects($this->once()) - ->method('manipulateF') - ->with('DELETE FROM il_resource_rca WHERE rcid = %s AND rid NOT IN("rid_one", "rid_one")'); - $called_table_names = [ 'il_resource_rca', 'il_resource_rca',