Completed
Push — master ( 264630...c90943 )
by mw
230:08 queued 195:34
created

LanguageContent::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SMW\Tests\Integration\ExtraneousLanguage;
4
5
use SMW\ExtraneousLanguage\ExtraneousLanguage;
6
use SMW\Tests\TestEnvironment;
7
8
/**
9
 * @group semantic-mediawiki
10
 *
11
 * @license GNU GPL v2+
12
 * @since 2.5
13
 *
14
 * @author mwjames
15
 */
16
class LanguageContent extends \PHPUnit_Framework_TestCase {
17
18
	protected function tearDown() {
19
		ExtraneousLanguage::clear();
20
		parent::tearDown();
21
	}
22
23
	/**
24
	 * @dataProvider canonicalPropertyAliasesProvider
25
	 */
26
	public function testGetCanonicalPropertyAliases( $languageCode, $canonicalMatch, $aliasMatch, $expected ) {
27
28
		$extraneousLanguage = ExtraneousLanguage::getInstance()->fetchByLanguageCode(
29
			$languageCode
30
		);
31
32
		$canonicalPropertyAliases = $extraneousLanguage->getCanonicalPropertyAliases();
33
34
		$this->assertEquals(
35
			$expected,
36
			$canonicalPropertyAliases[$canonicalMatch]
37
		);
38
	}
39
40
	/**
41
	 * @dataProvider canonicalPropertyAliasesProvider
42
	 */
43
	public function testGetPropertyAliases( $languageCode, $canonicalMatch, $aliasMatch, $expected ) {
44
45
		$extraneousLanguage = ExtraneousLanguage::getInstance()->fetchByLanguageCode(
46
			$languageCode
47
		);
48
49
		$propertyAliases = $extraneousLanguage->getPropertyAliases();
50
51
		$this->assertEquals(
52
			$expected,
53
			$propertyAliases[$aliasMatch]
54
		);
55
	}
56
57
	public function canonicalPropertyAliasesProvider() {
58
59
		$provider[] = array(
0 ignored issues
show
Coding Style Comprehensibility introduced by
$provider was never initialized. Although not strictly required by PHP, it is generally a good practice to add $provider = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
60
			'fr',
61
			'Query size',
62
			'Taille de la requête',
63
			'_ASKSI'
64
		);
65
66
		return $provider;
67
	}
68
69
}
70