Completed
Push — master ( 6435a2...ebbf46 )
by Julien
01:57
created

testLoadTopicThrowExceptionWhenImplementingTheWrongEventDispatcherInterface()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 29
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 29
rs 8.8571
c 1
b 0
f 0
cc 1
eloc 18
nc 1
nop 0
1
<?php
2
3
namespace Eole\Sandstone\Tests\Unit\Websocket;
4
5
use Eole\Sandstone\Serializer\ServiceProvider as SerializerServiceProvider;
6
use Eole\Sandstone\Websocket\Routing\TopicRouter;
7
use Eole\Sandstone\Websocket\Application as WebsocketApplication;
8
use Eole\Sandstone\Application;
9
10
class ApplicationTest extends \PHPUnit_Framework_TestCase
11
{
12
    public function testLoadTopicThrowExceptionWhenImplementingTheWrongEventDispatcherInterface()
13
    {
14
        $app = new Application();
15
        $websocketAppClass = new \ReflectionClass(WebsocketApplication::class);
16
        $method = $websocketAppClass->getMethod('loadTopic');
17
        $method->setAccessible(true);
18
        $websocketApp = $websocketAppClass->newInstance($app);
19
20
        $app->register(new SerializerServiceProvider());
21
22
        $app['sandstone.websocket.router'] = function () {
23
            $wrongTopic = new WrongTopic('my-topic');
24
            $topicRouterMock = $this->getMockBuilder(TopicRouter::class)->disableOriginalConstructor()->getMock();
25
26
            $topicRouterMock
27
                ->method('loadTopic')
28
                ->willReturn($wrongTopic)
29
            ;
30
31
            return $topicRouterMock;
32
        };
33
34
        $this->setExpectedExceptionRegExp(
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCa...pectedExceptionRegExp() has been deprecated with message: Method deprecated since Release 5.6.0; use expectExceptionMessageRegExp() instead

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

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

Loading history...
35
            \LogicException::class,
36
            '/WrongTopic seems to implements the wrong EventSubscriberInterface/'
37
        );
38
39
        $method->invokeArgs($websocketApp, ['my-topic']);
40
    }
41
}
42