Fix $called_api expecting at least 2 elements in tests

This commit is contained in:
Hypolite Petovan 2018-07-01 00:16:32 -04:00
parent 6776c4e3f9
commit a329ce5b50
2 changed files with 2 additions and 1 deletions

View file

@ -575,6 +575,7 @@ function api_get_user(App $a, $contact_id = null)
} }
} }
// $called_api is the API path exploded on / and is expected to have at least 2 elements
if (is_null($user) && ($a->argc > (count($called_api) - 1)) && (count($called_api) > 0)) { if (is_null($user) && ($a->argc > (count($called_api) - 1)) && (count($called_api) > 0)) {
$argid = count($called_api); $argid = count($called_api);
list($user, $null) = explode(".", $a->argv[$argid]); list($user, $null) = explode(".", $a->argv[$argid]);

View file

@ -818,7 +818,7 @@ class ApiTest extends DatabaseTest
public function testApiGetUserWithCalledApi() public function testApiGetUserWithCalledApi()
{ {
global $called_api; global $called_api;
$called_api = ['api_path']; $called_api = ['api', 'api_path'];
$this->assertSelfUser(api_get_user($this->app)); $this->assertSelfUser(api_get_user($this->app));
} }