1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2025-01-10 18:02:40 +00:00
Arsse/tests/cases/REST/NextCloudNews/TestVersions.php

61 lines
1.9 KiB
PHP
Raw Normal View History

<?php
/** @license MIT
* Copyright 2017 J. King, Dustin Wilson et al.
* See LICENSE and AUTHORS files for details */
declare(strict_types=1);
2017-12-22 03:47:19 +00:00
namespace JKingWeb\Arsse\TestCase\REST\NextCloudNews;
2017-08-29 14:50:31 +00:00
2017-12-22 03:47:19 +00:00
use JKingWeb\Arsse\REST\NextCloudNews\Versions;
use JKingWeb\Arsse\REST\Request;
use Zend\Diactoros\Response\JsonResponse as Response;
use Zend\Diactoros\Response\EmptyResponse;
2017-07-20 22:36:03 +00:00
/** @covers \JKingWeb\Arsse\REST\NextCloudNews\Versions */
2017-12-22 03:47:19 +00:00
class TestVersions extends \JKingWeb\Arsse\Test\AbstractTest {
2017-08-29 14:50:31 +00:00
public function setUp() {
$this->clearData();
}
2017-08-29 14:50:31 +00:00
public function testFetchVersionList() {
$exp = new Response(['apiLevels' => ['v1-2']]);
2017-12-22 03:47:19 +00:00
$h = new Versions;
$req = new Request("GET", "/");
$res = $h->dispatch($req);
$this->assertResponse($exp, $res);
$req = new Request("GET", "");
$res = $h->dispatch($req);
$this->assertResponse($exp, $res);
$req = new Request("GET", "/?id=1827");
$res = $h->dispatch($req);
$this->assertResponse($exp, $res);
}
public function testRespondToOptionsRequest() {
$exp = new EmptyResponse(204, ['Allow' => "HEAD,GET"]);
2017-12-22 03:47:19 +00:00
$h = new Versions;
$req = new Request("OPTIONS", "/");
$res = $h->dispatch($req);
$this->assertResponse($exp, $res);
}
2017-08-29 14:50:31 +00:00
public function testUseIncorrectMethod() {
$exp = new EmptyResponse(405, ['Allow' => "HEAD,GET"]);
2017-12-22 03:47:19 +00:00
$h = new Versions;
$req = new Request("POST", "/");
$res = $h->dispatch($req);
$this->assertResponse($exp, $res);
}
2017-08-29 14:50:31 +00:00
public function testUseIncorrectPath() {
$exp = new EmptyResponse(404);
2017-12-22 03:47:19 +00:00
$h = new Versions;
$req = new Request("GET", "/ook");
$res = $h->dispatch($req);
$this->assertResponse($exp, $res);
$req = new Request("OPTIONS", "/ook");
$res = $h->dispatch($req);
$this->assertResponse($exp, $res);
}
2017-08-29 14:50:31 +00:00
}