1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-23 07:54:51 +00:00
Arsse/tests/Lang/TestLangErrors.php
J. King f902346b6c Eliminated passing of RuntimeData instances
- RuntimeData has now been replaced by a single static Data class
- The Data class has a load() method which fills the same role as the constructor of RuntimeData
- The static Lang class is now an instantiable class and is a member of Data
- All tests have been adjusted and pass
- The Exception tests no longer require convoluted workarounds: a simple mock  for Data::$l suffices; Lang tests also use a mock to prevent loops now instead of using a workaround
2017-03-28 18:50:00 -04:00

64 lines
No EOL
1.7 KiB
PHP

<?php
declare(strict_types=1);
namespace JKingWeb\Arsse;
use org\bovigo\vfs\vfsStream;
class TestLangErrors extends \PHPUnit\Framework\TestCase {
use Test\Tools, Test\Lang\Setup;
public $files;
public $path;
public $l;
function setUpSeries() {
$this->l->set("", true);
}
function testLoadEmptyFile() {
$this->assertException("fileCorrupt", "Lang");
$this->l->set("fr_ca", true);
}
function testLoadFileWhichDoesNotReturnAnArray() {
$this->assertException("fileCorrupt", "Lang");
$this->l->set("it", true);
}
function testLoadFileWhichIsNotPhp() {
$this->assertException("fileCorrupt", "Lang");
$this->l->set("ko", true);
}
function testLoadFileWhichIsCorrupt() {
$this->assertException("fileCorrupt", "Lang");
$this->l->set("zh", true);
}
function testLoadFileWithooutReadPermission() {
$this->assertException("fileUnreadable", "Lang");
$this->l->set("ru", true);
}
function testLoadSubtagOfMissingLanguage() {
$this->assertException("fileMissing", "Lang");
$this->l->set("pt_br", true);
}
function testFetchInvalidMessage() {
$this->assertException("stringInvalid", "Lang");
$this->l->set("vi", true);
$txt = $this->l->msg('Test.presentText');
}
function testFetchMissingMessage() {
$this->assertException("stringMissing", "Lang");
$txt = $this->l->msg('Test.absentText');
}
function testLoadMissingDefaultLanguage() {
unlink($this->path.Lang::DEFAULT.".php");
$this->assertException("defaultFileMissing", "Lang");
$this->l->set("fr", true);
}
}