/** * @covers \Gamma\Pushpin\PushpinBundle\Services\Events\Json\EventFactory::getEvent */ public function testGetJsonEvents() { $event = new WebSocketEvent('TEXT', 'testAction:{ "string":"test string", "bool":true, "int":150, "float":150.9999, "array": { "key":"value" } }'); $jsonEvent = self::$instance->getEvent($event); static::assertInstanceOf('Gamma\\Pushpin\\PushpinBundle\\Tests\\Utils\\Events\\SimpleJsonEvent', $jsonEvent); static::assertEquals('testAction', $jsonEvent->getName()); static::assertEquals('test string', $jsonEvent->string); static::assertEquals(true, $jsonEvent->bool); static::assertEquals(150, $jsonEvent->int); static::assertEquals(150.9999, $jsonEvent->float); static::assertEquals(['key' => 'value'], $jsonEvent->array); static::assertTrue($jsonEvent->hasSubtypes()); }
private static function addJsonEventFactory() { $jsonFactory = new EventFactory(new EventParser(), new EventSerializer()); $jsonFactory->configure('Gamma\\Pushpin\\PushpinBundle\\Tests\\Utils\\Events', ['testAction' => ['class' => 'SimpleJsonEvent']]); self::$instance->addFactory($jsonFactory); }