11<?php namespace Gitlab \Tests \Api ;
22
33use Gitlab \Api \AbstractApi ;
4+ use Gitlab \Api \Projects ;
45
56class ProjectsTest extends TestCase
67{
@@ -13,7 +14,19 @@ public function shouldGetAllProjects()
1314
1415 $ api = $ this ->getMultipleProjectsRequestMock ('projects/all ' , $ expectedArray );
1516
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 ' ));
1730 }
1831
1932 /**
@@ -26,7 +39,7 @@ public function shouldNotNeedPaginationWhenGettingProjects()
2639 $ api = $ this ->getApiMock ();
2740 $ api ->expects ($ this ->once ())
2841 ->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 ))
3043 ->will ($ this ->returnValue ($ expectedArray ))
3144 ;
3245
@@ -66,7 +79,7 @@ public function shouldSearchProjects()
6679
6780 $ api = $ this ->getMultipleProjectsRequestMock ('projects/search/a+project ' , $ expectedArray );
6881
69- $ this ->assertEquals ($ expectedArray , $ api ->search ('a project ' , 1 , 10 ));
82+ $ this ->assertEquals ($ expectedArray , $ api ->search ('a project ' ));
7083 }
7184
7285 /**
@@ -703,12 +716,12 @@ public function shouldRemoveService()
703716 $ this ->assertEquals ($ expectedBool , $ api ->removeService (1 , 'hipchat ' ));
704717 }
705718
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 ' )
707720 {
708721 $ api = $ this ->getApiMock ();
709722 $ api ->expects ($ this ->once ())
710723 ->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 ))
712725 ->will ($ this ->returnValue ($ expectedArray ))
713726 ;
714727
0 commit comments