forked from loafle/openapi-generator-original
fix index, add test case in php client (#1994)
This commit is contained in:
parent
4f8164e713
commit
c438f67b66
@ -474,7 +474,7 @@ class Configuration
|
||||
$hosts = $this->getHostSettings();
|
||||
|
||||
// check array index out of bound
|
||||
if ($index < 0 || $index > sizeof($hosts)) {
|
||||
if ($index < 0 || $index >= sizeof($hosts)) {
|
||||
throw new \InvalidArgumentException("Invalid index $index when selecting the host. Must be less than ".sizeof($hosts));
|
||||
}
|
||||
|
||||
|
@ -458,7 +458,7 @@ class Configuration
|
||||
$hosts = $this->getHostSettings();
|
||||
|
||||
// check array index out of bound
|
||||
if ($index < 0 || $index > sizeof($hosts)) {
|
||||
if ($index < 0 || $index >= sizeof($hosts)) {
|
||||
throw new \InvalidArgumentException("Invalid index $index when selecting the host. Must be less than ".sizeof($hosts));
|
||||
}
|
||||
|
||||
|
@ -491,7 +491,7 @@ class Configuration
|
||||
$hosts = $this->getHostSettings();
|
||||
|
||||
// check array index out of bound
|
||||
if ($index < 0 || $index > sizeof($hosts)) {
|
||||
if ($index < 0 || $index >= sizeof($hosts)) {
|
||||
throw new \InvalidArgumentException("Invalid index $index when selecting the host. Must be less than ".sizeof($hosts));
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,17 @@ class ConfigurationTest extends TestCase
|
||||
$this->assertSame("http://dev-petstore.swagger.io:8080/v2", $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test invalid index
|
||||
* @expectedException InvalidArgumentException
|
||||
* @expectedExceptionMessage Invalid index 2 when selecting the host. Must be less than 2
|
||||
*/
|
||||
public function testInvalidIndex()
|
||||
{
|
||||
$config = new Configuration();
|
||||
$url = $config->getHostFromSettings(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test host settings with invalid vaues
|
||||
* @expectedException InvalidArgumentException
|
||||
|
Loading…
x
Reference in New Issue
Block a user