Completed
Push — master ( 55311e...acc5b2 )
by Craig
06:34
created

LocaleApiTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 3

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetSupportedLocales() 0 5 1
A testGetSupportedLocaleNames() 0 22 1
A testEmpty() 0 5 1
A getApi() 0 7 1
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));
0 ignored issues
show
Unused Code introduced by
The call to LocaleApi::getSupportedLocales() has too many arguments starting with false.

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 @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
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));
0 ignored issues
show
Unused Code introduced by
The call to LocaleApi::getSupportedLocaleNames() has too many arguments starting with false.

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 @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
34
        $expected = [
35
            'Englisch' => 'en',
36
            'Deutsch' => 'de',
37
            'Russisch' => 'ru'
38
        ];
39
        $this->assertEquals($expected, $api->getSupportedLocaleNames(null, 'de', false));
0 ignored issues
show
Unused Code introduced by
The call to LocaleApi::getSupportedLocaleNames() has too many arguments starting with false.

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 @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
40
        $expected = [
41
            'inglese' => 'en',
42
            'tedesco' => 'de',
43
            'russo' => 'ru'
44
        ];
45
        $this->assertEquals($expected, $api->getSupportedLocaleNames(null, 'it', false));
0 ignored issues
show
Unused Code introduced by
The call to LocaleApi::getSupportedLocaleNames() has too many arguments starting with false.

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 @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
46
    }
47
48
    public function testEmpty()
49
    {
50
        $api = $this->getApi('');
51
        $this->assertEquals(['en'], $api->getSupportedLocales(false));
0 ignored issues
show
Unused Code introduced by
The call to LocaleApi::getSupportedLocales() has too many arguments starting with false.

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 @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
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