The clean & modern RSS server that doesn't give you any crap. https://thearsse.com/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
2.5 KiB

<?php
declare(strict_types=1);
namespace JKingWeb\NewsSync;
use \org\bovigo\vfs\vfsStream;
class TestConf extends \PHPUnit\Framework\TestCase {
use TestingHelpers;
static $vfs;
static $path;
static function setUpBeforeClass() {
self::$vfs = vfsStream::setup();
self::$path = self::$vfs->url();
foreach(["confUnreadable","confGood", "confCorrupt", "confNotArray"] as $file) {
touch(self::$path."/".$file);
}
chmod(self::$path."/confUnreadable", 0000);
$validConf = <<<'VALID_CONFIGURATION_FILE'
<?php
return Array(
"lang" => "xx"
);
VALID_CONFIGURATION_FILE;
file_put_contents(self::$path."/confGood",$validConf);
file_put_contents(self::$path."/confNotArray", '<?php return 0;');
file_put_contents(self::$path."/confCorrupt", '<?php return 0');
file_put_contents(self::$path."/confNotPHP", 'DEAD BEEF');
}
static function tearDownAfterClass() {
self::$path = null;
self::$vfs = null;
}
function testConstructor() {
$this->assertInstanceOf(Conf::class, new Conf());
}
/**
* @depends testConstructor
*/
function testImportArray() {
$arr = ['lang' => "xx"];
$conf = new Conf();
$conf->import($arr);
$this->assertEquals("xx", $conf->lang);
}
/**
* @depends testImportArray
*/
function testImportFile() {
$conf = new Conf();
$conf->importFile(self::$path."/confGood");
$this->assertEquals("xx", $conf->lang);
$conf = new Conf(self::$path."/confGood");
$this->assertEquals("xx", $conf->lang);
}
/**
* @depends testImportFile
*/
function testImportFileMissing() {
$this->assertException("fileMissing", "Conf");
$conf = new Conf(self::$path."/confMissing");
}
/**
* @depends testImportFile
*/
function testImportFileUnreadable() {
$this->assertException("fileUnreadable", "Conf");
$conf = new Conf(self::$path."/confUnreadable");
}
/**
* @depends testImportFile
*/
function testImportFileNotAnArray() {
$this->assertException("fileCorrupt", "Conf");
$conf = new Conf(self::$path."/confNotArray");
}
/**
* @depends testImportFile
*/
function testImportFileNotPHP() {
$this->assertException("fileCorrupt", "Conf");
// this should not print the output of the non-PHP file
$conf = new Conf(self::$path."/confNotPHP");
}
/**
* @depends testImportFile
*/
function testImportFileCorrupt() {
$this->assertException("fileCorrupt", "Conf");
// this should not print the output of the non-PHP file
$conf = new Conf(self::$path."/confCorrupt");
}
}