1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the FirebaseCloudMessagingBundle |
4
|
|
|
* |
5
|
|
|
* (c) Artem Genvald <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Fresh\FirebaseCloudMessagingBundle\Tests\Event; |
12
|
|
|
|
13
|
|
|
use Fresh\FirebaseCloudMessaging\Event\FirebaseEvents; |
14
|
|
|
use Fresh\FirebaseCloudMessaging\Event\MulticastMessageResponseEvent; |
15
|
|
|
use Fresh\FirebaseCloudMessaging\Response\MessageResult\Collection\CanonicalTokenMessageResultCollection; |
16
|
|
|
use Fresh\FirebaseCloudMessaging\Response\MessageResult\Collection\FailedMessageResultCollection; |
17
|
|
|
use Fresh\FirebaseCloudMessaging\Response\MessageResult\Collection\SuccessfulMessageResultCollection; |
18
|
|
|
use Fresh\FirebaseCloudMessagingBundle\Event\SymfonyEventDispatcher; |
19
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface as SymfonyEventDispatcherInterface; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* SymfonyEventDispatcherTest. |
23
|
|
|
* |
24
|
|
|
* @author Artem Genvald <[email protected]> |
25
|
|
|
*/ |
26
|
|
|
class SymfonyEventDispatcherTest extends \PHPUnit_Framework_TestCase |
27
|
|
|
{ |
28
|
|
|
public function testDispatchMethod() |
29
|
|
|
{ |
30
|
|
|
/** @var SymfonyEventDispatcherInterface|\PHPUnit_Framework_MockObject_MockObject $eventDispatcher */ |
31
|
|
|
$eventDispatcher = $this->getMockBuilder(SymfonyEventDispatcherInterface::class) |
32
|
|
|
->disableOriginalConstructor() |
33
|
|
|
->getMock(); |
34
|
|
|
|
35
|
|
|
$eventDispatcher->expects($this->once()) |
|
|
|
|
36
|
|
|
->method('dispatch'); |
37
|
|
|
|
38
|
|
|
$eventData = new MulticastMessageResponseEvent( |
39
|
|
|
1234567890, |
40
|
|
|
new SuccessfulMessageResultCollection(), |
41
|
|
|
new FailedMessageResultCollection(), |
42
|
|
|
new CanonicalTokenMessageResultCollection() |
43
|
|
|
); |
44
|
|
|
|
45
|
|
|
$symfonyEventDispatcher = new SymfonyEventDispatcher($eventDispatcher); |
46
|
|
|
$symfonyEventDispatcher->dispatch( |
47
|
|
|
FirebaseEvents::MULTICAST_MESSAGE_RESPONSE_EVENT, |
48
|
|
|
$eventData |
49
|
|
|
); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: