1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-23 09:02:41 +00:00
Arsse/tests/REST/NextCloudNews/TestNCNVersionDiscovery.php
J. King 8b50297e6d Complete tests for NCN version list
- Fixes #47
- Implemented an AbstractHandler class with a generic URL parser
2017-03-24 13:16:34 -04:00

45 lines
No EOL
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace JKingWeb\NewsSync;
use JKingWeb\NewsSync\Rest\Request;
use JKingWeb\NewsSync\Rest\Response;
class TestNCNVersionDiscovery extends \PHPUnit\Framework\TestCase {
use Test\Tools;
function setUp() {
$conf = new Conf();
$this->data = new Test\RuntimeData($conf);
}
function testFetchVersionList() {
$exp = new Response(200, ['apiLevels' => ['v1-2']]);
$h = new Rest\NextCloudNews\Versions($this->data);
$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($this->data);
$req = new Request("POST", "/");
$res = $h->dispatch($req);
$this->assertEquals($exp, $res);
}
function testUseIncorrectPath() {
$exp = new Response(404);
$h = new Rest\NextCloudNews\Versions($this->data);
$req = new Request("GET", "/ook");
$res = $h->dispatch($req);
$this->assertEquals($exp, $res);
}
}