Skip to content

Commit 296d7f9

Browse files
author
Matt Humphrey
committed
Project namespace tests
1 parent 8873d0e commit 296d7f9

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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

Comments
 (0)