mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 05:02:40 +00:00
Basic tests for exception checking
This commit is contained in:
parent
04adc3b997
commit
3c8ee42666
2 changed files with 19 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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])],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue