Created
March 2, 2018 15:43
-
-
Save vaceletm/6f84aed38c9e7447fb1529ac61ec2340 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 __DIR__.'/../include/AdminDelegation_UserServiceManager.class.php'; | |
require_once 'common/user/User.class.php'; | |
class AdminDelegation_UserServiceTest extends TuleapTestCase { | |
protected $_keepCurrentTime; | |
function __construct($name = 'AdminDelegation_UserService test') { | |
parent::__construct($name); | |
} | |
function setUp() { | |
parent::setUp(); | |
$this->_keepCurrentTime = $_SERVER['REQUEST_TIME']; | |
$_SERVER['REQUEST_TIME'] = 1259333681; | |
} | |
function tearDown() { | |
$_SERVER['REQUEST_TIME'] = $this->_keepCurrentTime; | |
parent::tearDown(); | |
} | |
function testAddUserToPrivilegeList() { | |
$usDao = \Mockery::spy(AdminDelegation_UserServiceDao::class); | |
$usDao_addUserService = $usDao->shouldReceive('addUserService'); | |
$usDao_addUserService->with(112, AdminDelegation_Service::SHOW_PROJECT_ADMINS); | |
$usDao_addUserService->once(); | |
$usDao_addUserService->andReturns(true); | |
$uslDao = \Mockery::spy(AdminDelegation_UserServiceLogDao::class); | |
$uslDao_addLog = $uslDao->shouldReceive('addLog'); | |
$uslDao_addLog->with('grant', AdminDelegation_Service::SHOW_PROJECT_ADMINS, 112, 1259333681); | |
$uslDao_addLog->once(); | |
$usm = \Mockery::mock(AdminDelegation_UserServiceManager::class)->makePartial()->shouldAllowMockingProtectedMethods(); | |
$usm__getUserServiceDao = $usm->shouldReceive('_getUserServiceDao'); | |
$usm__getUserServiceDao->andReturns($usDao); | |
$usm__getUserServiceLogDao = $usm->shouldReceive('_getUserServiceLogDao'); | |
$usm__getUserServiceLogDao->andReturns($uslDao); | |
$user = \Mockery::spy(PFUser::class); | |
$user_getId = $user->shouldReceive('getId'); | |
$user_getId->andReturns(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