2017-06-03 09:06:30 -04:00
|
|
|
<?php
|
2024-12-27 20:28:38 -05:00
|
|
|
|
2017-11-16 20:23:18 -05:00
|
|
|
/** @license MIT
|
|
|
|
* Copyright 2017 J. King, Dustin Wilson et al.
|
|
|
|
* See LICENSE and AUTHORS files for details */
|
|
|
|
|
2017-06-03 09:06:30 -04:00
|
|
|
declare(strict_types=1);
|
2021-04-14 11:17:01 -04:00
|
|
|
|
2017-12-21 22:47:19 -05:00
|
|
|
namespace JKingWeb\Arsse\TestCase\Feed;
|
2017-06-03 09:06:30 -04:00
|
|
|
|
2017-12-21 22:47:19 -05:00
|
|
|
use JKingWeb\Arsse\Arsse;
|
|
|
|
use JKingWeb\Arsse\Feed;
|
2024-12-27 20:28:38 -05:00
|
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
|
|
use PHPUnit\Framework\Attributes\Group;
|
2017-06-03 09:06:30 -04:00
|
|
|
|
2024-12-27 20:28:38 -05:00
|
|
|
#[CoversClass(\JKingWeb\Arsse\Feed::class)]
|
|
|
|
#[Group('slow')]
|
2017-12-21 22:47:19 -05:00
|
|
|
class TestFetching extends \JKingWeb\Arsse\Test\AbstractTest {
|
2017-06-03 09:06:30 -04:00
|
|
|
protected static $host = "http://localhost:8000/";
|
|
|
|
protected $base = "";
|
|
|
|
|
2019-10-16 14:42:43 -04:00
|
|
|
public function setUp(): void {
|
2017-08-29 10:50:31 -04:00
|
|
|
if (!extension_loaded('curl')) {
|
2017-06-03 09:06:30 -04:00
|
|
|
$this->markTestSkipped("Feed fetching tests are only accurate with curl enabled.");
|
2017-08-29 10:50:31 -04:00
|
|
|
} elseif (!@file_get_contents(self::$host."IsUp")) {
|
2017-06-03 09:06:30 -04:00
|
|
|
$this->markTestSkipped("Test Web server is not accepting requests");
|
|
|
|
}
|
|
|
|
$this->base = self::$host."Feed/";
|
2021-02-27 15:24:02 -05:00
|
|
|
parent::setUp();
|
2018-11-22 19:55:54 -05:00
|
|
|
self::setConf();
|
2017-06-03 09:06:30 -04:00
|
|
|
}
|
|
|
|
|
2020-01-20 13:52:48 -05:00
|
|
|
public function testHandle400(): void {
|
2020-01-21 08:42:38 -05:00
|
|
|
$this->assertException("transmissionError", "Feed");
|
2017-06-03 09:06:30 -04:00
|
|
|
new Feed(null, $this->base."Fetching/Error?code=400");
|
|
|
|
}
|
|
|
|
|
2020-01-20 13:52:48 -05:00
|
|
|
public function testHandle401(): void {
|
2017-06-03 09:06:30 -04:00
|
|
|
$this->assertException("unauthorized", "Feed");
|
|
|
|
new Feed(null, $this->base."Fetching/Error?code=401");
|
|
|
|
}
|
|
|
|
|
2020-01-20 13:52:48 -05:00
|
|
|
public function testHandle403(): void {
|
2017-06-03 09:06:30 -04:00
|
|
|
$this->assertException("forbidden", "Feed");
|
|
|
|
new Feed(null, $this->base."Fetching/Error?code=403");
|
|
|
|
}
|
|
|
|
|
2020-01-20 13:52:48 -05:00
|
|
|
public function testHandle404(): void {
|
2017-06-03 09:06:30 -04:00
|
|
|
$this->assertException("invalidUrl", "Feed");
|
|
|
|
new Feed(null, $this->base."Fetching/Error?code=404");
|
|
|
|
}
|
|
|
|
|
2020-01-20 13:52:48 -05:00
|
|
|
public function testHandle500(): void {
|
2020-01-21 08:42:38 -05:00
|
|
|
$this->assertException("transmissionError", "Feed");
|
2017-06-03 09:06:30 -04:00
|
|
|
new Feed(null, $this->base."Fetching/Error?code=500");
|
|
|
|
}
|
|
|
|
|
2020-01-20 13:52:48 -05:00
|
|
|
public function testHandleARedirectLoop(): void {
|
2020-01-23 17:07:20 -05:00
|
|
|
$this->assertException("maxRedirect", "Feed");
|
2017-06-03 09:06:30 -04:00
|
|
|
new Feed(null, $this->base."Fetching/EndlessLoop?i=0");
|
|
|
|
}
|
|
|
|
|
2020-01-20 13:52:48 -05:00
|
|
|
public function testHandleAnOverlyLargeFeed(): void {
|
2020-01-24 15:54:08 -05:00
|
|
|
$this->markTestIncomplete("The nicolus/picofeed library does not implement miniflux/picofeed's max-size setting");
|
2017-07-17 07:47:57 -04:00
|
|
|
Arsse::$conf->fetchSizeLimit = 512;
|
2017-06-03 09:06:30 -04:00
|
|
|
$this->assertException("maxSize", "Feed");
|
|
|
|
new Feed(null, $this->base."Fetching/TooLarge");
|
|
|
|
}
|
|
|
|
|
2020-01-20 13:52:48 -05:00
|
|
|
public function testHandleACertificateError(): void {
|
2017-06-03 09:06:30 -04:00
|
|
|
$this->assertException("invalidCertificate", "Feed");
|
|
|
|
new Feed(null, "https://localhost:8000/");
|
|
|
|
}
|
2017-12-16 17:21:23 -05:00
|
|
|
|
2020-01-20 13:52:48 -05:00
|
|
|
public function testHandleATimeout(): void {
|
2017-12-16 17:21:23 -05:00
|
|
|
Arsse::$conf->fetchTimeout = 1;
|
|
|
|
$this->assertException("timeout", "Feed");
|
|
|
|
new Feed(null, $this->base."Fetching/Timeout");
|
|
|
|
}
|
2017-08-29 10:50:31 -04:00
|
|
|
}
|