blob: 817f250011afa69aa97215485729dd69c826a560 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
<?php
namespace UniversalLanguageSelector\Tests;
use ULSJsonMessageLoader;
/**
* @covers \ULSJsonMessageLoader
*
* @license GPL-2.0-or-later
* @author Thiemo Kreuz
*/
class ULSJsonMessageLoaderTest extends \PHPUnit\Framework\TestCase {
use \PHPUnit4And6Compat;
public function testGetFilenamesWithBadInput() {
$instance = new ULSJsonMessageLoader();
$this->setExpectedException( \MWException::class );
$instance->getFilenames( null );
}
public function testGetMessagesWithBadInput() {
$instance = new ULSJsonMessageLoader();
$this->setExpectedException( \MWException::class );
$instance->getMessages( null );
}
public function testWithInvalidLanguageCode() {
$instance = new ULSJsonMessageLoader();
$languageCode = '0';
$filenames = $instance->getFilenames( $languageCode );
$this->assertSame( [], $filenames );
$messages = $instance->getMessages( $languageCode );
$this->assertSame( [], $messages );
}
public function testWithValidLanguageCode() {
$instance = new ULSJsonMessageLoader();
$languageCode = 'en';
$filenames = $instance->getFilenames( $languageCode );
$this->assertContainsOnly( 'string', $filenames );
$messages = $instance->getMessages( $languageCode );
unset( $messages['@metadata'] );
$this->assertContainsOnly( 'string', array_keys( $messages ) );
$this->assertContainsOnly( 'string', $messages );
}
}
|