Sets the event loop dependency.
public setLoop ( React\EventLoop\LoopInterface $loop ) | ||
$loop | React\EventLoop\LoopInterface |
/** * @param ConstructEvent $event */ public function construct(ConstructEvent $event) { $client = new Client(); $client->setLoop($event->getLoop()); $bot = new Bot(); $bot->setConfig(Configure::read('WyriHaximus.Phergie.config')); $bot->setClient($client); $bot->run(false); EventManager::instance()->dispatch(StartEvent::create($event->getLoop(), $bot)); }
/** * Tests that the client emits a periodic event per connection. */ public function testTickCallback() { $connection = $this->getMockConnectionForAddConnection(); $logger = $this->getMockLogger(); $loop = $this->getMockLoop(); $writeStream = $this->getMockWriteStream(); $timer = $this->getMockTimer(); Phake::when($this->client)->getWriteStream($connection)->thenReturn($writeStream); Phake::when($loop)->addPeriodicTimer(0.2, $this->isType('callable'))->thenReturn($timer); $this->client->setLoop($loop); $this->client->setLogger($logger); $this->client->setResolver($this->getMockResolver()); $this->client->addConnection($connection); Phake::verify($loop)->addPeriodicTimer(0.2, Phake::capture($callback)); $callback(); Phake::verify($this->client)->emit('irc.tick', Phake::capture($params)); $this->assertInternalType('array', $params); $this->assertCount(3, $params); $this->assertSame($writeStream, $params[0]); $this->assertSame($connection, $params[1]); $this->assertSame($logger, $params[2]); }