Skip to content

Commit 62919f2

Browse files
committed
updated tests for Repositories/Repository
1 parent 29f92c7 commit 62919f2

File tree

1 file changed

+17
-33
lines changed

1 file changed

+17
-33
lines changed

test/Bitbucket/Tests/API/Repositories/RepositoryTest.php

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function invalidCreateProvider()
3232
{
3333
return array(
3434
array(''),
35+
array(3),
3536
array("\t"),
3637
array("\n"),
3738
array(' '),
@@ -41,26 +42,23 @@ public function invalidCreateProvider()
4142
array(
4243
substr(
4344
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
44-
mt_rand( 0 ,50 ) ,1 ) .substr( md5( time() ), 1)
45-
)
45+
mt_rand(0, 50), 1).substr(md5(time()), 1),
46+
),
4647
);
47-
4848
}
4949

5050
/**
51-
* @param $check
52-
* @param $expectation
53-
* @return mixed
51+
* @param mixed $check
5452
* @expectedException \InvalidArgumentException
55-
* @dataProvider invalidCreateProvider
53+
* @dataProvider invalidCreateProvider
54+
* @ticket 27, 26
5655
*/
5756
public function testInvalidCreate($check)
5857
{
59-
60-
$client = $this->getHttpClientMock();
58+
$client = $this->getHttpClientMock();
6159

6260
/** @var \Bitbucket\API\Repositories\Repository $repo */
63-
$repo = $this->getClassMock('Bitbucket\API\Repositories\Repository', $client);
61+
$repo = $this->getClassMock('Bitbucket\API\Repositories\Repository', $client);
6462
$this->setExpectedException('\InvalidArgumentException');
6563
$repo->create('gentle', 'new-repo', $check);
6664
}
@@ -134,28 +132,14 @@ public function testCreateRepositoryWithDefaultParams()
134132
$repo->create('gentle', 'new-repo', array());
135133
}
136134

137-
/**
138-
* @ticket 26
139-
* @expectedException \InvalidArgumentException
140-
*/
141-
public function testCreateRepositoryWithWrongParamsType()
142-
{
143-
/** @var \Bitbucket\API\Repositories\Repository $repo */
144-
$repo = $this->getApiMock('Bitbucket\API\Repositories\Repository');
145-
146-
$repo->create('gentle', 'new-repo', '');
147-
$repo->create('gentle', 'new-repo', 3);
148-
$repo->create('gentle', 'new-repo', "{ 'foo': 'bar' }");
149-
}
150-
151135
public function testCreateRepositorySuccess()
152136
{
153137
$endpoint = 'repositories';
154138
$params = array(
155139
'name' => 'secret',
156140
'description' => 'My super secret project',
157141
'language' => 'php',
158-
'is_private' => true
142+
'is_private' => true,
159143
);
160144

161145
$repository = $this->getApiMock('Bitbucket\API\Repositories\Repository');
@@ -174,7 +158,7 @@ public function testUpdateRepositorySuccess()
174158
'description' => 'My super secret project',
175159
'language' => 'php',
176160
'is_private' => false,
177-
'main_branch' => 'master'
161+
'main_branch' => 'master',
178162
);
179163

180164
$repository = $this->getApiMock('Bitbucket\API\Repositories\Repository');
@@ -242,7 +226,7 @@ public function testForkRepositorySuccess()
242226
$endpoint = 'repositories/gentle/eof/fork';
243227
$params = array(
244228
'name' => 'my-eof',
245-
'is_private' => true
229+
'is_private' => true,
246230
);
247231

248232
$repository = $this->getApiMock('Bitbucket\API\Repositories\Repository');
@@ -263,7 +247,7 @@ public function testGetBranches()
263247
$repository->expects($this->once())
264248
->method('requestGet')
265249
->with($endpoint)
266-
->will( $this->returnValue($expectedResult) );
250+
->will($this->returnValue($expectedResult));
267251

268252
/** @var $repository \Bitbucket\API\Repositories\Repository */
269253
$actual = $repository->branches('gentle', 'eof');
@@ -280,7 +264,7 @@ public function testGetMainBranch()
280264
$repository->expects($this->once())
281265
->method('requestGet')
282266
->with($endpoint)
283-
->will( $this->returnValue($expectedResult) );
267+
->will($this->returnValue($expectedResult));
284268

285269
/** @var $repository \Bitbucket\API\Repositories\Repository */
286270
$actual = $repository->branch('gentle', 'eof');
@@ -297,7 +281,7 @@ public function testGetManifest()
297281
$repository->expects($this->once())
298282
->method('requestGet')
299283
->with($endpoint)
300-
->will( $this->returnValue($expectedResult) );
284+
->will($this->returnValue($expectedResult));
301285

302286
/** @var $repository \Bitbucket\API\Repositories\Repository */
303287
$actual = $repository->manifest('gentle', 'eof', 'develop');
@@ -314,7 +298,7 @@ public function testGetTags()
314298
$repository->expects($this->once())
315299
->method('requestGet')
316300
->with($endpoint)
317-
->will( $this->returnValue($expectedResult) );
301+
->will($this->returnValue($expectedResult));
318302

319303
/** @var $repository \Bitbucket\API\Repositories\Repository */
320304
$actual = $repository->tags('gentle', 'eof');
@@ -331,7 +315,7 @@ public function testGetRawSource()
331315
$repository->expects($this->once())
332316
->method('requestGet')
333317
->with($endpoint)
334-
->will( $this->returnValue($expectedResult) );
318+
->will($this->returnValue($expectedResult));
335319

336320
/** @var $repository \Bitbucket\API\Repositories\Repository */
337321
$actual = $repository->raw('gentle', 'eof', '1bc8345', 'lib/file.php');
@@ -348,7 +332,7 @@ public function testGetFileHistory()
348332
$repository->expects($this->once())
349333
->method('requestGet')
350334
->with($endpoint)
351-
->will( $this->returnValue($expectedResult) );
335+
->will($this->returnValue($expectedResult));
352336

353337
/** @var $repository \Bitbucket\API\Repositories\Repository */
354338
$actual = $repository->filehistory('gentle', 'eof', '1bc8345', 'lib/file.php');

0 commit comments

Comments
 (0)