1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-23 09:02:41 +00:00
Arsse/tests/cases/Feed/TestFeedFetching.php

76 lines
2.3 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;
2017-08-29 14:50:31 +00:00
use Phake;
2017-12-17 01:03:04 +00:00
/**
* @covers \JKingWeb\Arsse\Feed
* @group slow */
class TestFeedFetching extends Test\AbstractTest {
protected static $host = "http://localhost:8000/";
protected $base = "";
2017-08-29 14:50:31 +00:00
public function setUp() {
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/";
$this->clearData();
Arsse::$conf = new Conf();
}
2017-08-29 14:50:31 +00:00
public function testHandle400() {
$this->assertException("unsupportedFeedFormat", "Feed");
new Feed(null, $this->base."Fetching/Error?code=400");
}
2017-08-29 14:50:31 +00:00
public function testHandle401() {
$this->assertException("unauthorized", "Feed");
new Feed(null, $this->base."Fetching/Error?code=401");
}
2017-08-29 14:50:31 +00:00
public function testHandle403() {
$this->assertException("forbidden", "Feed");
new Feed(null, $this->base."Fetching/Error?code=403");
}
2017-08-29 14:50:31 +00:00
public function testHandle404() {
$this->assertException("invalidUrl", "Feed");
new Feed(null, $this->base."Fetching/Error?code=404");
}
2017-08-29 14:50:31 +00:00
public function testHandle500() {
$this->assertException("unsupportedFeedFormat", "Feed");
new Feed(null, $this->base."Fetching/Error?code=500");
}
2017-08-29 14:50:31 +00:00
public function testHandleARedirectLoop() {
$this->assertException("maxRedirect", "Feed");
new Feed(null, $this->base."Fetching/EndlessLoop?i=0");
}
2017-08-29 14:50:31 +00:00
public function testHandleAnOverlyLargeFeed() {
Arsse::$conf->fetchSizeLimit = 512;
$this->assertException("maxSize", "Feed");
new Feed(null, $this->base."Fetching/TooLarge");
}
2017-08-29 14:50:31 +00:00
public function testHandleACertificateError() {
$this->assertException("invalidCertificate", "Feed");
new Feed(null, "https://localhost:8000/");
}
2017-12-16 22:21:23 +00:00
public function testHandleATimeout() {
Arsse::$conf->fetchTimeout = 1;
$this->assertException("timeout", "Feed");
new Feed(null, $this->base."Fetching/Timeout");
}
2017-08-29 14:50:31 +00:00
}