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
|
|
|
|
17
|
|
|
final class ArgumentCallTest extends TestCase |
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @test |
22
|
|
|
*/ |
23
|
|
|
public function shouldResolveCallArgument() |
24
|
|
|
{ |
25
|
|
|
/** @var Argument $callee */ |
26
|
|
|
$callee = $this->createMock(Argument::class); |
27
|
|
|
$callee->method("resolve")->willReturn($this); |
|
|
|
|
28
|
|
|
|
29
|
|
|
/** @var Argument $argumentA */ |
30
|
|
|
$argumentA = $this->createMock(Argument::class); |
31
|
|
|
$argumentA->method("resolve")->willReturn("some-foo"); |
|
|
|
|
32
|
|
|
|
33
|
|
|
/** @var Argument $argumentB */ |
34
|
|
|
$argumentB = $this->createMock(Argument::class); |
35
|
|
|
$argumentB->method("resolve")->willReturn(31415); |
|
|
|
|
36
|
|
|
|
37
|
|
|
$subject = new ArgumentCall($callee, "someMethod", [ |
38
|
|
|
$argumentA, |
39
|
|
|
$argumentB |
40
|
|
|
]); |
41
|
|
|
|
42
|
|
|
/** @var mixed $actualResult */ |
43
|
|
|
$actualResult = $subject->resolve(); |
44
|
|
|
|
45
|
|
|
$this->assertEquals("some-result", $actualResult); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function someMethod(string $foo, int $bar): string |
49
|
|
|
{ |
50
|
|
|
$this->assertEquals("some-foo", $foo); |
51
|
|
|
$this->assertEquals(31415, $bar); |
52
|
|
|
return "some-result"; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
} |
56
|
|
|
|
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.