From: Hypolite Petovan Date: Sun, 1 Jul 2018 04:16:32 +0000 (-0400) Subject: Fix $called_api expecting at least 2 elements in tests X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a329ce5b50fc118b8f5aa97e3c4ad6b8c941664c;p=friendica.git Fix $called_api expecting at least 2 elements in tests --- diff --git a/include/api.php b/include/api.php index 6d38be95b7..a9a1800af1 100644 --- a/include/api.php +++ b/include/api.php @@ -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)) { $argid = count($called_api); list($user, $null) = explode(".", $a->argv[$argid]); diff --git a/tests/ApiTest.php b/tests/ApiTest.php index 4c63af7a91..982f5bf11a 100644 --- a/tests/ApiTest.php +++ b/tests/ApiTest.php @@ -818,7 +818,7 @@ class ApiTest extends DatabaseTest public function testApiGetUserWithCalledApi() { global $called_api; - $called_api = ['api_path']; + $called_api = ['api', 'api_path']; $this->assertSelfUser(api_get_user($this->app)); }