Skip to content

A free, self-hostable news aggregator…

Avoid writing to log files during unit tests (#9373)

Inverle1f055da2183f
diff --git a/lib/Minz/Log.php b/lib/Minz/Log.php
index 39b210051..1736e9fbe 100644
--- a/lib/Minz/Log.php
+++ b/lib/Minz/Log.php
@@ -24,14 +24,14 @@ class Minz_Log {
];
/**
- * Enregistre un message dans un fichier de log spécifique
- * Message non loggué si
+ * Records a message in a specific log file
+ * The message is not logged if
* - environment = SILENT
- * - level est moins sévère que le seuil déterminé par `log_level`,
- * ou par défaut par `environment` (PRODUCTION ne garde que warning et error)
- * @param string $information message d'erreur / information à enregistrer
- * @param int $level niveau d'erreur https://www.php.net/function.syslog
- * @param string $file_name fichier de log
+ * - level is less severe than the threshold determined by `log_level`,
+ * or, by default, by `environment` (PRODUCTION keeps only warnings and errors)
+ * @param string $information error message / information to record
+ * @param int $level error level https://www.php.net/function.syslog
+ * @param string $file_name log file
* @throws Minz_PermissionDeniedException
*/
public static function record(string $information, int $level, ?string $file_name = null): void {
diff --git a/phpunit.xml b/phpunit.xml
index 33ba741db..dce206dfa 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -1,12 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
- bootstrap="./tests/bootstrap.php"
- displayDetailsOnAllIssues="true"
- failOnAllIssues="true"
+ bootstrap="./tests/bootstrap.php"
+ displayDetailsOnAllIssues="true"
+ failOnAllIssues="true"
>
- <testsuites>
- <testsuite name="default">
- <directory>./tests</directory>
- </testsuite>
- </testsuites>
+ <php>
+ <env name="FRESHRSS_ENV" value="silent" force="true"/> <!-- To avoid writing into log files -->
+ </php>
+ <testsuites>
+ <testsuite name="default">
+ <directory>./tests</directory>
+ </testsuite>
+ </testsuites>
</phpunit>
diff --git a/tests/lib/Minz/LogTest.php b/tests/lib/Minz/LogTest.php
index c93766767..946c46375 100644
--- a/tests/lib/Minz/LogTest.php
+++ b/tests/lib/Minz/LogTest.php
@@ -13,7 +13,7 @@ class LogTest extends TestCase {
#[\Override]
protected function tearDown(): void {
- putenv('FRESHRSS_ENV');
+ putenv('FRESHRSS_ENV=silent');
@unlink($this->logFile);
}