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