summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Integration/Lang/LanguageContentTest.php
blob: 9e49a224ca0528f385d55aa5cc1deb6e668462f0 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php

namespace SMW\Tests\Integration\Lang;

use SMW\Lang\Lang;

/**
 * @group semantic-mediawiki
 *
 * @license GNU GPL v2+
 * @since 2.5
 *
 * @author mwjames
 */
class LanguageContent extends \PHPUnit_Framework_TestCase {

	protected function tearDown() {
		Lang::clear();
		parent::tearDown();
	}

	/**
	 * @dataProvider canonicalPropertyAliasesProvider
	 */
	public function testGetCanonicalPropertyAliases( $languageCode, $canonicalMatch, $aliasMatch, $expected ) {

		$lang = Lang::getInstance()->fetch(
			$languageCode
		);

		$canonicalPropertyAliases = $lang->getCanonicalPropertyAliases();

		$this->assertEquals(
			$expected,
			$canonicalPropertyAliases[$canonicalMatch]
		);
	}

	/**
	 * @dataProvider canonicalPropertyAliasesProvider
	 */
	public function testGetPropertyAliases( $languageCode, $canonicalMatch, $aliasMatch, $expected ) {

		$lang = Lang::getInstance()->fetch(
			$languageCode
		);

		$propertyAliases = $lang->getPropertyAliases();

		$this->assertEquals(
			$expected,
			$propertyAliases[$aliasMatch]
		);
	}

	/**
	 * @dataProvider canonicalPropertyLabelsProvider
	 */
	public function testGetCanonicalPropertyLabels( $languageCode, $aliasMatch, $expected ) {

		$lang = Lang::getInstance()->fetch(
			$languageCode
		);

		$propertyLabels = $lang->getCanonicalPropertyLabels();

		$this->assertEquals(
			$expected,
			$propertyLabels[$aliasMatch]
		);
	}

	public function canonicalPropertyAliasesProvider() {

		$provider[] = [
			'fr',
			'Query size',
			'Taille de la requĂȘte',
			'_ASKSI'
		];

		return $provider;
	}

	public function canonicalPropertyLabelsProvider() {

		$provider[] = [
			'fr',
			'Boolean',
			'_boo'
		];

		$provider[] = [
			'en',
			'Float',
			'_num'
		];

		return $provider;
	}

}