File: CallSpec.php

package info (click to toggle)
php-phpspec-prophecy 1.22.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,376 kB
  • sloc: php: 9,909; makefile: 16
file content (65 lines) | stat: -rw-r--r-- 1,806 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php

namespace spec\Prophecy\Call;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument\ArgumentsWildcard;

class CallSpec extends ObjectBehavior
{
    function let(\Exception $exception)
    {
        $this->beConstructedWith('setValues', array(5, 2), 42, $exception, 'some_file.php', 23);
    }

    function it_exposes_method_name_through_getter()
    {
        $this->getMethodName()->shouldReturn('setValues');
    }

    function it_exposes_arguments_through_getter()
    {
        $this->getArguments()->shouldReturn(array(5, 2));
    }

    function it_exposes_return_value_through_getter()
    {
        $this->getReturnValue()->shouldReturn(42);
    }

    function it_exposes_exception_through_getter($exception)
    {
        $this->getException()->shouldReturn($exception);
    }

    function it_exposes_file_and_line_through_getter()
    {
        $this->getFile()->shouldReturn('some_file.php');
        $this->getLine()->shouldReturn(23);
    }

    function it_returns_shortpath_to_callPlace()
    {
        $this->getCallPlace()->shouldReturn('some_file.php:23');
    }

    function it_returns_unknown_as_callPlace_if_no_file_or_line_provided()
    {
        $this->beConstructedWith('setValues', array(), 0, null, null, null);

        $this->getCallPlace()->shouldReturn('unknown');
    }

    function it_adds_wildcard_match_score(ArgumentsWildcard $wildcard)
    {
        $this->addScore($wildcard, 99)->shouldReturn($this);
        $this->getScore($wildcard)->shouldReturn(99);
    }

    function it_caches_and_returns_wildcard_match_score(ArgumentsWildcard $wildcard)
    {
        $wildcard->scoreArguments(array(5, 2))->willReturn(13)->shouldBeCalledTimes(1);
        $this->getScore($wildcard)->shouldReturn(13);
        $this->getScore($wildcard)->shouldReturn(13);
    }
}