Skip to content

Commit cef7ff5

Browse files
committed
Client::setApiVersion argument type
setApiVersion method should accept only string type argument. fixes #57
1 parent 00feb80 commit cef7ff5

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

lib/Bitbucket/API/Http/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public function getApiVersion()
187187
*/
188188
public function setApiVersion($version)
189189
{
190-
if (!in_array($version, $this->options['api_versions'])) {
190+
if (!in_array($version, $this->options['api_versions'], true)) {
191191
throw new \InvalidArgumentException(sprintf('Unsupported API version %s', $version));
192192
}
193193

lib/Bitbucket/API/Http/ClientInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function getApiVersion();
109109
* Supported versions: 1.0, 2.0
110110
*
111111
* @access public
112-
* @param float $version
112+
* @param string $version
113113
* @return $this
114114
*
115115
* @throws \InvalidArgumentException If invalid API version is provided

test/Bitbucket/Tests/API/Http/ClientTest.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ public function testResponseFormatSuccess()
4343
}
4444

4545
/**
46+
* @dataProvider invalidApiVersionsProvider
4647
* @expectedException \InvalidArgumentException
48+
* @ticket 57
4749
*/
48-
public function testSetApiVersionInvalid()
50+
public function testSetApiVersionInvalid($version)
4951
{
50-
$this->client->setApiVersion('1.1.1');
52+
$this->client->setApiVersion($version);
5153
}
5254

5355
public function testApiVersionSuccess()
@@ -202,4 +204,11 @@ private function getListenerMock($name = 'dummy')
202204

203205
return $listener;
204206
}
207+
208+
public function invalidApiVersionsProvider()
209+
{
210+
return [
211+
['3.1'], ['1,2'], ['1,0'], ['2.1'], ['4'], [2], ['string'], [2.0]
212+
];
213+
}
205214
}

0 commit comments

Comments
 (0)