1+ <?php namespace Gitlab \Tests \Api ;
2+
3+ use Gitlab \Api \AbstractApi ;
4+
5+ class ProjectNamespacesTest extends TestCase
6+ {
7+ /**
8+ * @test
9+ */
10+ public function shouldGetAllNamespaces ()
11+ {
12+ $ expectedArray = array (
13+ array ('id ' => 1 , 'name ' => 'bespokes ' ),
14+ array ('id ' => 2 , 'name ' => 'internal ' )
15+ );
16+
17+ $ api = $ this ->getApiMock ();
18+ $ api ->expects ($ this ->once ())
19+ ->method ('get ' )
20+ ->with ('namespaces ' , array ('page ' => 1 , 'per_page ' => 10 ))
21+ ->will ($ this ->returnValue ($ expectedArray ))
22+ ;
23+
24+ $ this ->assertEquals ($ expectedArray , $ api ->all (1 , 10 ));
25+ }
26+
27+ /**
28+ * @test
29+ */
30+ public function shouldNotNeedPaginationWhenGettingNamespaces ()
31+ {
32+ $ expectedArray = array (
33+ array ('id ' => 1 , 'name ' => 'bespokes ' ),
34+ array ('id ' => 2 , 'name ' => 'internal ' )
35+ );
36+
37+ $ api = $ this ->getApiMock ();
38+ $ api ->expects ($ this ->once ())
39+ ->method ('get ' )
40+ ->with ('namespaces ' , array ('page ' => 1 , 'per_page ' => AbstractApi::PER_PAGE ))
41+ ->will ($ this ->returnValue ($ expectedArray ))
42+ ;
43+
44+ $ this ->assertEquals ($ expectedArray , $ api ->all ());
45+ }
46+
47+ protected function getApiClass ()
48+ {
49+ return 'Gitlab\Api\ProjectNamespaces ' ;
50+ }
51+ }
0 commit comments