Completed
Push — master ( 47ba96...4fd14e )
by Gerrit
02:18
created

ArgumentCallTest::someMethod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
/**
3
 * Copyright (C) 2017  Gerrit Addiks.
4
 * This package (including this file) was released under the terms of the GPL-3.0.
5
 * You should have received a copy of the GNU General Public License along with this program.
6
 * If not, see <http://www.gnu.org/licenses/> or send me a mail so i can send you a copy.
7
 * @license GPL-3.0
8
 * @author Gerrit Addiks <[email protected]>
9
 */
10
11
namespace Addiks\SymfonyGenerics\Tests\Unit\Arguments;
12
13
use PHPUnit\Framework\TestCase;
14
use Addiks\SymfonyGenerics\Arguments\ArgumentCall;
15
use Addiks\SymfonyGenerics\Arguments\Argument;
16
use InvalidArgumentException;
17
use stdClass;
18
19
final class ArgumentCallTest extends TestCase
20
{
21
22
    /**
23
     * @test
24
     */
25
    public function shouldResolveCallArgument()
26
    {
27
        /** @var Argument $callee */
28
        $callee = $this->createMock(Argument::class);
29
        $callee->method("resolve")->willReturn($this);
0 ignored issues
show
Bug introduced by
The method method() does not seem to exist on object<Addiks\SymfonyGenerics\Arguments\Argument>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
30
31
        /** @var Argument $argumentA */
32
        $argumentA = $this->createMock(Argument::class);
33
        $argumentA->method("resolve")->willReturn("some-foo");
0 ignored issues
show
Bug introduced by
The method method() does not seem to exist on object<Addiks\SymfonyGenerics\Arguments\Argument>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
34
35
        /** @var Argument $argumentB */
36
        $argumentB = $this->createMock(Argument::class);
37
        $argumentB->method("resolve")->willReturn(31415);
0 ignored issues
show
Bug introduced by
The method method() does not seem to exist on object<Addiks\SymfonyGenerics\Arguments\Argument>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
38
39
        $subject = new ArgumentCall($callee, "someMethod", [
40
            $argumentA,
41
            $argumentB
42
        ]);
43
44
        /** @var mixed $actualResult */
45
        $actualResult = $subject->resolve();
46
47
        $this->assertEquals("some-result", $actualResult);
48
    }
49
50
    public function someMethod(string $foo, int $bar): string
51
    {
52
        $this->assertEquals("some-foo", $foo);
53
        $this->assertEquals(31415, $bar);
54
        return "some-result";
55
    }
56
57
    /**
58
     * @test
59
     */
60 View Code Duplication
    public function shouldRejectNonObjectCallee()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
61
    {
62
        $this->expectException(InvalidArgumentException::class);
63
64
        /** @var Argument $callee */
65
        $callee = $this->createMock(Argument::class);
66
        $callee->method("resolve")->willReturn("non-object");
0 ignored issues
show
Bug introduced by
The method method() does not seem to exist on object<Addiks\SymfonyGenerics\Arguments\Argument>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
67
68
        $subject = new ArgumentCall($callee, "someMethod", []);
69
70
        $subject->resolve();
71
    }
72
73
    /**
74
     * @test
75
     */
76 View Code Duplication
    public function shouldRejectCalleeWithoutCalledMethod()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
77
    {
78
        $this->expectException(InvalidArgumentException::class);
79
80
        /** @var Argument $callee */
81
        $callee = $this->createMock(Argument::class);
82
        $callee->method("resolve")->willReturn($this->createMock(stdClass::class));
0 ignored issues
show
Bug introduced by
The method method() does not seem to exist on object<Addiks\SymfonyGenerics\Arguments\Argument>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
83
84
        $subject = new ArgumentCall($callee, "someMethod", []);
85
86
        $subject->resolve();
87
    }
88
89
}
90