mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-23 07:54:51 +00:00
f902346b6c
- RuntimeData has now been replaced by a single static Data class - The Data class has a load() method which fills the same role as the constructor of RuntimeData - The static Lang class is now an instantiable class and is a member of Data - All tests have been adjusted and pass - The Exception tests no longer require convoluted workarounds: a simple mock for Data::$l suffices; Lang tests also use a mock to prevent loops now instead of using a workaround
44 lines
No EOL
1.1 KiB
PHP
44 lines
No EOL
1.1 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
namespace JKingWeb\Arsse;
|
|
use JKingWeb\Arsse\Rest\Request;
|
|
use JKingWeb\Arsse\Rest\Response;
|
|
|
|
|
|
class TestNCNVersionDiscovery extends \PHPUnit\Framework\TestCase {
|
|
use Test\Tools;
|
|
|
|
function setUp() {
|
|
$this->clearData();
|
|
}
|
|
|
|
function testFetchVersionList() {
|
|
$exp = new Response(200, ['apiLevels' => ['v1-2']]);
|
|
$h = new Rest\NextCloudNews\Versions();
|
|
$req = new Request("GET", "/");
|
|
$res = $h->dispatch($req);
|
|
$this->assertEquals($exp, $res);
|
|
$req = new Request("GET", "");
|
|
$res = $h->dispatch($req);
|
|
$this->assertEquals($exp, $res);
|
|
$req = new Request("GET", "/?id=1827");
|
|
$res = $h->dispatch($req);
|
|
$this->assertEquals($exp, $res);
|
|
}
|
|
|
|
function testUseIncorrectMethod() {
|
|
$exp = new Response(405);
|
|
$h = new Rest\NextCloudNews\Versions();
|
|
$req = new Request("POST", "/");
|
|
$res = $h->dispatch($req);
|
|
$this->assertEquals($exp, $res);
|
|
}
|
|
|
|
function testUseIncorrectPath() {
|
|
$exp = new Response(404);
|
|
$h = new Rest\NextCloudNews\Versions();
|
|
$req = new Request("GET", "/ook");
|
|
$res = $h->dispatch($req);
|
|
$this->assertEquals($exp, $res);
|
|
}
|
|
} |