Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions test/functional/NewUserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private function approveGroup($uid)
// does not remove user from PI groups
private function ensureUserDoesNotExist()
{
global $USER, $SQL, $LDAP;
global $USER, $SQL, $LDAP, $REDIS;
$SQL->deleteRequestsByUser($USER->uid);
if ($USER->exists()) {
$org = $USER->getOrgGroup();
Expand All @@ -116,6 +116,7 @@ private function ensureUserDoesNotExist()
$all_users_group->write();
assert(!in_array($USER->uid, $all_users_group->getAttribute("memberuid")));
}
$REDIS->removeCacheArray("sorted_users", "", $USER->uid);
}

private function ensureOrgGroupDoesNotExist()
Expand All @@ -126,24 +127,28 @@ private function ensureOrgGroupDoesNotExist()
$org_group->delete();
assert(!$org_group->exists());
}
$REDIS->removeCacheArray("sorted_orgs", "", $SSO["org"]);
}

private function ensureUserNotInPIGroup(UnityGroup $pi_group)
{
global $USER;
global $USER, $REDIS;
if ($pi_group->userExists($USER)) {
$pi_group->removeUser($USER);
assert(!$pi_group->userExists($USER));
}
$REDIS->removeCacheArray($pi_group->gid, "members", $USER->uid);
}

private function ensurePIGroupDoesNotExist()
{
global $USER, $LDAP;
global $USER, $LDAP, $REDIS;
$gid = $USER->getPIGroup()->gid;
if ($USER->getPIGroup()->exists()) {
$LDAP->getPIGroupEntry($USER->getPIGroup()->gid)->delete();
$LDAP->getPIGroupEntry($gid)->delete();
assert(!$USER->getPIGroup()->exists());
}
$REDIS->removeCacheArray("sorted_groups", "", $gid);
}

public function testCreateUserByJoinGoupByPI()
Expand Down Expand Up @@ -327,6 +332,7 @@ public function testCreateUserByCreateGroup()
// $this->assertTrue($third_request_failed);
$this->assertRequestedPIGroup(false);
} finally {
switchUser(...$user_to_create_args);
$this->ensureOrgGroupDoesNotExist();
$this->ensurePIGroupDoesNotExist();
$this->ensureUserDoesNotExist();
Expand Down
35 changes: 35 additions & 0 deletions test/functional/PageLoadTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;

class PageLoadTest extends TestCase
{
public static function provider()
{
$admin = getAdminUser();
$nonexistent_user = getNonExistentUser();
$normal_user = getNormalUser();
$pi = getUserIsPIHasNoMembersNoMemberRequests();
return [
[$admin, __DIR__ . "/../../webroot/admin/pi-mgmt.php"],
[$admin, __DIR__ . "/../../webroot/admin/user-mgmt.php"],
[$admin, __DIR__ . "/../../webroot/admin/content.php"],
[$admin, __DIR__ . "/../../webroot/admin/notices.php"],
[$nonexistent_user, __DIR__ . "/../../webroot/panel/new_account.php"],
[$normal_user, __DIR__ . "/../../webroot/panel/account.php"],
[$normal_user, __DIR__ . "/../../webroot/panel/groups.php"],
[$normal_user, __DIR__ . "/../../webroot/panel/support.php"],
[$pi, __DIR__ . "/../../webroot/panel/pi.php"],
];
}

#[DataProvider("provider")]
public function testLoadPage($user, $path)
{
global $USER, $SSO, $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK;
switchuser(...$user);
http_get($path);
$this->assertTrue(true); // assert there were no errors
}
}
2 changes: 1 addition & 1 deletion webroot/panel/support.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require "../../resources/autoload.php";
require_once __DIR__ . "/../../resources/autoload.php";

include $LOC_HEADER;
?>
Expand Down