1
1
<?php namespace Gitlab \Tests \Api ;
2
2
3
3
use Gitlab \Api \AbstractApi ;
4
+ use Gitlab \Api \Projects ;
4
5
5
6
class ProjectsTest extends TestCase
6
7
{
@@ -13,7 +14,19 @@ public function shouldGetAllProjects()
13
14
14
15
$ api = $ this ->getMultipleProjectsRequestMock ('projects/all ' , $ expectedArray );
15
16
16
- $ this ->assertEquals ($ expectedArray , $ api ->all (1 , 10 ));
17
+ $ this ->assertEquals ($ expectedArray , $ api ->all ());
18
+ }
19
+
20
+ /**
21
+ * @test
22
+ */
23
+ public function shouldGetAllProjectsSortedByName ()
24
+ {
25
+ $ expectedArray = $ this ->getMultipleProjectsData ();
26
+
27
+ $ api = $ this ->getMultipleProjectsRequestMock ('projects/all ' , $ expectedArray , 1 , 5 , 'name ' , 'asc ' );
28
+
29
+ $ this ->assertEquals ($ expectedArray , $ api ->all (1 , 5 , 'name ' ));
17
30
}
18
31
19
32
/**
@@ -26,7 +39,7 @@ public function shouldNotNeedPaginationWhenGettingProjects()
26
39
$ api = $ this ->getApiMock ();
27
40
$ api ->expects ($ this ->once ())
28
41
->method ('get ' )
29
- ->with ('projects/all ' , array ('page ' => 1 , 'per_page ' => AbstractApi::PER_PAGE ))
42
+ ->with ('projects/all ' , array ('page ' => 1 , 'per_page ' => AbstractApi::PER_PAGE , ' order_by ' => Projects:: ORDER_BY , ' sort ' => Projects:: SORT ))
30
43
->will ($ this ->returnValue ($ expectedArray ))
31
44
;
32
45
@@ -66,7 +79,7 @@ public function shouldSearchProjects()
66
79
67
80
$ api = $ this ->getMultipleProjectsRequestMock ('projects/search/a+project ' , $ expectedArray );
68
81
69
- $ this ->assertEquals ($ expectedArray , $ api ->search ('a project ' , 1 , 10 ));
82
+ $ this ->assertEquals ($ expectedArray , $ api ->search ('a project ' ));
70
83
}
71
84
72
85
/**
@@ -703,12 +716,12 @@ public function shouldRemoveService()
703
716
$ this ->assertEquals ($ expectedBool , $ api ->removeService (1 , 'hipchat ' ));
704
717
}
705
718
706
- protected function getMultipleProjectsRequestMock ($ path , $ expectedArray = array (), $ page = 1 , $ per_page = 10 )
719
+ protected function getMultipleProjectsRequestMock ($ path , $ expectedArray = array (), $ page = 1 , $ per_page = 20 , $ order_by = ' created_at ' , $ sort = ' asc ' )
707
720
{
708
721
$ api = $ this ->getApiMock ();
709
722
$ api ->expects ($ this ->once ())
710
723
->method ('get ' )
711
- ->with ($ path , array ('page ' => $ page , 'per_page ' => $ per_page ))
724
+ ->with ($ path , array ('page ' => $ page , 'per_page ' => $ per_page, ' order_by ' => $ order_by , ' sort ' => $ sort ))
712
725
->will ($ this ->returnValue ($ expectedArray ))
713
726
;
714
727
0 commit comments