Completed
Pull Request — master (#83)
by Jeroen De
20:05
created

I18nJsonFileIntegrityTest::setUp()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 0
1
<?php
2
3
namespace SWL\Tests\Integration;
4
5
use SMW\Tests\Utils\UtilityFactory;
6
7
/**
8
 * @group semantic-watchlist
9
 *
10
 * @group medium
11
 *
12
 * @license GNU GPL v2+
13
 * @since 1.0
14
 *
15
 * @author mwjames
16
 */
17
class I18nJsonFileIntegrityTest extends \PHPUnit_Framework_TestCase {
18
19
	public function setUp() {
20
		if ( !class_exists( UtilityFactory::class ) ) {
21
			// FIXME: should not depend on non-production class of another package
22
			$this->markTestSkipped( 'SMW\Tests\Utils\UtilityFactory is not available' );
23
		}
24
	}
25
26
	/**
27
	 * @dataProvider i18nFileProvider
28
	 */
29
	public function testI18NJsonDecodeEncode( $file ) {
30
31
		$jsonFileReader = UtilityFactory::getInstance()->newJsonFileReader( $file );
32
33
		$this->assertInternalType(
34
			'integer',
35
			$jsonFileReader->getModificationTime()
36
		);
37
38
		$this->assertInternalType(
39
			'array',
40
			$jsonFileReader->read()
41
		);
42
	}
43
44
	public function i18nFileProvider() {
45
46
		$provider = array();
47
		$location = $GLOBALS['wgMessagesDirs']['SemanticWatchlist'];
48
49
		$bulkFileProvider = UtilityFactory::getInstance()->newBulkFileProvider( $location );
50
		$bulkFileProvider->searchByFileExtension( 'json' );
51
52
		foreach ( $bulkFileProvider->getFiles() as $file ) {
53
			$provider[] = array( $file );
54
		}
55
56
		return $provider;
57
	}
58
59
}
60