Fix $called_api expecting at least 2 elements in tests
authorHypolite Petovan <mrpetovan@gmail.com>
Sun, 1 Jul 2018 04:16:32 +0000 (00:16 -0400)
committerHypolite Petovan <mrpetovan@gmail.com>
Mon, 2 Jul 2018 11:45:11 +0000 (07:45 -0400)
include/api.php
tests/ApiTest.php

index 6d38be9..a9a1800 100644 (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)) {
                $argid = count($called_api);
                list($user, $null) = explode(".", $a->argv[$argid]);
index 4c63af7..982f5bf 100644 (file)
@@ -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));
        }