1<?php 2/* 3Copyright (C) 2014, Siemens AG 4 5This program is free software; you can redistribute it and/or 6modify it under the terms of the GNU General Public License 7version 2 as published by the Free Software Foundation. 8 9This program is distributed in the hope that it will be useful, 10but WITHOUT ANY WARRANTY; without even the implied warranty of 11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12GNU General Public License for more details. 13 14You should have received a copy of the GNU General Public License along 15with this program; if not, write to the Free Software Foundation, Inc., 1651 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17*/ 18 19namespace Fossology\Lib\Application; 20 21/** 22 * @class UserInfoTest 23 * @brief Unit tests for UserInfo class 24 */ 25class UserInfoTest extends \PHPUnit\Framework\TestCase 26{ 27 28 /** @var UserInfo $userInfo 29 * UserInfo class object for testing */ 30 private $userInfo; 31 32 /** 33 * @brief One time setup for test 34 * @see PHPUnit::Framework::TestCase::setUp() 35 */ 36 protected function setUp() 37 { 38 $this->userInfo = new UserInfo(); 39 } 40 41 /** 42 * @brief Test for UserInfo::getUserId() 43 * @test 44 * -# Set user id in session. 45 * -# Call UserInfo::getUserId() and check if the id matches. 46 */ 47 public function testGetUserId() 48 { 49 $userId = 424; 50 51 $_SESSION['UserId'] = $userId; 52 53 assertThat($this->userInfo->getUserId(), is($userId)); 54 } 55 56 /** 57 * @brief Test for UserInfo::getGroupId() 58 * @test 59 * -# Set group id in session. 60 * -# Call UserInfo::getGroupId() and check if the id matches. 61 */ 62 public function testGetGroupId() 63 { 64 $groupId = 321; 65 66 $_SESSION['GroupId'] = $groupId; 67 68 assertThat($this->userInfo->getGroupId(), is($groupId)); 69 } 70} 71