ModuleTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 19 1
A tearDown() 0 3 1
A testGetInstance() 0 6 1
1
<?php
2
/**
3
 * Yii2 module for language switching.
4
 *
5
 * @link      https://github.com/hiqdev/yii2-language
6
 * @package   yii2-language
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2016-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\yii2\language\tests\unit;
12
13
use hiqdev\yii2\language\Module;
14
use yii\web\Application;
15
16
/**
17
 * Module test suite.
18
 */
19
class ModuleTest extends \PHPUnit\Framework\TestCase
20
{
21
    /**
22
     * @var Module
23
     */
24
    protected $object;
25
26
    protected function setUp()
27
    {
28
        $application = new Application([
0 ignored issues
show
Unused Code introduced by
$application is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
29
            'id'       => 'mock',
30
            'basePath' => dirname(dirname(__DIR__)),
31
            'modules'  => [
32
                'language' => [
33
                    'class' => Module::class,
34
                ],
35
            ],
36
            'components' => [
37
                'urlManager' => [
38
                    'enablePrettyUrl' => true,
39
                    'showScriptName'  => false,
40
                ],
41
            ],
42
        ]);
43
        $this->object = Module::getInstance();
44
    }
45
46
    protected function tearDown()
47
    {
48
    }
49
50
    public function testGetInstance()
51
    {
52
        $module = Module::getInstance();
53
        $this->assertInstanceOf(Module::class, $module);
54
        $this->assertSame($this->object, $module);
55
    }
56
}
57