2017-03-20 01:50:00 +00:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
2017-03-28 04:12:12 +00:00
|
|
|
namespace JKingWeb\Arsse;
|
|
|
|
use JKingWeb\Arsse\Rest\Request;
|
|
|
|
use JKingWeb\Arsse\Rest\Response;
|
2017-03-20 01:50:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestNCNVersionDiscovery extends \PHPUnit\Framework\TestCase {
|
|
|
|
use Test\Tools;
|
|
|
|
|
2017-04-07 01:41:21 +00:00
|
|
|
function setUp() {
|
|
|
|
$this->clearData();
|
|
|
|
}
|
2017-03-20 01:50:00 +00:00
|
|
|
|
2017-04-07 01:41:21 +00:00
|
|
|
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);
|
|
|
|
}
|
2017-03-24 17:16:34 +00:00
|
|
|
|
2017-04-07 01:41:21 +00:00
|
|
|
function testUseIncorrectMethod() {
|
|
|
|
$exp = new Response(405);
|
|
|
|
$h = new Rest\NextCloudNews\Versions();
|
|
|
|
$req = new Request("POST", "/");
|
|
|
|
$res = $h->dispatch($req);
|
|
|
|
$this->assertEquals($exp, $res);
|
|
|
|
}
|
2017-03-24 17:16:34 +00:00
|
|
|
|
2017-04-07 01:41:21 +00:00
|
|
|
function testUseIncorrectPath() {
|
|
|
|
$exp = new Response(404);
|
|
|
|
$h = new Rest\NextCloudNews\Versions();
|
|
|
|
$req = new Request("GET", "/ook");
|
|
|
|
$res = $h->dispatch($req);
|
|
|
|
$this->assertEquals($exp, $res);
|
|
|
|
}
|
2017-03-20 01:50:00 +00:00
|
|
|
}
|