BaseAdapterTest::testBaseAdapterWithServiceMap()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 9.504
c 0
b 0
f 0
cc 1
nc 1
nop 0
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
0 ignored issues
show
Bug introduced by
The method setMethods cannot be called on $this->getMockBuilder(\L...s\Server\Client::class) (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
29
            ->getMockBuilder(Client::class)
30
            ->setMethods(['call'])
31
            ->getMock();
32
33
        $adapter = $this->getMockForAbstractClass(
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $adapter is correct as $this->getMockForAbstrac...:class, array($client)) (which targets PHPUnit\Framework\TestCa...tMockForAbstractClass()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
34
            BaseAdapter::class,
35
            [$client]
36
        );
37
38
        $client
39
            ->expects(self::once())
0 ignored issues
show
Bug introduced by
The method once() does not seem to exist on object<ProxyManagerTest\...dapter\BaseAdapterTest>.

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...
40
            ->method('call')
41
            ->with('foobarbaz', ['tab' => 'taz'])
42
            ->willReturn('baz');
43
44
        $adapter
0 ignored issues
show
Bug introduced by
The method expects cannot be called on $adapter (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
45
            ->expects(self::once())
0 ignored issues
show
Bug introduced by
The method once() does not seem to exist on object<ProxyManagerTest\...dapter\BaseAdapterTest>.

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...
46
            ->method('getServiceName')
47
            ->with('foo', 'bar')
48
            ->willReturn('foobarbaz');
49
50
        self::assertSame('baz', $adapter->call('foo', 'bar', ['tab' => 'taz']));
0 ignored issues
show
Bug introduced by
The method call cannot be called on $adapter (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
Bug introduced by
The method assertSame() does not seem to exist on object<ProxyManagerTest\...dapter\BaseAdapterTest>.

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...
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
0 ignored issues
show
Bug introduced by
The method setMethods cannot be called on $this->getMockBuilder(\L...s\Server\Client::class) (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
63
            ->getMockBuilder(Client::class)
64
            ->setMethods(['call'])
65
            ->getMock();
66
67
        $adapter = $this->getMockForAbstractClass(
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $adapter is correct as $this->getMockForAbstrac...obarbaz' => 'mapped'))) (which targets PHPUnit\Framework\TestCa...tMockForAbstractClass()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
68
            BaseAdapter::class,
69
            [$client, ['foobarbaz' => 'mapped']]
70
        );
71
72
        $client
73
            ->expects(self::once())
0 ignored issues
show
Bug introduced by
The method once() does not seem to exist on object<ProxyManagerTest\...dapter\BaseAdapterTest>.

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...
74
            ->method('call')
75
            ->with('mapped', ['tab' => 'taz'])
76
            ->willReturn('baz');
77
78
        $adapter
0 ignored issues
show
Bug introduced by
The method expects cannot be called on $adapter (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
79
            ->expects(self::once())
0 ignored issues
show
Bug introduced by
The method once() does not seem to exist on object<ProxyManagerTest\...dapter\BaseAdapterTest>.

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...
80
            ->method('getServiceName')
81
            ->with('foo', 'bar')
82
            ->willReturn('foobarbaz');
83
84
        self::assertSame('baz', $adapter->call('foo', 'bar', ['tab' => 'taz']));
0 ignored issues
show
Bug introduced by
The method call cannot be called on $adapter (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
Bug introduced by
The method assertSame() does not seem to exist on object<ProxyManagerTest\...dapter\BaseAdapterTest>.

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...
85
    }
86
}
87