Completed
Pull Request — master (#26)
by Julien
04:20
created

DelayEventDispatcherTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
namespace Itkg\DelayEventBundle\Tests\EventDispatcher;
3
4
use Itkg\DelayEventBundle\Event\DelayableEvents;
5
use Itkg\DelayEventBundle\EventDispatcher\DelayEventDispatcher;
6
use Phake;
7
8
/**
9
 * Class DelayEventDispatcherTest
10
 */
11
class DelayEventDispatcherTest extends \PHPUnit_Framework_TestCase
12
{
13
    /**
14
     * @var DelayEventDispatcher
15
     */
16
    private $dispatcher;
17
18
    private $decoratedDispatcher;
19
20
    protected function setUp()
21
    {
22
        $this->decoratedDispatcher = Phake::mock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
23
        $this->dispatcher = new DelayEventDispatcher($this->decoratedDispatcher, array('delayable.event'));
0 ignored issues
show
Documentation introduced by
$this->decoratedDispatcher is of type object<Phake_IMock>, but the function expects a object<Symfony\Component...entDispatcherInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
24
    }
25
26
    public function testDispatch()
27
    {
28
        $eventName = 'foo';
29
        $event = Phake::mock('Symfony\Component\EventDispatcher\Event');
30
        $this->dispatcher->dispatch($eventName, $event);
0 ignored issues
show
Documentation introduced by
$event is of type object<Phake_IMock>, but the function expects a null|object<Symfony\Comp...\EventDispatcher\Event>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
31
        Phake::verify($this->decoratedDispatcher)->dispatch($eventName, $event);
32
33
        $delayEvent = Phake::mock('Itkg\DelayEventBundle\Model\Event');
34
        $this->dispatcher->dispatch($eventName, $delayEvent);
0 ignored issues
show
Documentation introduced by
$delayEvent is of type object<Phake_IMock>, but the function expects a null|object<Symfony\Comp...\EventDispatcher\Event>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
35
        Phake::verify($this->decoratedDispatcher)->dispatch($eventName, $delayEvent);
36
37
        $eventName = 'delayable.event';
38
        $this->dispatcher->dispatch($eventName, $event);
0 ignored issues
show
Documentation introduced by
$event is of type object<Phake_IMock>, but the function expects a null|object<Symfony\Comp...\EventDispatcher\Event>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
39
        Phake::verify($this->decoratedDispatcher)->dispatch($eventName, $event);
40
41
        Phake::when($delayEvent)->isDelayed()->thenReturn(true);
42
        $this->dispatcher->dispatch($eventName, $delayEvent);
0 ignored issues
show
Documentation introduced by
$delayEvent is of type object<Phake_IMock>, but the function expects a null|object<Symfony\Comp...\EventDispatcher\Event>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
43
        Phake::verify($this->decoratedDispatcher)->dispatch(DelayableEvents::DELAY, Phake::capture($newEvent));
44
        $this->assertInstanceOf('Itkg\DelayEventBundle\Event\DelayableEvent', $newEvent);
45
        Phake::verify($delayEvent)->setOriginalName($eventName);
46
        /** @var \Itkg\DelayEventBundle\Event\DelayableEvent $newEvent */
47
        $this->assertEquals($delayEvent, $newEvent->getDelayedEvent());
48
    }
49
}
50