Skip to content

Commit cb82886

Browse files
committed
revert changes to phpunit bootstrap
1 parent c2ceb00 commit cb82886

File tree

1 file changed

+7
-36
lines changed

1 file changed

+7
-36
lines changed

test/phpunit-bootstrap.php

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,11 @@
4242
mb_convert_encoding("Hello, World!", "UTF-16")
4343
];
4444

45-
function switchUser(
46-
string $eppn,
47-
string $given_name,
48-
string $sn,
49-
string $mail,
50-
string|null $session_id = null
51-
): void {
45+
function switchUser(string $eppn, string $given_name, string $sn, string $mail): void
46+
{
5247
global $CONFIG, $REDIS, $LDAP, $SQL, $MAILER, $WEBHOOK, $GITHUB, $SITE, $SSO, $OPERATOR, $USER, $SEND_PIMESG_TO_ADMINS, $LOC_HEADER, $LOC_FOOTER;
5348
session_write_close();
54-
if (is_null($session_id)) {
55-
session_id(str_replace(["_", "@", "."], "-", uniqid($eppn . "_")));
56-
} else {
57-
session_id($session_id);
58-
}
49+
session_id(str_replace(["_", "@", "."], "-", $eppn));
5950
// session_start will be called on the first post()
6051
$_SERVER["REMOTE_USER"] = $eppn;
6152
$_SERVER["REMOTE_ADDR"] = "127.0.0.1";
@@ -74,22 +65,12 @@ function post(string $phpfile, array $post_data): void
7465
ob_start();
7566
try {
7667
include $phpfile;
77-
} finally {
7868
ob_get_clean(); // discard output
79-
unset($_POST);
80-
unset($_SERVER["REQUEST_METHOD"]);
81-
}
82-
}
83-
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;
69+
} catch (Throwable $e) {
70+
error_log(ob_get_clean()); // don't discard output
71+
throw $e;
9172
} finally {
92-
ob_get_clean(); // discard output
73+
unset($_POST);
9374
unset($_SERVER["REQUEST_METHOD"]);
9475
}
9576
}
@@ -128,13 +109,3 @@ function getUserWithOneKey()
128109
{
129110
return ["[email protected]", "foo", "bar", "[email protected]"];
130111
}
131-
132-
function getNonExistentUser()
133-
{
134-
return ["[email protected]", "foo", "bar", "[email protected]"];
135-
}
136-
137-
function getAdminUser()
138-
{
139-
return ["[email protected]", "foo", "bar", "[email protected]"];
140-
}

0 commit comments

Comments
 (0)