Created
March 2, 2018 15:32
-
-
Save vaceletm/2fe8a0b87aa8ba8e37692527722e123d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once dirname(__FILE__).'/../include/AdminDelegation_UserServiceManager.class.php'; | |
Mock::generatePartial('AdminDelegation_UserServiceManager', | |
'AdminDelegation_UserServiceManagerTestVersion', | |
array('_getUserServiceLogDao', | |
'_getUserServiceDao')); | |
Mock::generate('AdminDelegation_UserServiceDao'); | |
Mock::generate('AdminDelegation_UserServiceLogDao'); | |
require_once 'common/user/User.class.php'; | |
Mock::generate('PFUser'); | |
class AdminDelegation_UserServiceTest extends TuleapTestCase { | |
protected $_keepCurrentTime; | |
function __construct($name = 'AdminDelegation_UserService test') { | |
parent::__construct($name); | |
} | |
function setUp() { | |
$this->_keepCurrentTime = $_SERVER['REQUEST_TIME']; | |
$_SERVER['REQUEST_TIME'] = 1259333681; | |
} | |
function tearDown() { | |
$_SERVER['REQUEST_TIME'] = $this->_keepCurrentTime; | |
} | |
function testAddUserToPrivilegeList() { | |
$usDao = new MockAdminDelegation_UserServiceDao($this); | |
$usDao->expectOnce('addUserService', array(112, AdminDelegation_Service::SHOW_PROJECT_ADMINS)); | |
$usDao->setReturnValue('addUserService', true); | |
$uslDao = new MockAdminDelegation_UserServiceLogDao($this); | |
$uslDao->expectOnce('addLog', array('grant', AdminDelegation_Service::SHOW_PROJECT_ADMINS, 112, 1259333681)); | |
$usm = new AdminDelegation_UserServiceManagerTestVersion($this); | |
$usm->setReturnValue('_getUserServiceDao', $usDao); | |
$usm->setReturnValue('_getUserServiceLogDao', $uslDao); | |
$user = mock('PFUser'); | |
$user->setReturnValue('getId', 112); | |
$usm->addUserService($user, AdminDelegation_Service::SHOW_PROJECT_ADMINS); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment