2017-02-11 17:11:14 +00:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
2017-03-28 04:12:12 +00:00
|
|
|
namespace JKingWeb\Arsse;
|
2017-03-28 22:50:00 +00:00
|
|
|
use org\bovigo\vfs\vfsStream;
|
2017-02-11 17:11:14 +00:00
|
|
|
|
2017-07-20 22:36:03 +00:00
|
|
|
/** @covers \JKingWeb\Arsse\Lang */
|
2017-07-08 01:06:38 +00:00
|
|
|
class TestLangErrors extends Test\AbstractTest {
|
|
|
|
use Test\Lang\Setup;
|
2017-02-16 20:29:42 +00:00
|
|
|
|
2017-03-28 22:50:00 +00:00
|
|
|
public $files;
|
|
|
|
public $path;
|
|
|
|
public $l;
|
2017-02-16 20:29:42 +00:00
|
|
|
|
2017-03-28 22:50:00 +00:00
|
|
|
function setUpSeries() {
|
|
|
|
$this->l->set("", true);
|
2017-02-16 20:29:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testLoadEmptyFile() {
|
|
|
|
$this->assertException("fileCorrupt", "Lang");
|
2017-03-28 22:50:00 +00:00
|
|
|
$this->l->set("fr_ca", true);
|
2017-02-16 20:29:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testLoadFileWhichDoesNotReturnAnArray() {
|
|
|
|
$this->assertException("fileCorrupt", "Lang");
|
2017-03-28 22:50:00 +00:00
|
|
|
$this->l->set("it", true);
|
2017-02-16 20:29:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testLoadFileWhichIsNotPhp() {
|
|
|
|
$this->assertException("fileCorrupt", "Lang");
|
2017-03-28 22:50:00 +00:00
|
|
|
$this->l->set("ko", true);
|
2017-02-16 20:29:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testLoadFileWhichIsCorrupt() {
|
|
|
|
$this->assertException("fileCorrupt", "Lang");
|
2017-03-28 22:50:00 +00:00
|
|
|
$this->l->set("zh", true);
|
2017-02-16 20:29:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testLoadFileWithooutReadPermission() {
|
|
|
|
$this->assertException("fileUnreadable", "Lang");
|
2017-03-28 22:50:00 +00:00
|
|
|
$this->l->set("ru", true);
|
2017-02-16 20:29:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testLoadSubtagOfMissingLanguage() {
|
|
|
|
$this->assertException("fileMissing", "Lang");
|
2017-03-28 22:50:00 +00:00
|
|
|
$this->l->set("pt_br", true);
|
2017-02-16 20:29:42 +00:00
|
|
|
}
|
|
|
|
|
2017-02-16 22:50:34 +00:00
|
|
|
function testFetchInvalidMessage() {
|
|
|
|
$this->assertException("stringInvalid", "Lang");
|
2017-03-28 22:50:00 +00:00
|
|
|
$this->l->set("vi", true);
|
|
|
|
$txt = $this->l->msg('Test.presentText');
|
2017-02-16 22:50:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testFetchMissingMessage() {
|
|
|
|
$this->assertException("stringMissing", "Lang");
|
2017-03-28 22:50:00 +00:00
|
|
|
$txt = $this->l->msg('Test.absentText');
|
2017-02-16 22:50:34 +00:00
|
|
|
}
|
|
|
|
|
2017-02-16 20:29:42 +00:00
|
|
|
function testLoadMissingDefaultLanguage() {
|
2017-03-28 22:50:00 +00:00
|
|
|
unlink($this->path.Lang::DEFAULT.".php");
|
2017-02-16 20:29:42 +00:00
|
|
|
$this->assertException("defaultFileMissing", "Lang");
|
2017-03-28 22:50:00 +00:00
|
|
|
$this->l->set("fr", true);
|
2017-02-16 20:29:42 +00:00
|
|
|
}
|
2017-02-11 17:11:14 +00:00
|
|
|
}
|