IniterTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 7
c 3
b 0
f 0
dl 0
loc 24
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A createObject() 0 3 2
A setUp() 0 5 1
A testReinit() 0 3 1
1
<?php
2
/**
3
 * RBAC implementation for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-rbac
6
 * @package   hipanel-rbac
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2016-2020, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\rbac\tests\unit;
12
13
use hipanel\rbac\AuthManager;
14
use hipanel\rbac\Initer;
15
16
/**
17
 * AuthManagerTest class.
18
 *
19
 * @author Andrii Vasyliev <[email protected]>
20
 */
21
class IniterTest extends \PHPUnit\Framework\TestCase
22
{
23
    use CheckAccessTrait;
0 ignored issues
show
Bug introduced by
The trait hipanel\rbac\tests\unit\CheckAccessTrait requires the property $name which is not provided by hipanel\rbac\tests\unit\IniterTest.
Loading history...
24
25
    /**
26
     * @var AuthManager
27
     */
28
    protected $auth;
29
30
    protected function setUp(): void
31
    {
32
        $this->auth = $this->createObject(AuthManager::class);
33
34
        $this->setAssignments();
35
    }
36
37
    public function testReinit()
38
    {
39
        $this->assertNull((new Initer())->reinit($this->auth));
0 ignored issues
show
Bug introduced by
Are you sure the usage of new hipanel\rbac\Initer()->reinit($this->auth) targeting hipanel\rbac\AbstractIniter::reinit() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Bug introduced by
The method assertNull() does not exist on hipanel\rbac\tests\unit\IniterTest. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
        $this->/** @scrutinizer ignore-call */ 
40
               assertNull((new Initer())->reinit($this->auth));

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
40
    }
41
42
    protected function createObject($config)
43
    {
44
        return class_exists('Yii') ? \Yii::createObject($config) : \yii\helpers\Yii::createObject($config);
0 ignored issues
show
Bug introduced by
The type yii\helpers\Yii was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
45
    }
46
}
47