Passed
Pull Request — master (#1312)
by Michael
07:24
created

HelperTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 29
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 3 1
A tearDown() 0 2 1
A testGetHelper() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Xmf\Test\Module;
6
7
use PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase 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...
8
use Xmf\Module\Helper;
9
10
require_once dirname(__DIR__, 4) . '/init_new.php';
11
12
require_once(XOOPS_TU_ROOT_PATH . '/include/functions.php');
13
require_once(XOOPS_TU_ROOT_PATH . '/kernel/object.php');
14
15
require_once(XOOPS_TU_ROOT_PATH . '/class/logger/xoopslogger.php');
16
require_once(XOOPS_TU_ROOT_PATH . '/class/xoopsload.php');
17
require_once(XOOPS_TU_ROOT_PATH . '/class/preload.php');
18
require_once(XOOPS_TU_ROOT_PATH . '/class/database/databasefactory.php');
19
20
require_once(XOOPS_TU_ROOT_PATH . '/class/module.textsanitizer.php');
21
22
class HelperTest extends TestCase
23
{
24
    /**
25
     * @var Helper
26
     */
27
    protected $object;
28
29
    /**
30
     * Sets up the fixture, for example, opens a network connection.
31
     * This method is called before a test is executed.
32
     */
33
    protected function setUp(): void
34
    {
35
        $this->object = Helper::getHelper();
0 ignored issues
show
Documentation Bug introduced by
It seems like Xmf\Module\Helper::getHelper() can also be of type false. However, the property $object is declared as type Xmf\Module\Helper. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
36
    }
37
38
    /**
39
     * Tears down the fixture, for example, closes a network connection.
40
     * This method is called after a test is executed.
41
     */
42
    protected function tearDown(): void
43
    {
44
    }
45
46
    public function testGetHelper()
47
    {
48
        // Remove the following lines when you implement this test.
49
        $this->markTestIncomplete(
50
            'This test has not been implemented yet.'
51
        );
52
    }
53
}
54