RpcServerTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 4
Bugs 1 Features 0
Metric Value
eloc 24
c 4
b 1
f 0
dl 0
loc 31
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testProcessMessageWithCustomSerializer() 0 29 1
1
<?php
2
3
namespace OldSound\RabbitMqBundle\Tests\RabbitMq;
4
5
use OldSound\RabbitMqBundle\RabbitMq\RpcServer;
6
use PhpAmqpLib\Message\AMQPMessage;
7
use PHPUnit\Framework\TestCase;
8
9
class RpcServerTest extends TestCase
10
{
11
    public function testProcessMessageWithCustomSerializer()
12
    {
13
        /** @var RpcServer $server */
14
        $server = $this->getMockBuilder('\OldSound\RabbitMqBundle\RabbitMq\RpcServer')
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\MockOb...ckBuilder::setMethods() has been deprecated: https://github.com/sebastianbergmann/phpunit/pull/3687 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

14
        $server = /** @scrutinizer ignore-deprecated */ $this->getMockBuilder('\OldSound\RabbitMqBundle\RabbitMq\RpcServer')

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
15
            ->setMethods(['sendReply', 'maybeStopConsumer'])
16
            ->disableOriginalConstructor()
17
            ->getMock();
18
        $message = $this->getMockBuilder('\PhpAmqpLib\Message\AMQPMessage')
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\MockOb...ckBuilder::setMethods() has been deprecated: https://github.com/sebastianbergmann/phpunit/pull/3687 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

18
        $message = /** @scrutinizer ignore-deprecated */ $this->getMockBuilder('\PhpAmqpLib\Message\AMQPMessage')

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
19
            ->setMethods(['get'])
20
            ->getMock();
21
        $message->setChannel(
22
            $this->getMockBuilder('\PhpAmqpLib\Channel\AMQPChannel')
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\MockOb...ckBuilder::setMethods() has been deprecated: https://github.com/sebastianbergmann/phpunit/pull/3687 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

22
            /** @scrutinizer ignore-deprecated */ $this->getMockBuilder('\PhpAmqpLib\Channel\AMQPChannel')

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
23
                ->setMethods([])->setConstructorArgs([])
24
                ->setMockClassName('')
25
                ->disableOriginalConstructor()
26
                ->getMock()
27
        );
28
        $message->setDeliveryTag(0);
29
        $server->setCallback(function () {
30
            return 'message';
31
        });
32
        $serializer = $this->getMockBuilder('\Symfony\Component\Serializer\SerializerInterface')
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\MockOb...ckBuilder::setMethods() has been deprecated: https://github.com/sebastianbergmann/phpunit/pull/3687 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

32
        $serializer = /** @scrutinizer ignore-deprecated */ $this->getMockBuilder('\Symfony\Component\Serializer\SerializerInterface')

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
33
            ->setMethods(['serialize', 'deserialize'])
34
            ->getMock();
35
        $serializer->expects($this->once())->method('serialize')->with('message', 'json');
36
        $server->setSerializer(function ($data) use ($serializer) {
37
            $serializer->serialize($data, 'json');
38
        });
39
        $server->processMessage($message);
40
    }
41
}
42