diff --git a/lib/Gitlab/Api/Users.php b/lib/Gitlab/Api/Users.php index 0675c1f15..2fa1d88c3 100644 --- a/lib/Gitlab/Api/Users.php +++ b/lib/Gitlab/Api/Users.php @@ -76,6 +76,24 @@ public function remove($id) return $this->delete('users/'.$this->encodePath($id)); } + /** + * @param int $id + * @return mixed + */ + public function block($id) + { + return $this->put('users/'.$this->encodePath($id).'/block'); + } + + /** + * @param int $id + * @return mixed + */ + public function unblock($id) + { + return $this->put('users/'.$this->encodePath($id).'/unblock'); + } + /** * @param string $emailOrUsername * @param string $password diff --git a/lib/Gitlab/Model/User.php b/lib/Gitlab/Model/User.php index cce45d0f7..e44835868 100644 --- a/lib/Gitlab/Model/User.php +++ b/lib/Gitlab/Model/User.php @@ -129,6 +129,26 @@ public function remove() return true; } + /** + * @return bool + */ + public function block() + { + $this->api('users')->block($this->id); + + return true; + } + + /** + * @return bool + */ + public function unblock() + { + $this->api('users')->unblock($this->id); + + return true; + } + /** * @return Key[] */ diff --git a/test/Gitlab/Tests/Api/UsersTest.php b/test/Gitlab/Tests/Api/UsersTest.php index 2e5dbe645..cc1d262ab 100644 --- a/test/Gitlab/Tests/Api/UsersTest.php +++ b/test/Gitlab/Tests/Api/UsersTest.php @@ -206,6 +206,40 @@ public function shouldRemoveUser() $this->assertEquals($expectedBool, $api->remove(1)); } + /** + * @test + */ + public function shouldBlockUser() + { + $expectedBool = true; + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('put') + ->with('users/1/block') + ->will($this->returnValue($expectedBool)) + ; + + $this->assertEquals($expectedBool, $api->block(1)); + } + + /** + * @test + */ + public function shouldUnblockUser() + { + $expectedBool = true; + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('put') + ->with('users/1/unblock') + ->will($this->returnValue($expectedBool)) + ; + + $this->assertEquals($expectedBool, $api->unblock(1)); + } + /** * @test */