Skip to content

Commit 0fe5b3f

Browse files
drummm1guelpf
authored andcommitted
Add $skip_confirmation parameter to Users::createEmailForUser()
1 parent f2944fb commit 0fe5b3f

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

lib/Gitlab/Api/Users.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,14 @@ public function userEmails($user_id)
275275
/**
276276
* @param int $user_id
277277
* @param string $email
278+
* @param bool $skip_confirmation
278279
* @return mixed
279280
*/
280-
public function createEmailForUser($user_id, $email)
281+
public function createEmailForUser($user_id, $email, $skip_confirmation = false)
281282
{
282283
return $this->post('users/'.$this->encodePath($user_id).'/emails', array(
283284
'email' => $email,
285+
'skip_confirmation' => $skip_confirmation,
284286
));
285287
}
286288

test/Gitlab/Tests/Api/UsersTest.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,13 +456,30 @@ public function shouldCreateEmailForUser()
456456
$api = $this->getApiMock();
457457
$api->expects($this->once())
458458
->method('post')
459-
->with('users/1/emails', array('email' => '[email protected]'))
459+
->with('users/1/emails', array('email' => '[email protected]', 'skip_confirmation' => false))
460460
->will($this->returnValue($expectedArray))
461461
;
462462

463463
$this->assertEquals($expectedArray, $api->createEmailForUser(1, '[email protected]'));
464464
}
465465

466+
/**
467+
* @test
468+
*/
469+
public function shouldCreateConfirmedEmailForUser()
470+
{
471+
$expectedArray = array('id' => 4, 'email' => '[email protected]');
472+
473+
$api = $this->getApiMock();
474+
$api->expects($this->once())
475+
->method('post')
476+
->with('users/1/emails', array('email' => '[email protected]', 'skip_confirmation' => true))
477+
->will($this->returnValue($expectedArray))
478+
;
479+
480+
$this->assertEquals($expectedArray, $api->createEmailForUser(1, '[email protected]', true));
481+
}
482+
466483
/**
467484
* @test
468485
*/

0 commit comments

Comments
 (0)