mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2025-01-03 14:32:40 +00:00
Split feed fetching tests from feed parsing tests
Lack of curl should not skip all Feed tests, just those that require curl to be reliable.
This commit is contained in:
parent
c6b7e653c5
commit
140d608f0f
3 changed files with 71 additions and 49 deletions
|
@ -81,8 +81,6 @@ class TestFeed extends \PHPUnit\Framework\TestCase {
|
||||||
function setUp() {
|
function setUp() {
|
||||||
if(!@file_get_contents(self::$host."IsUp")) {
|
if(!@file_get_contents(self::$host."IsUp")) {
|
||||||
$this->markTestSkipped("Test Web server is not accepting requests");
|
$this->markTestSkipped("Test Web server is not accepting requests");
|
||||||
} else if(!extension_loaded('curl')) {
|
|
||||||
$this->markTestSkipped("Feed tests are only accurate with curl enabled.");
|
|
||||||
}
|
}
|
||||||
$this->base = self::$host."Feed/";
|
$this->base = self::$host."Feed/";
|
||||||
$this->clearData();
|
$this->clearData();
|
||||||
|
@ -90,53 +88,6 @@ class TestFeed extends \PHPUnit\Framework\TestCase {
|
||||||
Data::$db = Phake::mock(Database::class);
|
Data::$db = Phake::mock(Database::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testHandle400() {
|
|
||||||
$this->assertException("unsupportedFeedFormat", "Feed");
|
|
||||||
new Feed(null, $this->base."Fetching/Error?code=400");
|
|
||||||
}
|
|
||||||
|
|
||||||
function testHandle401() {
|
|
||||||
$this->assertException("unauthorized", "Feed");
|
|
||||||
new Feed(null, $this->base."Fetching/Error?code=401");
|
|
||||||
}
|
|
||||||
|
|
||||||
function testHandle403() {
|
|
||||||
$this->assertException("forbidden", "Feed");
|
|
||||||
new Feed(null, $this->base."Fetching/Error?code=403");
|
|
||||||
}
|
|
||||||
|
|
||||||
function testHandle404() {
|
|
||||||
$this->assertException("invalidUrl", "Feed");
|
|
||||||
new Feed(null, $this->base."Fetching/Error?code=404");
|
|
||||||
}
|
|
||||||
|
|
||||||
function testHandle500() {
|
|
||||||
$this->assertException("unsupportedFeedFormat", "Feed");
|
|
||||||
new Feed(null, $this->base."Fetching/Error?code=500");
|
|
||||||
}
|
|
||||||
|
|
||||||
function testHandleARedirectLoop() {
|
|
||||||
$this->assertException("maxRedirect", "Feed");
|
|
||||||
new Feed(null, $this->base."Fetching/EndlessLoop?i=0");
|
|
||||||
}
|
|
||||||
|
|
||||||
function testHandleATimeout() {
|
|
||||||
Data::$conf->fetchTimeout = 1;
|
|
||||||
$this->assertException("timeout", "Feed");
|
|
||||||
new Feed(null, $this->base."Fetching/Timeout");
|
|
||||||
}
|
|
||||||
|
|
||||||
function testHandleAnOverlyLargeFeed() {
|
|
||||||
Data::$conf->fetchSizeLimit = 512;
|
|
||||||
$this->assertException("maxSize", "Feed");
|
|
||||||
new Feed(null, $this->base."Fetching/TooLarge");
|
|
||||||
}
|
|
||||||
|
|
||||||
function testHandleACertificateError() {
|
|
||||||
$this->assertException("invalidCertificate", "Feed");
|
|
||||||
new Feed(null, "https://localhost:8000/");
|
|
||||||
}
|
|
||||||
|
|
||||||
function testParseAFeed() {
|
function testParseAFeed() {
|
||||||
// test that various properties are set on the feed and on items
|
// test that various properties are set on the feed and on items
|
||||||
$f = new Feed(null, $this->base."Parsing/Valid");
|
$f = new Feed(null, $this->base."Parsing/Valid");
|
||||||
|
|
70
tests/Feed/TestFeedFetching.php
Normal file
70
tests/Feed/TestFeedFetching.php
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
namespace JKingWeb\Arsse;
|
||||||
|
Use Phake;
|
||||||
|
|
||||||
|
|
||||||
|
class TestFeedFetching extends \PHPUnit\Framework\TestCase {
|
||||||
|
use Test\Tools;
|
||||||
|
|
||||||
|
protected static $host = "http://localhost:8000/";
|
||||||
|
protected $base = "";
|
||||||
|
|
||||||
|
function setUp() {
|
||||||
|
if(!extension_loaded('curl')) {
|
||||||
|
$this->markTestSkipped("Feed fetching tests are only accurate with curl enabled.");
|
||||||
|
} else if(!@file_get_contents(self::$host."IsUp")) {
|
||||||
|
$this->markTestSkipped("Test Web server is not accepting requests");
|
||||||
|
}
|
||||||
|
$this->base = self::$host."Feed/";
|
||||||
|
$this->clearData();
|
||||||
|
Data::$conf = new Conf();
|
||||||
|
}
|
||||||
|
|
||||||
|
function testHandle400() {
|
||||||
|
$this->assertException("unsupportedFeedFormat", "Feed");
|
||||||
|
new Feed(null, $this->base."Fetching/Error?code=400");
|
||||||
|
}
|
||||||
|
|
||||||
|
function testHandle401() {
|
||||||
|
$this->assertException("unauthorized", "Feed");
|
||||||
|
new Feed(null, $this->base."Fetching/Error?code=401");
|
||||||
|
}
|
||||||
|
|
||||||
|
function testHandle403() {
|
||||||
|
$this->assertException("forbidden", "Feed");
|
||||||
|
new Feed(null, $this->base."Fetching/Error?code=403");
|
||||||
|
}
|
||||||
|
|
||||||
|
function testHandle404() {
|
||||||
|
$this->assertException("invalidUrl", "Feed");
|
||||||
|
new Feed(null, $this->base."Fetching/Error?code=404");
|
||||||
|
}
|
||||||
|
|
||||||
|
function testHandle500() {
|
||||||
|
$this->assertException("unsupportedFeedFormat", "Feed");
|
||||||
|
new Feed(null, $this->base."Fetching/Error?code=500");
|
||||||
|
}
|
||||||
|
|
||||||
|
function testHandleARedirectLoop() {
|
||||||
|
$this->assertException("maxRedirect", "Feed");
|
||||||
|
new Feed(null, $this->base."Fetching/EndlessLoop?i=0");
|
||||||
|
}
|
||||||
|
|
||||||
|
function testHandleATimeout() {
|
||||||
|
Data::$conf->fetchTimeout = 1;
|
||||||
|
$this->assertException("timeout", "Feed");
|
||||||
|
new Feed(null, $this->base."Fetching/Timeout");
|
||||||
|
}
|
||||||
|
|
||||||
|
function testHandleAnOverlyLargeFeed() {
|
||||||
|
Data::$conf->fetchSizeLimit = 512;
|
||||||
|
$this->assertException("maxSize", "Feed");
|
||||||
|
new Feed(null, $this->base."Fetching/TooLarge");
|
||||||
|
}
|
||||||
|
|
||||||
|
function testHandleACertificateError() {
|
||||||
|
$this->assertException("invalidCertificate", "Feed");
|
||||||
|
new Feed(null, "https://localhost:8000/");
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,6 +29,7 @@
|
||||||
<file>User/TestAuthorization.php</file>
|
<file>User/TestAuthorization.php</file>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
<testsuite name="Feed parser">
|
<testsuite name="Feed parser">
|
||||||
|
<file>Feed/TestFeedFetching.php</file>
|
||||||
<file>Feed/TestFeed.php</file>
|
<file>Feed/TestFeed.php</file>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
<testsuite name="Database drivers">
|
<testsuite name="Database drivers">
|
||||||
|
|
Loading…
Reference in a new issue