mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 13:12:41 +00:00
Clean up tests a little
This commit is contained in:
parent
bc6ee434e5
commit
3a9753fd22
2 changed files with 36 additions and 32 deletions
|
@ -11,22 +11,17 @@ class TestConf extends \PHPUnit\Framework\TestCase {
|
|||
static $path;
|
||||
|
||||
static function setUpBeforeClass() {
|
||||
self::$vfs = vfsStream::setup();
|
||||
self::$vfs = vfsStream::setup("root", null, [
|
||||
'confGood' => '<?php return Array("lang" => "xx");',
|
||||
'confNotArray' => '<?php return 0;',
|
||||
'confCorrupt' => '<?php return 0',
|
||||
'confNotPHP' => 'DEAD BEEF',
|
||||
'confEmpty' => '',
|
||||
'confUnreadable' => '',
|
||||
]);
|
||||
self::$path = self::$vfs->url();
|
||||
foreach(["confUnreadable","confGood", "confCorrupt", "confNotArray"] as $file) {
|
||||
touch(self::$path."/".$file);
|
||||
}
|
||||
// set up a file without read access
|
||||
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() {
|
||||
|
@ -69,6 +64,14 @@ VALID_CONFIGURATION_FILE;
|
|||
|
||||
/**
|
||||
* @depends testImportFile
|
||||
*/
|
||||
function testImportFileEmpty() {
|
||||
$this->assertException("fileCorrupt", "Conf");
|
||||
$conf = new Conf(self::$path."/confEmpty");
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testImportFile
|
||||
*/
|
||||
function testImportFileUnreadable() {
|
||||
$this->assertException("fileUnreadable", "Conf");
|
||||
|
|
|
@ -9,26 +9,26 @@ class TestLang extends \PHPUnit\Framework\TestCase {
|
|||
|
||||
static $vfs;
|
||||
static $path;
|
||||
|
||||
const FILES = [
|
||||
'en.php' => '<?php return ["Test.presentText" => "and the Philosopher\'s Stone"];',
|
||||
'en-ca.php' => '<?php return [];',
|
||||
'en-us.php' => '<?php return ["Test.presentText" => "and the Sorcerer\'s Stone"];',
|
||||
'fr.php' => '<?php return ["Test.presentText" => "à l\'école des sorciers"];',
|
||||
'ja.php' => '<?php return ["Test.absentText" => "賢者の石"];',
|
||||
// corrupt files
|
||||
'it.php' => '<?php return 0;',
|
||||
'zh.php' => '<?php return 0',
|
||||
'ko.php' => 'DEAD BEEF',
|
||||
// empty file
|
||||
'fr-ca.php' => '',
|
||||
// unreadable file
|
||||
'ru.php' => '',
|
||||
];
|
||||
static $files;
|
||||
|
||||
static function setUpBeforeClass() {
|
||||
Lang\Exception::$test = true;
|
||||
self::$vfs = vfsStream::setup("langtest", 0777, self::FILES);
|
||||
self::$files = [
|
||||
'en.php' => '<?php return ["Test.presentText" => "and the Philosopher\'s Stone"];',
|
||||
'en-ca.php' => '<?php return [];',
|
||||
'en-us.php' => '<?php return ["Test.presentText" => "and the Sorcerer\'s Stone"];',
|
||||
'fr.php' => '<?php return ["Test.presentText" => "à l\'école des sorciers"];',
|
||||
'ja.php' => '<?php return ["Test.absentText" => "賢者の石"];',
|
||||
// corrupt files
|
||||
'it.php' => '<?php return 0;',
|
||||
'zh.php' => '<?php return 0',
|
||||
'ko.php' => 'DEAD BEEF',
|
||||
// empty file
|
||||
'fr-ca.php' => '',
|
||||
// unreadable file
|
||||
'ru.php' => '',
|
||||
];
|
||||
self::$vfs = vfsStream::setup("langtest", 0777, self::$files);
|
||||
self::$path = self::$vfs->url();
|
||||
// set up a file without read access
|
||||
chmod(self::$path."/ru.php", 0000);
|
||||
|
@ -38,9 +38,10 @@ class TestLang extends \PHPUnit\Framework\TestCase {
|
|||
Lang\Exception::$test = false;
|
||||
self::$path = null;
|
||||
self::$vfs = null;
|
||||
self::$files = null;
|
||||
}
|
||||
|
||||
function testList() {
|
||||
$this->assertEquals(sizeof(self::FILES), sizeof(Lang::list("en", "vfs://langtest/")));
|
||||
$this->assertEquals(sizeof(self::$files), sizeof(Lang::list("en", "vfs://langtest/")));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue