1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-23 17:12:41 +00:00
Arsse/tests/cases/Lang/TestErrors.php

84 lines
2.5 KiB
PHP
Raw Normal View History

2017-02-11 17:11:14 +00:00
<?php
/** @license MIT
* Copyright 2017 J. King, Dustin Wilson et al.
* See LICENSE and AUTHORS files for details */
2017-02-11 17:11:14 +00:00
declare(strict_types=1);
2017-12-22 03:47:19 +00:00
namespace JKingWeb\Arsse\TestCase\Lang;
2017-08-29 14:50:31 +00:00
2017-12-22 03:47:19 +00:00
use JKingWeb\Arsse\Lang as TestClass;
2017-02-11 17:11:14 +00:00
2017-07-20 22:36:03 +00:00
/** @covers \JKingWeb\Arsse\Lang */
2017-12-22 03:47:19 +00:00
class TestErrors extends \JKingWeb\Arsse\Test\AbstractTest {
use \JKingWeb\Arsse\Test\Lang\Setup;
2017-02-16 20:29:42 +00:00
public $files;
public $path;
public $l;
2017-02-16 20:29:42 +00:00
2020-01-20 18:52:48 +00:00
public function setUpSeries(): void {
$this->l->set("", true);
2017-02-16 20:29:42 +00:00
}
2020-01-20 18:52:48 +00:00
public function testLoadEmptyFile(): void {
2017-02-16 20:29:42 +00:00
$this->assertException("fileCorrupt", "Lang");
$this->l->set("fr_ca", true);
2017-02-16 20:29:42 +00:00
}
2020-01-20 18:52:48 +00:00
public function testLoadFileWhichDoesNotReturnAnArray(): void {
2017-02-16 20:29:42 +00:00
$this->assertException("fileCorrupt", "Lang");
$this->l->set("it", true);
2017-02-16 20:29:42 +00:00
}
2020-01-20 18:52:48 +00:00
public function testLoadFileWhichIsNotPhp(): void {
2017-02-16 20:29:42 +00:00
$this->assertException("fileCorrupt", "Lang");
$this->l->set("ko", true);
2017-02-16 20:29:42 +00:00
}
2020-01-20 18:52:48 +00:00
public function testLoadFileWhichIsCorrupt(): void {
2017-02-16 20:29:42 +00:00
$this->assertException("fileCorrupt", "Lang");
$this->l->set("zh", true);
2017-02-16 20:29:42 +00:00
}
2020-01-20 18:52:48 +00:00
public function testLoadFileWithooutReadPermission(): void {
2017-02-16 20:29:42 +00:00
$this->assertException("fileUnreadable", "Lang");
$this->l->set("ru", true);
2017-02-16 20:29:42 +00:00
}
2020-01-20 18:52:48 +00:00
public function testLoadSubtagOfMissingLanguage(): void {
2017-02-16 20:29:42 +00:00
$this->assertException("fileMissing", "Lang");
$this->l->set("pt_br", true);
2017-02-16 20:29:42 +00:00
}
2020-01-20 18:52:48 +00:00
public function testFetchInvalidMessage(): void {
$this->assertException("stringInvalid", "Lang");
$this->l->set("vi", true);
$txt = $this->l->msg('Test.presentText');
}
2020-01-20 18:52:48 +00:00
public function testFetchMissingMessage(): void {
$this->assertException("stringMissing", "Lang");
$txt = $this->l->msg('Test.absentText');
}
2020-01-20 18:52:48 +00:00
public function testLoadMissingDefaultLanguage(): void {
2017-12-22 03:47:19 +00:00
unlink($this->path.TestClass::DEFAULT.".php");
2017-02-16 20:29:42 +00:00
$this->assertException("defaultFileMissing", "Lang");
$this->l->set("fr", true);
2017-02-16 20:29:42 +00:00
}
2018-08-17 12:35:13 +00:00
2020-01-20 18:52:48 +00:00
public function testLoadMissingLanguageWhenFetching(): void {
2018-08-17 12:35:13 +00:00
$this->l->set("en_ca");
unlink($this->path.TestClass::DEFAULT.".php");
$this->assertException("fileMissing", "Lang");
$this->l->msg('Test.presentText');
}
2020-01-20 18:52:48 +00:00
public function testLoadMissingDefaultLanguageWhenFetching(): void {
2018-08-17 12:35:13 +00:00
unlink($this->path.TestClass::DEFAULT.".php");
$this->l = new TestClass($this->path);
$this->assertException("stringMissing", "Lang");
$this->l->msg('Test.presentText');
}
2017-08-29 14:50:31 +00:00
}