2017-02-11 17:11:14 +00:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace JKingWeb\NewsSync;
|
|
|
|
use \org\bovigo\vfs\vfsStream;
|
|
|
|
|
|
|
|
|
|
|
|
class TestLangErrors extends \PHPUnit\Framework\TestCase {
|
|
|
|
use TestingHelpers, LanguageTestingHelpers;
|
|
|
|
|
|
|
|
static $vfs;
|
|
|
|
static $path;
|
|
|
|
static $files;
|
|
|
|
static $defaultPath;
|
|
|
|
|
|
|
|
function setUp() {
|
|
|
|
Lang::set("", true);
|
|
|
|
}
|
|
|
|
|
2017-02-11 18:50:34 +00:00
|
|
|
function testLoadEmptyFile() {
|
2017-02-11 17:11:14 +00:00
|
|
|
$this->assertException("fileCorrupt", "Lang");
|
|
|
|
Lang::set("fr_ca", true);
|
|
|
|
}
|
|
|
|
|
2017-02-11 18:50:34 +00:00
|
|
|
function testLoadFileWhichDoesNotReturnAnArray() {
|
2017-02-11 17:11:14 +00:00
|
|
|
$this->assertException("fileCorrupt", "Lang");
|
|
|
|
Lang::set("it", true);
|
|
|
|
}
|
|
|
|
|
2017-02-11 18:50:34 +00:00
|
|
|
function testLoadFileWhichIsNotPhp() {
|
2017-02-11 17:11:14 +00:00
|
|
|
$this->assertException("fileCorrupt", "Lang");
|
|
|
|
Lang::set("ko", true);
|
|
|
|
}
|
|
|
|
|
2017-02-11 18:50:34 +00:00
|
|
|
function testLoadFileWhichIsCorrupt() {
|
2017-02-11 17:11:14 +00:00
|
|
|
$this->assertException("fileCorrupt", "Lang");
|
|
|
|
Lang::set("zh", true);
|
|
|
|
}
|
|
|
|
|
2017-02-11 18:50:34 +00:00
|
|
|
function testLoadFileWithooutReadPermission() {
|
2017-02-11 17:11:14 +00:00
|
|
|
$this->assertException("fileUnreadable", "Lang");
|
|
|
|
Lang::set("ru", true);
|
|
|
|
}
|
|
|
|
|
2017-02-11 18:50:34 +00:00
|
|
|
function testLoadSubtagOfMissingLanguage() {
|
|
|
|
$this->assertException("fileMissing", "Lang");
|
|
|
|
Lang::set("pt_br", true);
|
|
|
|
}
|
|
|
|
|
|
|
|
function testLoadMissingDefaultLanguage() {
|
2017-02-11 17:11:14 +00:00
|
|
|
// this should be the last test of the series
|
|
|
|
unlink(self::$path.Lang::DEFAULT.".php");
|
|
|
|
$this->assertException("defaultFileMissing", "Lang");
|
|
|
|
Lang::set("fr", true);
|
|
|
|
}
|
|
|
|
}
|