Skip to content

Instantly share code, notes, and snippets.

@vaceletm
Created March 2, 2018 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vaceletm/2fe8a0b87aa8ba8e37692527722e123d to your computer and use it in GitHub Desktop.
Save vaceletm/2fe8a0b87aa8ba8e37692527722e123d to your computer and use it in GitHub Desktop.
<?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