From edbfb12d17bcc1221b32a64ccda27247b0632c59 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Fri, 17 Aug 2018 08:35:13 -0400 Subject: [PATCH] Improve coverage slightly Improves #66 --- lib/Lang.php | 6 ++---- tests/cases/Lang/TestErrors.php | 14 ++++++++++++++ tests/cases/REST/NextCloudNews/PDO/TestV1_2.php | 4 +++- tests/cases/REST/TinyTinyRSS/PDO/TestAPI.php | 3 ++- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/Lang.php b/lib/Lang.php index d6c798c..6114ba7 100644 --- a/lib/Lang.php +++ b/lib/Lang.php @@ -118,16 +118,14 @@ class Lang { } public function match(string $locale, array $list = null): string { - if ($list===null) { - $list = $this->listFiles(); - } + $list = $list ?? $this->listFiles(); $default = ($this->locale=="") ? self::DEFAULT : $this->locale; return \Locale::lookup($list, $locale, true, $default); } protected function checkRequirements(): bool { if (!extension_loaded("intl")) { - throw new ExceptionFatal("The \"Intl\" extension is required, but not loaded"); + throw new ExceptionFatal("The \"Intl\" extension is required, but not loaded"); // @codeCoverageIgnore } $this->requirementsMet = true; return true; diff --git a/tests/cases/Lang/TestErrors.php b/tests/cases/Lang/TestErrors.php index bd3f8c0..bed8c79 100644 --- a/tests/cases/Lang/TestErrors.php +++ b/tests/cases/Lang/TestErrors.php @@ -67,4 +67,18 @@ class TestErrors extends \JKingWeb\Arsse\Test\AbstractTest { $this->assertException("defaultFileMissing", "Lang"); $this->l->set("fr", true); } + + public function testLoadMissingLanguageWhenFetching() { + $this->l->set("en_ca"); + unlink($this->path.TestClass::DEFAULT.".php"); + $this->assertException("fileMissing", "Lang"); + $this->l->msg('Test.presentText'); + } + + public function testLoadMissingDefaultLanguageWhenFetching() { + unlink($this->path.TestClass::DEFAULT.".php"); + $this->l = new TestClass($this->path); + $this->assertException("stringMissing", "Lang"); + $this->l->msg('Test.presentText'); + } } diff --git a/tests/cases/REST/NextCloudNews/PDO/TestV1_2.php b/tests/cases/REST/NextCloudNews/PDO/TestV1_2.php index c6a3ef7..afc6751 100644 --- a/tests/cases/REST/NextCloudNews/PDO/TestV1_2.php +++ b/tests/cases/REST/NextCloudNews/PDO/TestV1_2.php @@ -6,7 +6,9 @@ declare(strict_types=1); namespace JKingWeb\Arsse\TestCase\REST\NextCloudNews\PDO; -/** @covers \JKingWeb\Arsse\REST\NextCloudNews\V1_2 */ +/** @covers \JKingWeb\Arsse\REST\NextCloudNews\V1_2 + * @group optional + */ class TestV1_2 extends \JKingWeb\Arsse\TestCase\REST\NextCloudNews\TestV1_2 { use \JKingWeb\Arsse\Test\PDOTest; } diff --git a/tests/cases/REST/TinyTinyRSS/PDO/TestAPI.php b/tests/cases/REST/TinyTinyRSS/PDO/TestAPI.php index 4acaf6d..62a9cef 100644 --- a/tests/cases/REST/TinyTinyRSS/PDO/TestAPI.php +++ b/tests/cases/REST/TinyTinyRSS/PDO/TestAPI.php @@ -7,7 +7,8 @@ declare(strict_types=1); namespace JKingWeb\Arsse\TestCase\REST\TinyTinyRSS\PDO; /** @covers \JKingWeb\Arsse\REST\TinyTinyRSS\API - * @covers \JKingWeb\Arsse\REST\TinyTinyRSS\Exception */ + * @covers \JKingWeb\Arsse\REST\TinyTinyRSS\Exception + * @group optional */ class TestAPI extends \JKingWeb\Arsse\TestCase\REST\TinyTinyRSS\TestAPI { use \JKingWeb\Arsse\Test\PDOTest; }