Browse Source

Improve coverage slightly

Improves #66
microsub
J. King 6 years ago
parent
commit
edbfb12d17
  1. 6
      lib/Lang.php
  2. 14
      tests/cases/Lang/TestErrors.php
  3. 4
      tests/cases/REST/NextCloudNews/PDO/TestV1_2.php
  4. 3
      tests/cases/REST/TinyTinyRSS/PDO/TestAPI.php

6
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;

14
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');
}
}

4
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<extended> */
/** @covers \JKingWeb\Arsse\REST\NextCloudNews\V1_2<extended>
* @group optional
*/
class TestV1_2 extends \JKingWeb\Arsse\TestCase\REST\NextCloudNews\TestV1_2 {
use \JKingWeb\Arsse\Test\PDOTest;
}

3
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<extended>
* @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;
}

Loading…
Cancel
Save