FOSSology  4.7.1
Open Source License Compliance by Open Source Software
AuthTest.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2026 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
8 namespace Fossology\Lib\Auth;
9 
14 class AuthTest extends \PHPUnit\Framework\TestCase
15 {
16  protected function setUp(): void
17  {
18  $_SESSION = array();
19  }
20 
21  protected function tearDown(): void
22  {
23  $_SESSION = array();
24  }
25 
32  public function testIsAdminFalseWhenSessionEmpty(): void
33  {
34  $this->assertFalse(Auth::isAdmin());
35  }
36 
42  {
43  $_SESSION[Auth::USER_LEVEL] = Auth::PERM_ADMIN - 1;
44  $this->assertFalse(Auth::isAdmin());
45  }
46 
52  public function testIsAdminTrueWhenUserLevelIsAdmin(): void
53  {
55  $this->assertTrue(Auth::isAdmin());
56  }
57 }
Test for class Auth.
Definition: AuthTest.php:15
static isAdmin()
Check if user is admin.
Definition: Auth.php:92