@@ -7,24 +7,34 @@ class PageLoadTest extends UnityWebPortalTestCase
77 public static function provider ()
88 {
99 return [
10- ["Admin " , __DIR__ . "/../../webroot/admin/pi-mgmt.php " ],
11- ["Admin " , __DIR__ . "/../../webroot/admin/user-mgmt.php " ],
12- ["Admin " , __DIR__ . "/../../webroot/admin/content.php " ],
13- ["Admin " , __DIR__ . "/../../webroot/admin/notices.php " ],
14- ["NonExistent " , __DIR__ . "/../../webroot/panel/new_account.php " ],
15- ["Blank " , __DIR__ . "/../../webroot/panel/account.php " ],
16- ["Blank " , __DIR__ . "/../../webroot/panel/groups.php " ],
17- ["Blank " , __DIR__ . "/../../webroot/panel/support.php " ],
18- ["EmptyPIGroupOwner " , __DIR__ . "/../../webroot/panel/pi.php " ],
10+ // normal page load
11+ ["Admin " , "admin/pi-mgmt.php " , "/PI Management/ " ],
12+ ["Admin " , "admin/user-mgmt.php " , "/User Management/ " ],
13+ ["Admin " , "admin/content.php " , "/Page Content Management/ " ],
14+ ["Admin " , "admin/notices.php " , "/Cluster Notice Management/ " ],
15+ ["NonExistent " , "panel/new_account.php " , "/Register New Account/ " ],
16+ ["Blank " , "panel/account.php " , "/Account Settings/ " ],
17+ ["Blank " , "panel/groups.php " , "/My Principal Investigators/ " ],
18+ ["Blank " , "panel/support.php " , "/Support/ " ],
19+ ["EmptyPIGroupOwner " , "panel/pi.php " , "/My Users/ " ],
20+ // normal user should not be able to access admin pages
21+ ["Blank " , "admin/pi-mgmt.php " , "/You are not an admin/ " ],
22+ ["Blank " , "admin/user-mgmt.php " , "/You are not an admin/ " ],
23+ ["Blank " , "admin/content.php " , "/You are not an admin/ " ],
24+ ["Blank " , "admin/notices.php " , "/You are not an admin/ " ],
25+ // new_account.php should redirect to account.php if account already exists
26+ ["Blank " , "panel/new_account.php " , "/panel\/account\.php/ " ],
27+ // all pages should redirect to new_account.php if account does not exist
28+ ["NonExistent " , "panel/account.php " , "/panel\/new_account\.php/ " ],
1929 ];
2030 }
2131
2232 #[DataProvider("provider " )]
23- public function testLoadPage ($ nickname , $ path )
33+ public function testLoadPage ($ nickname , $ path, $ regex )
2434 {
2535 global $ USER , $ SSO , $ LDAP , $ SQL , $ MAILER , $ WEBHOOK ;
2636 $ this ->switchUser ($ nickname );
27- http_get ($ path );
28- $ this ->assertTrue ( true ); // assert there were no errors
37+ $ output = http_get (__DIR__ . " /../../webroot/ " . $ path );
38+ $ this ->assertMatchesRegularExpression ( $ regex , $ output );
2939 }
3040}
0 commit comments