2017-03-19 21:50:00 -04:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
2017-03-27 23:12:12 -05:00
|
|
|
namespace JKingWeb\Arsse;
|
|
|
|
use JKingWeb\Arsse\Rest\Request;
|
|
|
|
use JKingWeb\Arsse\Rest\Response;
|
2017-03-19 21:50:00 -04:00
|
|
|
|
|
|
|
|
|
|
|
class TestNCNVersionDiscovery extends \PHPUnit\Framework\TestCase {
|
|
|
|
use Test\Tools;
|
|
|
|
|
|
|
|
function setUp() {
|
2017-03-28 18:50:00 -04:00
|
|
|
$this->clearData();
|
2017-03-19 21:50:00 -04:00
|
|
|
}
|
|
|
|
|
2017-03-24 13:16:34 -04:00
|
|
|
function testFetchVersionList() {
|
2017-03-19 21:54:28 -04:00
|
|
|
$exp = new Response(200, ['apiLevels' => ['v1-2']]);
|
2017-03-28 18:50:00 -04:00
|
|
|
$h = new Rest\NextCloudNews\Versions();
|
2017-03-19 21:50:00 -04:00
|
|
|
$req = new Request("GET", "/");
|
2017-03-24 13:16:34 -04:00
|
|
|
$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);
|
2017-03-28 18:50:00 -04:00
|
|
|
$h = new Rest\NextCloudNews\Versions();
|
2017-03-24 13:16:34 -04:00
|
|
|
$req = new Request("POST", "/");
|
|
|
|
$res = $h->dispatch($req);
|
|
|
|
$this->assertEquals($exp, $res);
|
|
|
|
}
|
|
|
|
|
|
|
|
function testUseIncorrectPath() {
|
|
|
|
$exp = new Response(404);
|
2017-03-28 18:50:00 -04:00
|
|
|
$h = new Rest\NextCloudNews\Versions();
|
2017-03-24 13:16:34 -04:00
|
|
|
$req = new Request("GET", "/ook");
|
2017-03-19 21:50:00 -04:00
|
|
|
$res = $h->dispatch($req);
|
|
|
|
$this->assertEquals($exp, $res);
|
|
|
|
}
|
|
|
|
}
|