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

ApplicationTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
lcom 0
cbo 5
dl 0
loc 32
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B testLoadTopicThrowExceptionWhenImplementingTheWrongEventDispatcherInterface() 0 29 1
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