HelpersTest::testView()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 9.4285
1
<?php
2
3
namespace Tests;
4
5
use PHPUnit\Framework\TestCase;
6
7
class HelpersTest extends TestCase
8
{
9
    /**
10
     * Includes the functions file manually.
11
     *
12
     * @return void
13
     */
14
    public function setUp()
15
    {
16
        require_once __DIR__ . '/../app/helpers.php';
17
    }
18
19
    /**
20
     * Tests the view importer.
21
     *
22
     * @return void
23
     */
24
    public function testView(): void
25
    {
26
        $hash = bin2hex(openssl_random_pseudo_bytes(16));
27
        $value = view('/../tests/samples/view.php', ['hash' => $hash]);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $value is correct as view('/../tests/samples/...array('hash' => $hash)) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

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

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

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

Loading history...
28
        $this->assertEquals('Test value: ' . $hash, $value);
29
    }
30
31
    /**
32
     * tests the configuration importer.
33
     *
34
     * @return void
35
     */
36
    public function testConfig(): void
37
    {
38
        $hash = '9575d687c61ce66fc190cd2bed464cef';
39
        $value = config('tests/samples/config.php');
40
        $this->assertEquals($hash, $value['api_secret']);
41
    }
42
}
43