-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throw an exception when Topic implements the wrong EventSubscriberInt…
…erface
- Loading branch information
Showing
4 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/Unit/EventForwarderTest.php → tests/Unit/Push/EventForwarderTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Eole\Sandstone\Tests\Unit\Websocket; | ||
|
||
use Eole\Sandstone\Serializer\ServiceProvider as SerializerServiceProvider; | ||
use Eole\Sandstone\Websocket\Routing\TopicRouter; | ||
use Eole\Sandstone\Websocket\Application as WebsocketApplication; | ||
use Eole\Sandstone\Application; | ||
|
||
class ApplicationTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testLoadTopicThrowExceptionWhenImplementingTheWrongEventDispatcherInterface() | ||
{ | ||
$app = new Application(); | ||
$websocketAppClass = new \ReflectionClass(WebsocketApplication::class); | ||
$method = $websocketAppClass->getMethod('loadTopic'); | ||
$method->setAccessible(true); | ||
$websocketApp = $websocketAppClass->newInstance($app); | ||
|
||
$app->register(new SerializerServiceProvider()); | ||
|
||
$app['sandstone.websocket.router'] = function () { | ||
$wrongTopic = new WrongTopic('my-topic'); | ||
$topicRouterMock = $this->createMock(TopicRouter::class); | ||
|
||
$topicRouterMock | ||
->method('loadTopic') | ||
->willReturn($wrongTopic) | ||
; | ||
|
||
return $topicRouterMock; | ||
}; | ||
|
||
$this->expectException(\LogicException::class); | ||
$this->expectExceptionMessage('WrongTopic seems to implements the wrong EventSubscriberInterface'); | ||
|
||
$method->invokeArgs($websocketApp, ['my-topic']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace Eole\Sandstone\Tests\Unit\Websocket; | ||
|
||
use JMS\Serializer\EventDispatcher\EventSubscriberInterface; | ||
use Eole\Sandstone\Websocket\Topic; | ||
|
||
class WrongTopic extends Topic implements EventSubscriberInterface | ||
{ | ||
public static function getSubscribedEvents() | ||
{ | ||
return []; | ||
} | ||
} |