|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Zikula package. |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright Zikula Foundation - http://zikula.org/ |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Zikula\SettingsModule\Tests\Api; |
|
13
|
|
|
|
|
14
|
|
|
use Zikula\Bundle\CoreBundle\HttpKernel\ZikulaHttpKernelInterface; |
|
15
|
|
|
use Zikula\SettingsModule\Api\LocaleApi; |
|
16
|
|
|
|
|
17
|
|
|
class LocaleApiTest extends \PHPUnit_Framework_TestCase |
|
18
|
|
|
{ |
|
19
|
|
|
public function testGetSupportedLocales() |
|
20
|
|
|
{ |
|
21
|
|
|
$api = $this->getApi(); |
|
22
|
|
|
$this->assertEquals(['en', 'de', 'ru'], $api->getSupportedLocales(false)); |
|
|
|
|
|
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
public function testGetSupportedLocaleNames() |
|
26
|
|
|
{ |
|
27
|
|
|
$api = $this->getApi(); |
|
28
|
|
|
$expected = [ |
|
29
|
|
|
'English' => 'en', |
|
30
|
|
|
'German' => 'de', |
|
31
|
|
|
'Russian' => 'ru' |
|
32
|
|
|
]; |
|
33
|
|
|
$this->assertEquals($expected, $api->getSupportedLocaleNames(null, 'en', false)); |
|
|
|
|
|
|
34
|
|
|
$expected = [ |
|
35
|
|
|
'Englisch' => 'en', |
|
36
|
|
|
'Deutsch' => 'de', |
|
37
|
|
|
'Russisch' => 'ru' |
|
38
|
|
|
]; |
|
39
|
|
|
$this->assertEquals($expected, $api->getSupportedLocaleNames(null, 'de', false)); |
|
|
|
|
|
|
40
|
|
|
$expected = [ |
|
41
|
|
|
'inglese' => 'en', |
|
42
|
|
|
'tedesco' => 'de', |
|
43
|
|
|
'russo' => 'ru' |
|
44
|
|
|
]; |
|
45
|
|
|
$this->assertEquals($expected, $api->getSupportedLocaleNames(null, 'it', false)); |
|
|
|
|
|
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function testEmpty() |
|
49
|
|
|
{ |
|
50
|
|
|
$api = $this->getApi(''); |
|
51
|
|
|
$this->assertEquals(['en'], $api->getSupportedLocales(false)); |
|
|
|
|
|
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
private function getApi($dir = '/Fixtures') |
|
55
|
|
|
{ |
|
56
|
|
|
$kernel = $this->getMockBuilder(ZikulaHttpKernelInterface::class)->getMock(); |
|
57
|
|
|
$kernel->method('getRootDir')->willReturn(__DIR__ . $dir); |
|
58
|
|
|
|
|
59
|
|
|
return new LocaleApi($kernel); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignorePhpDoc annotation to the duplicate definition and it will be ignored.