1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-23 17:12:41 +00:00
Arsse/tests/cases/REST/NextcloudNews/TestVersions.php

50 lines
1.7 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);
namespace JKingWeb\Arsse\TestCase\REST\NextcloudNews;
2017-08-29 14:50:31 +00:00
use JKingWeb\Arsse\REST\NextcloudNews\Versions;
use Psr\Http\Message\ResponseInterface;
use Laminas\Diactoros\Response\JsonResponse as Response;
use Laminas\Diactoros\Response\EmptyResponse;
/** @covers \JKingWeb\Arsse\REST\NextcloudNews\Versions */
2017-12-22 03:47:19 +00:00
class TestVersions extends \JKingWeb\Arsse\Test\AbstractTest {
2019-10-16 18:42:43 +00:00
public function setUp(): void {
2018-11-23 15:01:17 +00:00
self::clearData();
}
protected function req(string $method, string $target): ResponseInterface {
$prefix = "/index.php/apps/news/api";
$url = $prefix.$target;
$req = $this->serverRequest($method, $url, $prefix);
return (new Versions)->dispatch($req);
}
2020-01-20 18:52:48 +00:00
public function testFetchVersionList(): void {
$exp = new Response(['apiLevels' => ['v1-2']]);
$this->assertMessage($exp, $this->req("GET", "/"));
$this->assertMessage($exp, $this->req("GET", "/"));
$this->assertMessage($exp, $this->req("GET", "/"));
}
2020-01-20 18:52:48 +00:00
public function testRespondToOptionsRequest(): void {
$exp = new EmptyResponse(204, ['Allow' => "HEAD,GET"]);
$this->assertMessage($exp, $this->req("OPTIONS", "/"));
}
2020-01-20 18:52:48 +00:00
public function testUseIncorrectMethod(): void {
$exp = new EmptyResponse(405, ['Allow' => "HEAD,GET"]);
$this->assertMessage($exp, $this->req("POST", "/"));
}
2020-01-20 18:52:48 +00:00
public function testUseIncorrectPath(): void {
$exp = new EmptyResponse(404);
$this->assertMessage($exp, $this->req("GET", "/ook"));
$this->assertMessage($exp, $this->req("OPTIONS", "/ook"));
}
2017-08-29 14:50:31 +00:00
}