2017-03-20 01:50:00 +00:00
|
|
|
<?php
|
2017-11-17 01:23:18 +00:00
|
|
|
/** @license MIT
|
|
|
|
* Copyright 2017 J. King, Dustin Wilson et al.
|
|
|
|
* See LICENSE and AUTHORS files for details */
|
|
|
|
|
2017-03-20 01:50:00 +00:00
|
|
|
declare(strict_types=1);
|
2017-12-22 16:41:54 +00:00
|
|
|
namespace JKingWeb\Arsse\TestCase\REST\NextCloudNews;
|
2017-08-29 14:50:31 +00:00
|
|
|
|
2017-12-22 16:41:54 +00:00
|
|
|
use JKingWeb\Arsse\REST\NextCloudNews\Versions;
|
2017-05-21 23:51:03 +00:00
|
|
|
use JKingWeb\Arsse\REST\Request;
|
|
|
|
use JKingWeb\Arsse\REST\Response;
|
2017-03-20 01:50:00 +00:00
|
|
|
|
2017-07-20 22:36:03 +00:00
|
|
|
/** @covers \JKingWeb\Arsse\REST\NextCloudNews\Versions */
|
2017-12-22 16:41:54 +00:00
|
|
|
class TestVersions extends \JKingWeb\Arsse\Test\AbstractTest {
|
2017-08-29 14:50:31 +00:00
|
|
|
public function setUp() {
|
2017-04-07 01:41:21 +00:00
|
|
|
$this->clearData();
|
|
|
|
}
|
2017-03-20 01:50:00 +00:00
|
|
|
|
2017-08-29 14:50:31 +00:00
|
|
|
public function testFetchVersionList() {
|
2017-04-07 01:41:21 +00:00
|
|
|
$exp = new Response(200, ['apiLevels' => ['v1-2']]);
|
2017-12-22 16:41:54 +00:00
|
|
|
$h = new Versions;
|
2017-04-07 01:41:21 +00: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 17:16:34 +00:00
|
|
|
|
2017-11-29 20:28:33 +00:00
|
|
|
public function testRespondToOptionsRequest() {
|
|
|
|
$exp = new Response(204, "", "", ["Allow: HEAD,GET"]);
|
2017-12-22 16:41:54 +00:00
|
|
|
$h = new Versions;
|
2017-11-29 20:28:33 +00:00
|
|
|
$req = new Request("OPTIONS", "/");
|
|
|
|
$res = $h->dispatch($req);
|
|
|
|
$this->assertEquals($exp, $res);
|
|
|
|
}
|
|
|
|
|
2017-08-29 14:50:31 +00:00
|
|
|
public function testUseIncorrectMethod() {
|
2017-11-29 20:28:33 +00:00
|
|
|
$exp = new Response(405, "", "", ["Allow: HEAD,GET"]);
|
2017-12-22 16:41:54 +00:00
|
|
|
$h = new Versions;
|
2017-04-07 01:41:21 +00:00
|
|
|
$req = new Request("POST", "/");
|
|
|
|
$res = $h->dispatch($req);
|
|
|
|
$this->assertEquals($exp, $res);
|
|
|
|
}
|
2017-03-24 17:16:34 +00:00
|
|
|
|
2017-08-29 14:50:31 +00:00
|
|
|
public function testUseIncorrectPath() {
|
2017-11-29 18:41:26 +00:00
|
|
|
$exp = new Response(404);
|
2017-12-22 16:41:54 +00:00
|
|
|
$h = new Versions;
|
2017-04-07 01:41:21 +00:00
|
|
|
$req = new Request("GET", "/ook");
|
|
|
|
$res = $h->dispatch($req);
|
|
|
|
$this->assertEquals($exp, $res);
|
2017-11-29 20:28:33 +00:00
|
|
|
$req = new Request("OPTIONS", "/ook");
|
|
|
|
$res = $h->dispatch($req);
|
|
|
|
$this->assertEquals($exp, $res);
|
2017-04-07 01:41:21 +00:00
|
|
|
}
|
2017-08-29 14:50:31 +00:00
|
|
|
}
|