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/Feed/TestFetching.php

78 lines
2.6 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\Feed;
2017-12-22 03:47:19 +00:00
use JKingWeb\Arsse\Arsse;
use JKingWeb\Arsse\Feed;
2017-12-20 03:19:42 +00:00
/**
* @covers \JKingWeb\Arsse\Feed
2017-12-17 01:03:04 +00:00
* @group slow */
2017-12-22 03:47:19 +00:00
class TestFetching extends \JKingWeb\Arsse\Test\AbstractTest {
protected static $host = "http://localhost:8000/";
protected $base = "";
2019-10-16 18:42:43 +00:00
public function setUp(): void {
2017-08-29 14:50:31 +00:00
if (!extension_loaded('curl')) {
$this->markTestSkipped("Feed fetching tests are only accurate with curl enabled.");
2017-08-29 14:50:31 +00:00
} elseif (!@file_get_contents(self::$host."IsUp")) {
$this->markTestSkipped("Test Web server is not accepting requests");
}
$this->base = self::$host."Feed/";
2021-02-27 20:24:02 +00:00
parent::setUp();
2018-11-23 00:55:54 +00:00
self::setConf();
}
2020-01-20 18:52:48 +00:00
public function testHandle400(): void {
$this->assertException("transmissionError", "Feed");
new Feed(null, $this->base."Fetching/Error?code=400");
}
2020-01-20 18:52:48 +00:00
public function testHandle401(): void {
$this->assertException("unauthorized", "Feed");
new Feed(null, $this->base."Fetching/Error?code=401");
}
2020-01-20 18:52:48 +00:00
public function testHandle403(): void {
$this->assertException("forbidden", "Feed");
new Feed(null, $this->base."Fetching/Error?code=403");
}
2020-01-20 18:52:48 +00:00
public function testHandle404(): void {
$this->assertException("invalidUrl", "Feed");
new Feed(null, $this->base."Fetching/Error?code=404");
}
2020-01-20 18:52:48 +00:00
public function testHandle500(): void {
$this->assertException("transmissionError", "Feed");
new Feed(null, $this->base."Fetching/Error?code=500");
}
2020-01-20 18:52:48 +00:00
public function testHandleARedirectLoop(): void {
$this->assertException("maxRedirect", "Feed");
new Feed(null, $this->base."Fetching/EndlessLoop?i=0");
}
2020-01-20 18:52:48 +00:00
public function testHandleAnOverlyLargeFeed(): void {
$this->markTestIncomplete("The nicolus/picofeed library does not implement miniflux/picofeed's max-size setting");
Arsse::$conf->fetchSizeLimit = 512;
$this->assertException("maxSize", "Feed");
new Feed(null, $this->base."Fetching/TooLarge");
}
2020-01-20 18:52:48 +00:00
public function testHandleACertificateError(): void {
$this->assertException("invalidCertificate", "Feed");
new Feed(null, "https://localhost:8000/");
}
2017-12-16 22:21:23 +00:00
2020-01-20 18:52:48 +00:00
public function testHandleATimeout(): void {
2017-12-16 22:21:23 +00:00
Arsse::$conf->fetchTimeout = 1;
$this->assertException("timeout", "Feed");
new Feed(null, $this->base."Fetching/Timeout");
}
2017-08-29 14:50:31 +00:00
}