Completed
Branch master (2230cd)
by Max
06:42 queued 03:04
created

CallTest::testFunctionCall()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
/*
3
 * @copyright (c) 2018 Mendel <[email protected]>
4
 * @license see license.txt
5
 */
6
namespace drycart\di\tests;
7
8
9
/**
10
 * Description of DiTest
11
 *
12
 * @author mendel
13
 */
14
class CallTest extends \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...
15
{
16
    public function testSimpleCall()
17
    {
18
        $di = new \drycart\di\Container();
19
        $di->setConfig([
20
            'drycart\di\tests\DummyInterface' => ['#class'=>'drycart\di\tests\DummyComplex']
21
        ]);
22
        $obj = $di->get('drycart\di\tests\DummyInterface');
23
        $dummy = $di->call([$obj, 'method'], ['i'=>null]);
24
        $this->assertTrue(is_a($dummy, 'drycart\di\tests\Dummy'));
25
    }
26
    
27
    public function testFunctionCall()
28
    {
29
        $function = function(int $i) : int
30
        {
31
            return $i;
32
        };
33
        //
34
        $di = new \drycart\di\Container();
35
        $i = $di->call($function, ['i'=>999]);
36
        //
37
        $this->assertEquals($i, 999);
38
    }
39
}
40