1
+ <?php namespace Gitlab \Tests \Api ;
2
+
3
+ class MilestonesTest extends TestCase
4
+ {
5
+ /**
6
+ * @test
7
+ */
8
+ public function shouldGetAllMilestones ()
9
+ {
10
+ $ expectedArray = array (
11
+ array ('id ' => 1 , 'title ' => 'A milestone ' ),
12
+ array ('id ' => 2 , 'title ' => 'Another milestone ' ),
13
+ );
14
+
15
+ $ api = $ this ->getApiMock ();
16
+ $ api ->expects ($ this ->once ())
17
+ ->method ('get ' )
18
+ ->with ('projects/1/milestones ' )
19
+ ->will ($ this ->returnValue ($ expectedArray ))
20
+ ;
21
+
22
+ $ this ->assertEquals ($ expectedArray , $ api ->all (1 ));
23
+ }
24
+
25
+ /**
26
+ * @test
27
+ */
28
+ public function shouldShowMilestone ()
29
+ {
30
+ $ expectedArray = array ('id ' => 1 , 'name ' => 'A milestone ' );
31
+
32
+ $ api = $ this ->getApiMock ();
33
+ $ api ->expects ($ this ->once ())
34
+ ->method ('get ' )
35
+ ->with ('projects/1/milestones/2 ' )
36
+ ->will ($ this ->returnValue ($ expectedArray ))
37
+ ;
38
+
39
+ $ this ->assertEquals ($ expectedArray , $ api ->show (1 , 2 ));
40
+ }
41
+
42
+ /**
43
+ * @test
44
+ */
45
+ public function shouldCreateMilestone ()
46
+ {
47
+ $ expectedArray = array ('id ' => 3 , 'title ' => 'A new milestone ' );
48
+
49
+ $ api = $ this ->getApiMock ();
50
+ $ api ->expects ($ this ->once ())
51
+ ->method ('post ' )
52
+ ->with ('projects/1/milestones ' , array ('description ' => 'Some text ' , 'title ' => 'A new milestone ' ))
53
+ ->will ($ this ->returnValue ($ expectedArray ))
54
+ ;
55
+
56
+ $ this ->assertEquals ($ expectedArray , $ api ->create (1 , array ('description ' => 'Some text ' , 'title ' => 'A new milestone ' )));
57
+ }
58
+
59
+ /**
60
+ * @test
61
+ */
62
+ public function shouldUpdateMilestone ()
63
+ {
64
+ $ expectedArray = array ('id ' => 3 , 'title ' => 'Updated milestone ' );
65
+
66
+ $ api = $ this ->getApiMock ();
67
+ $ api ->expects ($ this ->once ())
68
+ ->method ('put ' )
69
+ ->with ('projects/1/milestones/3 ' , array ('title ' => 'Updated milestone ' , 'due_date ' => '2015-04-01 ' , 'state_event ' => 'close ' ))
70
+ ->will ($ this ->returnValue ($ expectedArray ))
71
+ ;
72
+
73
+ $ this ->assertEquals ($ expectedArray , $ api ->update (1 , 3 , array ('title ' => 'Updated milestone ' , 'due_date ' => '2015-04-01 ' , 'state_event ' => 'close ' )));
74
+ }
75
+
76
+ /**
77
+ * @test
78
+ */
79
+ public function shouldGetMilestonesIssues ()
80
+ {
81
+ $ expectedArray = array (
82
+ array ('id ' => 1 , 'title ' => 'An issue ' ),
83
+ array ('id ' => 2 , 'title ' => 'Another issue ' ),
84
+ );
85
+
86
+ $ api = $ this ->getApiMock ();
87
+ $ api ->expects ($ this ->once ())
88
+ ->method ('get ' )
89
+ ->with ('projects/1/milestones/3/issues ' )
90
+ ->will ($ this ->returnValue ($ expectedArray ))
91
+ ;
92
+
93
+ $ this ->assertEquals ($ expectedArray , $ api ->issues (1 , 3 ));
94
+ }
95
+
96
+ protected function getApiClass ()
97
+ {
98
+ return 'Gitlab\Api\Milestones ' ;
99
+ }
100
+ }
0 commit comments