From 140d608f0f5d6a7fd9d550a8b30d4f986c56ca99 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Sat, 3 Jun 2017 09:06:30 -0400 Subject: [PATCH] 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. --- tests/Feed/TestFeed.php | 49 ----------------------- tests/Feed/TestFeedFetching.php | 70 +++++++++++++++++++++++++++++++++ tests/phpunit.xml | 1 + 3 files changed, 71 insertions(+), 49 deletions(-) create mode 100644 tests/Feed/TestFeedFetching.php diff --git a/tests/Feed/TestFeed.php b/tests/Feed/TestFeed.php index 133a0f6..9bb5e91 100644 --- a/tests/Feed/TestFeed.php +++ b/tests/Feed/TestFeed.php @@ -81,8 +81,6 @@ class TestFeed extends \PHPUnit\Framework\TestCase { function setUp() { if(!@file_get_contents(self::$host."IsUp")) { $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->clearData(); @@ -90,53 +88,6 @@ class TestFeed extends \PHPUnit\Framework\TestCase { 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() { // test that various properties are set on the feed and on items $f = new Feed(null, $this->base."Parsing/Valid"); diff --git a/tests/Feed/TestFeedFetching.php b/tests/Feed/TestFeedFetching.php new file mode 100644 index 0000000..8b038eb --- /dev/null +++ b/tests/Feed/TestFeedFetching.php @@ -0,0 +1,70 @@ +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/"); + } +} \ No newline at end of file diff --git a/tests/phpunit.xml b/tests/phpunit.xml index 35201e2..7366d9b 100644 --- a/tests/phpunit.xml +++ b/tests/phpunit.xml @@ -29,6 +29,7 @@ User/TestAuthorization.php + Feed/TestFeedFetching.php Feed/TestFeed.php