Passed
Pull Request — master (#21)
by GIT
08:43 queued 44s
created

I18nJsonFileIntegrityTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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