Passed
Pull Request — master (#417)
by Alejandro
06:44
created

AsyncEventListenerTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 0
1
<?php
2
declare(strict_types=1);
3
4
namespace ShlinkioTest\Shlink\EventDispatcher\Listener;
5
6
use PHPUnit\Framework\TestCase;
7
use Shlinkio\Shlink\EventDispatcher\Listener\AsyncEventListener;
8
use Shlinkio\Shlink\EventDispatcher\Listener\EventListenerTask;
9
use stdClass;
10
use Swoole\Http\Server as HttpServer;
11
12
class AsyncEventListenerTest extends TestCase
13
{
14
    /** @var AsyncEventListener */
15
    private $eventListener;
16
    /** @var HttpServer */
17
    private $server;
18
    /** @var string */
19
    private $regularListenerName;
20
21
    public function setUp(): void
22
    {
23
        $this->regularListenerName = 'the_regular_listener';
24
        $this->server = $this->createMock(HttpServer::class);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->createMock(Swoole\Http\Server::class) of type PHPUnit\Framework\MockObject\MockObject is incompatible with the declared type Swoole\Http\Server of property $server.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
25
26
        $this->eventListener = new AsyncEventListener($this->server, $this->regularListenerName);
27
    }
28
29
    /** @test */
30
    public function enqueuesTaskWhenInvoked(): void
31
    {
32
        $event = new stdClass();
33
34
        $this->server
35
            ->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not exist on Swoole\Http\Server. ( Ignorable by Annotation )

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

35
            ->/** @scrutinizer ignore-call */ 
36
              expects($this->once())

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...
36
            ->method('task')
37
            ->with(new EventListenerTask($this->regularListenerName, $event));
38
39
        ($this->eventListener)($event);
40
    }
41
}
42