I18nJsonFileIntegrityTest::i18nFileProvider()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace SIL\Tests\Integration;
4
5
use SMW\Tests\Utils\UtilityFactory;
6
7
/**
8
 * @group semantic-interlanguage-links
9
 * @group semantic-mediawiki-integration
10
 *
11
 * @group medium
12
 *
13
 * @license GNU GPL v2+
14
 * @since 1.0
15
 *
16
 * @author mwjames
17
 */
18
class I18nJsonFileIntegrityTest extends \PHPUnit_Framework_TestCase {
19
20
	/**
21
	 * @dataProvider i18nFileProvider
22
	 */
23
	public function testI18NJsonDecodeEncode( $file ) {
24
25
		$jsonFileReader = UtilityFactory::getInstance()->newJsonFileReader( $file );
26
27
		$this->assertInternalType(
28
			'integer',
29
			$jsonFileReader->getModificationTime()
30
		);
31
32
		$this->assertInternalType(
33
			'array',
34
			$jsonFileReader->read()
35
		);
36
	}
37
38
	public function i18nFileProvider() {
39
40
		$provider = [];
41
		$location = $GLOBALS['wgMessagesDirs']['SemanticInterlanguageLinks'];
42
43
		$bulkFileProvider = UtilityFactory::getInstance()->newBulkFileProvider( $location );
44
		$bulkFileProvider->searchByFileExtension( 'json' );
45
46
		foreach ( $bulkFileProvider->getFiles() as $file ) {
47
			$provider[] = [ $file ];
48
		}
49
50
		return $provider;
51
	}
52
53
}
54