mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-01-16 21:58:21 +01:00
refactor: ./tests (#2649)
* refactor: ./tests * test: consolidate testsuites * refactor: move config setup into rssbridge.php Makes it easier to unit test. * lint
This commit is contained in:
parent
183004f954
commit
d62b977394
@ -1,11 +1,7 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/lib/rssbridge.php';
|
||||
|
||||
Configuration::verifyInstallation();
|
||||
Configuration::loadConfiguration();
|
||||
|
||||
Authentication::showPromptIfNeeded();
|
||||
|
||||
/*
|
||||
Move the CLI arguments to the $_GET array, in order to be able to use
|
||||
rss-bridge from the command line
|
||||
|
@ -87,3 +87,7 @@ define('MAX_FILE_SIZE', 10000000); /* Allow larger files for simple_html_dom */
|
||||
require_once PATH_LIB_VENDOR . 'parsedown/Parsedown.php';
|
||||
require_once PATH_LIB_VENDOR . 'php-urljoin/src/urljoin.php';
|
||||
require_once PATH_LIB_VENDOR . 'simplehtmldom/simple_html_dom.php';
|
||||
|
||||
Configuration::verifyInstallation();
|
||||
Configuration::loadConfiguration();
|
||||
Authentication::showPromptIfNeeded();
|
||||
|
11
phpunit.xml
11
phpunit.xml
@ -1,6 +1,7 @@
|
||||
<phpunit
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd"
|
||||
bootstrap="./lib/rssbridge.php"
|
||||
colors="true"
|
||||
processIsolation="false"
|
||||
timeoutForSmallTests="1"
|
||||
@ -8,14 +9,8 @@
|
||||
timeoutForLargeTests="6" >
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="implementations">
|
||||
<directory suffix="ImplementationTest.php">tests</directory>
|
||||
</testsuite>
|
||||
<testsuite name="formats">
|
||||
<directory suffix="FormatTest.php">tests</directory>
|
||||
</testsuite>
|
||||
<testsuite name="actions">
|
||||
<directory suffix="ActionTest.php">tests</directory>
|
||||
<testsuite name="rss-bridge">
|
||||
<directory>./tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../lib/rssbridge.php';
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@ -40,8 +39,6 @@ class ActionImplementationTest extends TestCase {
|
||||
$this->assertEquals($allowedActionAbstract, $methods);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public function dataActionsProvider() {
|
||||
$actions = array();
|
||||
foreach (glob(PATH_LIB_ACTIONS . '*.php') as $path) {
|
||||
|
@ -3,7 +3,6 @@
|
||||
* AtomFormat - RFC 4287: The Atom Syndication Format
|
||||
* https://tools.ietf.org/html/rfc4287
|
||||
*/
|
||||
require_once __DIR__ . '/../lib/rssbridge.php';
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@ -41,8 +40,6 @@ class AtomFormatTest extends TestCase {
|
||||
$this->assertXmlStringEqualsXmlFile($this->sample->expected, $this->data);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public function sampleProvider() {
|
||||
$samples = array();
|
||||
foreach (glob(self::PATH_SAMPLES . '*.json') as $path) {
|
||||
@ -84,7 +81,8 @@ class AtomFormatTest extends TestCase {
|
||||
$this->format->setExtraInfos($this->sample->meta);
|
||||
$this->format->setLastModified(strtotime('2000-01-01 12:00:00 UTC'));
|
||||
|
||||
$this->data = $this->getActualOutput($this->format->display());
|
||||
$_ = $this->format->display();
|
||||
$this->data = $this->getActualOutput();
|
||||
$this->assertNotFalse(simplexml_load_string($this->data));
|
||||
ob_clean();
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../lib/rssbridge.php';
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@ -52,7 +51,9 @@ class BridgeImplementationTest extends TestCase {
|
||||
$this->setBridge($path);
|
||||
|
||||
$multiMinimum = 2;
|
||||
if (isset($this->obj::PARAMETERS['global'])) ++$multiMinimum;
|
||||
if (isset($this->obj::PARAMETERS['global'])) {
|
||||
++$multiMinimum;
|
||||
}
|
||||
$multiContexts = (count($this->obj::PARAMETERS) >= $multiMinimum);
|
||||
$paramsSeen = array();
|
||||
|
||||
@ -202,8 +203,6 @@ class BridgeImplementationTest extends TestCase {
|
||||
$this->checkUrl($this->obj->getURI());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public function dataBridgesProvider() {
|
||||
$bridges = array();
|
||||
foreach (glob(PATH_LIB_BRIDGES . '*.php') as $path) {
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../lib/rssbridge.php';
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../lib/rssbridge.php';
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@ -25,8 +24,6 @@ class FormatImplementationTest extends TestCase {
|
||||
$this->assertInstanceOf(FormatInterface::class, $this->obj);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public function dataFormatsProvider() {
|
||||
$formats = array();
|
||||
foreach (glob(PATH_LIB_FORMATS . '*.php') as $path) {
|
||||
|
@ -41,8 +41,6 @@ class JsonFormatTest extends TestCase {
|
||||
$this->assertJsonStringEqualsJsonFile($this->sample->expected, $this->data);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public function sampleProvider() {
|
||||
$samples = array();
|
||||
foreach (glob(self::PATH_SAMPLES . '*.json') as $path) {
|
||||
@ -84,7 +82,8 @@ class JsonFormatTest extends TestCase {
|
||||
$this->format->setExtraInfos($this->sample->meta);
|
||||
$this->format->setLastModified(strtotime('2000-01-01 12:00:00 UTC'));
|
||||
|
||||
$this->data = $this->getActualOutput($this->format->display());
|
||||
$_ = $this->format->display();
|
||||
$this->data = $this->getActualOutput();
|
||||
$this->assertNotNull(json_decode($this->data), 'invalid JSON output: ' . json_last_error_msg());
|
||||
ob_clean();
|
||||
}
|
||||
|
@ -1,11 +1,9 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../lib/rssbridge.php';
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ListActionTest extends TestCase {
|
||||
|
||||
private $action;
|
||||
private $data;
|
||||
|
||||
/**
|
||||
@ -75,17 +73,15 @@ class ListActionTest extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private function initAction() {
|
||||
$actionFac = new ActionFactory();
|
||||
$actionFac->setWorkingDir(PATH_LIB_ACTIONS);
|
||||
|
||||
$this->action = $actionFac->create('list');
|
||||
$this->action->setUserData(array()); /* no user data required */
|
||||
$action = $actionFac->create('list');
|
||||
$action->setUserData(array()); /* no user data required */
|
||||
|
||||
ob_start();
|
||||
$this->action->execute();
|
||||
$action->execute();
|
||||
$this->data = ob_get_contents();
|
||||
ob_clean();
|
||||
ob_end_flush();
|
||||
|
@ -4,7 +4,6 @@
|
||||
* http://www.rssboard.org/rss-specification
|
||||
* http://www.rssboard.org/media-rss
|
||||
*/
|
||||
require_once __DIR__ . '/../lib/rssbridge.php';
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@ -42,8 +41,6 @@ class MrssFormatTest extends TestCase {
|
||||
$this->assertXmlStringEqualsXmlFile($this->sample->expected, $this->data);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public function sampleProvider() {
|
||||
$samples = array();
|
||||
foreach (glob(self::PATH_SAMPLES . '*.json') as $path) {
|
||||
@ -85,7 +82,8 @@ class MrssFormatTest extends TestCase {
|
||||
$this->format->setExtraInfos($this->sample->meta);
|
||||
$this->format->setLastModified(strtotime('2000-01-01 12:00:00 UTC'));
|
||||
|
||||
$this->data = $this->getActualOutput($this->format->display());
|
||||
$_ = $this->format->display();
|
||||
$this->data = $this->getActualOutput();
|
||||
$this->assertNotFalse(simplexml_load_string($this->data));
|
||||
ob_clean();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user