testShouldSendExpectedMessageOnPushRaw()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 46
Code Lines 43

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 43
nc 1
nop 0
dl 0
loc 46
rs 9.232
c 1
b 0
f 0
1
<?php
2
3
namespace Noitran\Lumen\Horizon\Tests;
4
5
use Interop\Amqp\AmqpTopic;
6
use Interop\Amqp\AmqpQueue;
7
use Interop\Amqp\AmqpProducer;
8
9
10
class RabbitMQQueueTest extends TestCase
11
{
12
    public function testShouldSendExpectedMessageOnPushRaw()
13
    {
14
        $expectedQueueName = 'theQueueName';
15
        $expectedBody = 'thePayload';
16
        $topic = $this->createMock(AmqpTopic::class);
17
        $queue = $this->createMock(AmqpQueue::class);
18
        $queue->expects($this->any())->method('getQueueName')->willReturn('theQueueName');
19
        $producer = $this->createMock(AmqpProducer::class);
20
        $producer
21
            ->expects($this->once())
22
            ->method('send')
23
            ->with($this->identicalTo($topic), $this->isInstanceOf(AmqpMessage::class))
0 ignored issues
show
Bug introduced by
The type Noitran\Lumen\Horizon\Tests\AmqpMessage was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
24
            ->willReturnCallback(function ($actualTopic, AmqpMessage $message) use ($expectedQueueName, $expectedBody, $topic) {
25
                $this->assertSame($topic, $actualTopic);
26
                $this->assertSame($expectedBody, $message->getBody());
27
                $this->assertSame($expectedQueueName, $message->getRoutingKey());
28
                $this->assertSame('application/json', $message->getContentType());
29
                $this->assertSame(AmqpMessage::DELIVERY_MODE_PERSISTENT, $message->getDeliveryMode());
30
                $this->assertNotEmpty($message->getCorrelationId());
31
                $this->assertNull($message->getProperty(RabbitMQJob::ATTEMPT_COUNT_HEADERS_KEY));
0 ignored issues
show
Bug introduced by
The type Noitran\Lumen\Horizon\Tests\RabbitMQJob was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
32
            });
33
        $producer
34
            ->expects($this->never())
35
            ->method('setDeliveryDelay');
36
        $context = $this->createAmqpContext();
0 ignored issues
show
Bug introduced by
The method createAmqpContext() does not exist on Noitran\Lumen\Horizon\Tests\RabbitMQQueueTest. ( Ignorable by Annotation )

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

36
        /** @scrutinizer ignore-call */ 
37
        $context = $this->createAmqpContext();

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...
37
        $context
38
            ->expects($this->once())
39
            ->method('createTopic')
40
            ->willReturn($topic);
41
        $context
42
            ->expects($this->once())
43
            ->method('createMessage')
44
            ->with($expectedBody)
45
            ->willReturn(new \Interop\Amqp\Impl\AmqpMessage($expectedBody));
46
        $context
47
            ->expects($this->once())
48
            ->method('createQueue')
49
            ->with($expectedQueueName)
50
            ->willReturn($queue);
51
        $context
52
            ->expects($this->once())
53
            ->method('createProducer')
54
            ->willReturn($producer);
55
        $queue = new RabbitMQQueue($context, $this->createDummyConfig());
0 ignored issues
show
Bug introduced by
The method createDummyConfig() does not exist on Noitran\Lumen\Horizon\Tests\RabbitMQQueueTest. ( Ignorable by Annotation )

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

55
        $queue = new RabbitMQQueue($context, $this->/** @scrutinizer ignore-call */ createDummyConfig());

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...
56
        $queue->setContainer($this->createDummyContainer());
0 ignored issues
show
Bug introduced by
The method createDummyContainer() does not exist on Noitran\Lumen\Horizon\Tests\RabbitMQQueueTest. ( Ignorable by Annotation )

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

56
        $queue->setContainer($this->/** @scrutinizer ignore-call */ createDummyContainer());

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...
57
        $queue->pushRaw('thePayload', $expectedQueueName);
58
    }
59
}
60