/** * Tests escaping messages. */ public function testEscapeParam() { $toTest = ["one\r\ntwo", "one\rtwo", "one\ntwo", "one two"]; $expected = "one two"; foreach ($toTest as $test) { $this->assertSame($expected, $this->plugin->escapeParam($test)); } }
/** * Sets the event emitter for the implementing class to use. * * @see \Phergie\Irc\Bot\React\EventEmitterAwareInterface::setEventEmitter() * @param \Evenement\EventEmitterInterface $emitter */ public function setEventEmitter(EventEmitterInterface $emitter) { parent::setEventEmitter($emitter); foreach ($this->getHooks() as $hook => $info) { if ($info['handler'] instanceof EventEmitterAwareInterface) { $info['handler']->setEventEmitter($emitter); } } }
/** * Sets the event loop instance. * * @param \React\EventLoop\LoopInterface $loop * * @todo find some way to do a unit test for this method */ public function setLoop(LoopInterface $loop) { parent::setLoop($loop); \React\Promise\Timer\timeout(MessengerFactory::parentFromClass('PSchwisow\\Phergie\\Plugin\\Karma\\ChildProcess', $loop), 10.0, $loop)->then(function (Messenger $messenger) use($loop) { $this->logDebug('got a messenger'); $this->messenger = $messenger; $messenger->on('error', function ($e) { $this->logDebug('Error: ' . var_export($e, true)); }); $this->messenger->rpc(MessageFactory::rpc('config', $this->config))->then(function ($payload) { $this->logDebug('configuration sent to child. Response: ' . var_export($payload, true)); }); }, function ($error) { if ($error instanceof \React\Promise\Timer\TimeoutException) { // the operation has failed due to a timeout $this->logDebug('TIMEOUT'); } else { // the input operation has failed due to some other error $this->logDebug('OTHER ERROR'); } }); }
/** * Injects the event emitter into the adapter. * * @param \Evenement\EventEmitterInterface $emitter */ public function setEventEmitter(EventEmitterInterface $emitter) { parent::setEventEmitter($emitter); $this->adapter->setEventEmitter($emitter); }
/** * Set Loop Interface * @param LoopInterface $loop */ public function setLoop(LoopInterface $loop) { parent::setLoop($loop); foreach ($this->plugins as $plugin) { if (!$plugin instanceof LoopAwareInterface) { continue; } $plugin->setLoop($loop); } }