Skip to content

Commit b2489b6

Browse files
committed
add get(), always discard output
1 parent f82470e commit b2489b6

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

test/phpunit-bootstrap.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,26 @@ function post(string $phpfile, array $post_data): void
7474
ob_start();
7575
try {
7676
include $phpfile;
77-
ob_get_clean(); // discard output
78-
} catch (Throwable $e) {
79-
error_log(ob_get_clean()); // don't discard output
80-
throw $e;
8177
} finally {
78+
ob_get_clean(); // discard output
8279
unset($_POST);
8380
unset($_SERVER["REQUEST_METHOD"]);
8481
}
8582
}
8683

84+
function get(string $phpfile): void
85+
{
86+
global $CONFIG, $REDIS, $LDAP, $SQL, $MAILER, $WEBHOOK, $GITHUB, $SITE, $SSO, $OPERATOR, $USER, $SEND_PIMESG_TO_ADMINS, $LOC_HEADER, $LOC_FOOTER;
87+
$_SERVER["REQUEST_METHOD"] = "GET";
88+
ob_start();
89+
try {
90+
include $phpfile;
91+
} finally {
92+
ob_get_clean(); // discard output
93+
unset($_SERVER["REQUEST_METHOD"]);
94+
}
95+
}
96+
8797
function getNormalUser()
8898
{
8999
return ["[email protected]", "foo", "bar", "[email protected]"];

0 commit comments

Comments
 (0)