Skip to content

Commit e06c0c0

Browse files
committed
Replace assert() with PHPUnit assertions in cache cleanup
PHP assert() can be disabled via zend.assertions=-1, making cleanup failures invisible. Use self::assertTrue() / $this->assertTrue() to ensure failures surface reliably in all environments.
1 parent e766edc commit e06c0c0

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

tests/unit/htdocs/class/cache/XoopsCacheTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ public static function tearDownAfterClass(): void
3535
$ok = $file->isDir()
3636
? rmdir($file->getPathname())
3737
: unlink($file->getPathname());
38-
assert($ok, 'Failed to remove cache artifact: ' . basename($file->getPathname()));
38+
self::assertTrue($ok, 'Failed to remove cache artifact: ' . basename($file->getPathname()));
3939
}
40-
assert(rmdir(self::$cachePath), 'Failed to remove cache test directory: ' . basename(self::$cachePath));
40+
self::assertTrue(rmdir(self::$cachePath), 'Failed to remove cache test directory: ' . basename(self::$cachePath));
4141
}
4242

4343
protected function setUp(): void
@@ -697,9 +697,12 @@ public function testConfigWithMultipleEngines()
697697
\RecursiveIteratorIterator::CHILD_FIRST
698698
);
699699
foreach ($entries as $entry) {
700-
$entry->isDir() ? rmdir($entry->getPathname()) : unlink($entry->getPathname());
700+
$removed = $entry->isDir()
701+
? rmdir($entry->getPathname())
702+
: unlink($entry->getPathname());
703+
$this->assertTrue($removed, 'Failed to remove temp artifact: ' . basename($entry->getPathname()));
701704
}
702-
rmdir($secondPath);
705+
$this->assertTrue(rmdir($secondPath), 'Failed to remove second temp cache directory');
703706
$this->assertDirectoryDoesNotExist($secondPath, 'Temp directory should be cleaned up');
704707
}
705708
}

0 commit comments

Comments
 (0)