Completed
Branch develop (9f43d2)
by Filipe
05:14
created

FactorySpec::it_is_initializable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace spec\Slick\Di\Definition;
4
5
use Slick\Di\Definition\Factory;
6
use PhpSpec\ObjectBehavior;
7
use Prophecy\Argument;
8
use Slick\Di\DefinitionInterface;
9
10
class FactorySpec extends ObjectBehavior
11
{
12
    function let()
13
    {
14
        $this->beConstructedWith(
15
            function (){
16
                return 'Test Callable';
17
            }
18
        );
19
    }
20
21
    function it_is_initializable()
22
    {
23
        $this->shouldHaveType(Factory::class);
24
    }
25
26
    function its_a_definition()
27
    {
28
        $this->shouldBeAnInstanceOf(DefinitionInterface::class);
29
    }
30
31
    function it_resolves_to_the_callable_return()
32
    {
33
        $this->resolve()->shouldBe('Test Callable');
34
    }
35
36
    function it_can_have_parameters_to_pass_to_callable_on_resolve()
37
    {
38
        $this->beConstructedWith(
39
            function ($test) {
40
                return $test;
41
            },
42
            ['test with parameters']
0 ignored issues
show
Unused Code introduced by
The call to FactorySpec::beConstructedWith() has too many arguments starting with array('test with parameters').

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
43
        );
44
        $this->resolve()->shouldBe('test with parameters');
0 ignored issues
show
Bug introduced by
The method resolve() does not exist on spec\Slick\Di\Definition\FactorySpec. Did you maybe mean it_resolves_to_the_callable_return()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
45
    }
46
}
47