Skip to content

Commit 29f92c7

Browse files
committed
Merged in gerryghall/bitbucket-api (pull request #22)
add new test which validate correct Exception in Repository::create this thrown if $params fails.
2 parents 14c33a5 + db13f5f commit 29f92c7

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,46 @@ public function testGetRepository()
2525
$this->assertEquals($expectedResult, $actual);
2626
}
2727

28+
/**
29+
* @return array of invalid value for repo creations parameter
30+
*/
31+
public function invalidCreateProvider()
32+
{
33+
return array(
34+
array(''),
35+
array("\t"),
36+
array("\n"),
37+
array(' '),
38+
array("{ 'bar': 'baz' }"),
39+
array('{ repo: "company", }'),
40+
array('{ repo: "company" }'),
41+
array(
42+
substr(
43+
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
44+
mt_rand( 0 ,50 ) ,1 ) .substr( md5( time() ), 1)
45+
)
46+
);
47+
48+
}
49+
50+
/**
51+
* @param $check
52+
* @param $expectation
53+
* @return mixed
54+
* @expectedException \InvalidArgumentException
55+
* @dataProvider invalidCreateProvider
56+
*/
57+
public function testInvalidCreate($check)
58+
{
59+
60+
$client = $this->getHttpClientMock();
61+
62+
/** @var \Bitbucket\API\Repositories\Repository $repo */
63+
$repo = $this->getClassMock('Bitbucket\API\Repositories\Repository', $client);
64+
$this->setExpectedException('\InvalidArgumentException');
65+
$repo->create('gentle', 'new-repo', $check);
66+
}
67+
2868
public function testCreateRepositoryFromJSON()
2969
{
3070
$endpoint = 'repositories/gentle/new-repo';

0 commit comments

Comments
 (0)