diff --git a/lib/REST.php b/lib/REST.php index d8dce626..f7818e56 100644 --- a/lib/REST.php +++ b/lib/REST.php @@ -86,7 +86,7 @@ class REST { // create a request object if not provided $req = $req ?? ServerRequestFactory::fromGlobals(); // find the API to handle - [$api, $target, $class] = $this->apiMatch($req->getRequestTarget(), $this->apis); + [, $target, $class] = $this->apiMatch($req->getRequestTarget(), $this->apis); // authenticate the request pre-emptively $req = $this->authenticateRequest($req); // modify the request to have an uppercase method and a stripped target diff --git a/tests/cases/TestArsse.php b/tests/cases/TestArsse.php index 2173db83..f7e4e8e8 100644 --- a/tests/cases/TestArsse.php +++ b/tests/cases/TestArsse.php @@ -6,6 +6,7 @@ declare(strict_types=1); namespace JKingWeb\Arsse\TestCase; +use JKingWeb\Arsse\Exception; use JKingWeb\Arsse\Arsse; use JKingWeb\Arsse\Conf; use JKingWeb\Arsse\Lang; @@ -47,4 +48,21 @@ class TestArsse extends \JKingWeb\Arsse\Test\AbstractTest { $this->assertInstanceOf(Database::class, Arsse::$db); $this->assertInstanceOf(User::class, Arsse::$user); } + + /** @dataProvider provideExtensionChecks */ + public function testCheckForExtensions(array $ext, $exp): void { + if ($exp instanceof \Exception) { + $this->assertException($exp); + Arsse::checkExtensions(...$ext); + } else { + $this->assertNull(Arsse::checkExtensions(...$ext)); + } + } + + public function provideExtensionChecks(): iterable { + return [ + [["pcre"], null], + [["foo", "bar", "baz"], new Exception("extMissing", ['first' => "foo", 'total' => 3])], + ]; + } }