Skip to content

Commit d857d42

Browse files
author
Matt Humphrey
committed
System hooks test
1 parent 142e85d commit d857d42

File tree

2 files changed

+80
-2
lines changed

2 files changed

+80
-2
lines changed

test/Gitlab/Tests/Api/SnippetsTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php namespace Gitlab\Tests\Api;
22

3-
use Gitlab\Api\AbstractApi;
4-
53
class SnippetsTest extends TestCase
64
{
75
/**
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php namespace Gitlab\Tests\Api;
2+
3+
class SystemHooksTest extends TestCase
4+
{
5+
/**
6+
* @test
7+
*/
8+
public function shouldGetAllHooks()
9+
{
10+
$expectedArray = array(
11+
array('id' => 1, 'url' => 'http://www.example.com'),
12+
array('id' => 2, 'url' => 'http://www.example.org'),
13+
);
14+
15+
$api = $this->getApiMock();
16+
$api->expects($this->once())
17+
->method('get')
18+
->with('hooks')
19+
->will($this->returnValue($expectedArray))
20+
;
21+
22+
$this->assertEquals($expectedArray, $api->all());
23+
}
24+
25+
/**
26+
* @test
27+
*/
28+
public function shouldCreateHook()
29+
{
30+
$expectedArray = array('id' => 3, 'url' => 'http://www.example.net');
31+
32+
$api = $this->getApiMock();
33+
$api->expects($this->once())
34+
->method('post')
35+
->with('hooks', array('url' => 'http://www.example.net'))
36+
->will($this->returnValue($expectedArray))
37+
;
38+
39+
$this->assertEquals($expectedArray, $api->create('http://www.example.net'));
40+
}
41+
42+
/**
43+
* @test
44+
*/
45+
public function shouldTestHook()
46+
{
47+
$expectedBool = true;
48+
49+
$api = $this->getApiMock();
50+
$api->expects($this->once())
51+
->method('get')
52+
->with('hooks/3')
53+
->will($this->returnValue($expectedBool))
54+
;
55+
56+
$this->assertEquals($expectedBool, $api->test(3));
57+
}
58+
59+
/**
60+
* @test
61+
*/
62+
public function shouldRemoveHook()
63+
{
64+
$expectedBool = true;
65+
66+
$api = $this->getApiMock();
67+
$api->expects($this->once())
68+
->method('delete')
69+
->with('hooks/3')
70+
->will($this->returnValue($expectedBool))
71+
;
72+
73+
$this->assertEquals($expectedBool, $api->remove(3));
74+
}
75+
76+
protected function getApiClass()
77+
{
78+
return 'Gitlab\Api\SystemHooks';
79+
}
80+
}

0 commit comments

Comments
 (0)