1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-23 08:34:56 +00:00
Arsse/tests/TestLang.php

47 lines
1.3 KiB
PHP
Raw Normal View History

2017-02-08 21:53:02 +00:00
<?php
declare(strict_types=1);
namespace JKingWeb\NewsSync;
use \org\bovigo\vfs\vfsStream;
class TestLang extends \PHPUnit\Framework\TestCase {
use TestingHelpers;
static $vfs;
static $path;
2017-02-08 21:59:16 +00:00
static $files;
2017-02-08 21:53:02 +00:00
static function setUpBeforeClass() {
Lang\Exception::$test = true;
2017-02-08 21:59:16 +00:00
self::$files = [
'en.php' => '<?php return ["Test.presentText" => "and the Philosopher\'s Stone"];',
'en-ca.php' => '<?php return [];',
'en-us.php' => '<?php return ["Test.presentText" => "and the Sorcerer\'s Stone"];',
'fr.php' => '<?php return ["Test.presentText" => "à l\'école des sorciers"];',
'ja.php' => '<?php return ["Test.absentText" => "賢者の石"];',
// corrupt files
'it.php' => '<?php return 0;',
'zh.php' => '<?php return 0',
'ko.php' => 'DEAD BEEF',
// empty file
'fr-ca.php' => '',
// unreadable file
'ru.php' => '',
];
self::$vfs = vfsStream::setup("langtest", 0777, self::$files);
2017-02-08 21:53:02 +00:00
self::$path = self::$vfs->url();
// set up a file without read access
chmod(self::$path."/ru.php", 0000);
}
static function tearDownAfterClass() {
Lang\Exception::$test = false;
self::$path = null;
self::$vfs = null;
2017-02-08 21:59:16 +00:00
self::$files = null;
2017-02-08 21:53:02 +00:00
}
function testList() {
2017-02-08 21:59:16 +00:00
$this->assertEquals(sizeof(self::$files), sizeof(Lang::list("en", "vfs://langtest/")));
2017-02-08 21:53:02 +00:00
}
}