Skip to content

Commit 1514b2b

Browse files
authored
tests: prevent output in phpunit tests (#1158)
I noticed an accidental `echo` left in a test during a recent review. It's best practice to avoid output during tests. Update PHPUnit config to make CI fail, rather than relying on human code review. * Modify `ElasticSearchIndexDeleteTest` so it doesn't print output. * `beStrictAboutOutputDuringTests` marks tests as "risky" if there is output printed. * `failOnRisky` makes the test suite fail if any tests are marked as "risky". Bug: T428716
1 parent 5bbd9da commit 1514b2b

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

phpunit.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
1010
cacheDirectory=".phpunit.cache"
1111
backupStaticProperties="false"
12+
beStrictAboutOutputDuringTests="true"
13+
failOnRisky="true"
1214
>
1315
<testsuites>
1416
<testsuite name="Application Test Suite">

tests/Jobs/Integration/ElasticSearchIndexDeleteTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,11 @@ public function makeRequest($url, $method = 'GET') {
4848
);
4949
$response = $curlRequest->execute();
5050
$err = $curlRequest->error();
51-
var_dump($response);
51+
$curlRequest->close();
5252

5353
if ($err) {
54-
var_dump($err);
54+
$this->fail("Request returned an error: {$err}");
5555
}
56-
$curlRequest->close();
5756

5857
return json_decode($response, true);
5958
}

0 commit comments

Comments
 (0)