1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace ProxyManagerTest\Factory\RemoteObject\Adapter; |
6
|
|
|
|
7
|
|
|
use Laminas\Server\Client; |
8
|
|
|
use PHPUnit\Framework\MockObject\MockObject; |
9
|
|
|
use PHPUnit\Framework\TestCase; |
10
|
|
|
use ProxyManager\Factory\RemoteObject\Adapter\BaseAdapter; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Tests for {@see \ProxyManager\Factory\RemoteObject\Adapter\Soap} |
14
|
|
|
* |
15
|
|
|
* @group Coverage |
16
|
|
|
*/ |
17
|
|
|
final class BaseAdapterTest extends TestCase |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* {@inheritDoc} |
21
|
|
|
* |
22
|
|
|
* @covers \ProxyManager\Factory\RemoteObject\Adapter\BaseAdapter::__construct |
23
|
|
|
* @covers \ProxyManager\Factory\RemoteObject\Adapter\BaseAdapter::call |
24
|
|
|
* @covers \ProxyManager\Factory\RemoteObject\Adapter\Soap::getServiceName |
25
|
|
|
*/ |
26
|
|
|
public function testBaseAdapter() : void |
27
|
|
|
{ |
28
|
|
|
$client = $this |
|
|
|
|
29
|
|
|
->getMockBuilder(Client::class) |
30
|
|
|
->setMethods(['call']) |
31
|
|
|
->getMock(); |
32
|
|
|
|
33
|
|
|
$adapter = $this->getMockForAbstractClass( |
|
|
|
|
34
|
|
|
BaseAdapter::class, |
35
|
|
|
[$client] |
36
|
|
|
); |
37
|
|
|
|
38
|
|
|
$client |
39
|
|
|
->expects(self::once()) |
|
|
|
|
40
|
|
|
->method('call') |
41
|
|
|
->with('foobarbaz', ['tab' => 'taz']) |
42
|
|
|
->willReturn('baz'); |
43
|
|
|
|
44
|
|
|
$adapter |
|
|
|
|
45
|
|
|
->expects(self::once()) |
|
|
|
|
46
|
|
|
->method('getServiceName') |
47
|
|
|
->with('foo', 'bar') |
48
|
|
|
->willReturn('foobarbaz'); |
49
|
|
|
|
50
|
|
|
self::assertSame('baz', $adapter->call('foo', 'bar', ['tab' => 'taz'])); |
|
|
|
|
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* {@inheritDoc} |
55
|
|
|
* |
56
|
|
|
* @covers \ProxyManager\Factory\RemoteObject\Adapter\BaseAdapter::__construct |
57
|
|
|
* @covers \ProxyManager\Factory\RemoteObject\Adapter\BaseAdapter::call |
58
|
|
|
* @covers \ProxyManager\Factory\RemoteObject\Adapter\Soap::getServiceName |
59
|
|
|
*/ |
60
|
|
|
public function testBaseAdapterWithServiceMap() : void |
61
|
|
|
{ |
62
|
|
|
$client = $this |
|
|
|
|
63
|
|
|
->getMockBuilder(Client::class) |
64
|
|
|
->setMethods(['call']) |
65
|
|
|
->getMock(); |
66
|
|
|
|
67
|
|
|
$adapter = $this->getMockForAbstractClass( |
|
|
|
|
68
|
|
|
BaseAdapter::class, |
69
|
|
|
[$client, ['foobarbaz' => 'mapped']] |
70
|
|
|
); |
71
|
|
|
|
72
|
|
|
$client |
73
|
|
|
->expects(self::once()) |
|
|
|
|
74
|
|
|
->method('call') |
75
|
|
|
->with('mapped', ['tab' => 'taz']) |
76
|
|
|
->willReturn('baz'); |
77
|
|
|
|
78
|
|
|
$adapter |
|
|
|
|
79
|
|
|
->expects(self::once()) |
|
|
|
|
80
|
|
|
->method('getServiceName') |
81
|
|
|
->with('foo', 'bar') |
82
|
|
|
->willReturn('foobarbaz'); |
83
|
|
|
|
84
|
|
|
self::assertSame('baz', $adapter->call('foo', 'bar', ['tab' => 'taz'])); |
|
|
|
|
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.