2017-03-19 21:50:00 -04:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
2017-03-27 23:12:12 -05:00
|
|
|
namespace JKingWeb\Arsse;
|
2017-05-21 19:51:03 -04:00
|
|
|
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;
|
|
|
|
|
2017-04-06 21:41:21 -04:00
|
|
|
function setUp() {
|
|
|
|
$this->clearData();
|
|
|
|
}
|
2017-03-19 21:50:00 -04:00
|
|
|
|
2017-04-06 21:41:21 -04:00
|
|
|
function testFetchVersionList() {
|
|
|
|
$exp = new Response(200, ['apiLevels' => ['v1-2']]);
|
2017-05-21 19:51:03 -04:00
|
|
|
$h = new REST\NextCloudNews\Versions();
|
2017-04-06 21:41:21 -04:00
|
|
|
$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 13:16:34 -04:00
|
|
|
|
2017-04-06 21:41:21 -04:00
|
|
|
function testUseIncorrectMethod() {
|
|
|
|
$exp = new Response(405);
|
2017-05-21 19:51:03 -04:00
|
|
|
$h = new REST\NextCloudNews\Versions();
|
2017-04-06 21:41:21 -04:00
|
|
|
$req = new Request("POST", "/");
|
|
|
|
$res = $h->dispatch($req);
|
|
|
|
$this->assertEquals($exp, $res);
|
|
|
|
}
|
2017-03-24 13:16:34 -04:00
|
|
|
|
2017-04-06 21:41:21 -04:00
|
|
|
function testUseIncorrectPath() {
|
2017-05-19 23:52:26 -04:00
|
|
|
$exp = new Response(501);
|
2017-05-21 19:51:03 -04:00
|
|
|
$h = new REST\NextCloudNews\Versions();
|
2017-04-06 21:41:21 -04:00
|
|
|
$req = new Request("GET", "/ook");
|
|
|
|
$res = $h->dispatch($req);
|
|
|
|
$this->assertEquals($exp, $res);
|
|
|
|
}
|
2017-03-19 21:50:00 -04:00
|
|
|
}
|