/** * Tests that dependencies can be overridden via configuration. */ public function testOverrideDependencies() { $client = $this->getMockClient(); $logger = $this->getMockLogger(); $parser = $this->getMockParser(); $converter = $this->getMockConverter(); $eventQueueFactory = $this->getMockEventQueueFactory(); $config = array('client' => $client, 'logger' => $logger, 'parser' => $parser, 'converter' => $converter, 'eventQueueFactory' => $eventQueueFactory, 'plugins' => array(), 'connections' => array($this->getMockConnection())); $this->bot->setConfig($config); $this->bot->run(); $this->assertSame($client, $this->bot->getClient()); $this->assertSame($logger, $this->bot->getLogger()); $this->assertSame($parser, $this->bot->getParser()); $this->assertSame($converter, $this->bot->getConverter()); $this->assertSame($eventQueueFactory, $this->bot->getEventQueueFactory()); }
/** * Injects the bot's logger into the plugin if it implements * \Psr\Log\LoggerAwareInterface. * * @param \Phergie\Irc\Bot\React\PluginInterface $plugin Loaded plugin * @param \Phergie\Irc\Bot\React\Bot $bot Bot that loaded the plugin */ public function process(PluginInterface $plugin, Bot $bot) { if ($plugin instanceof LoggerAwareInterface) { $plugin->setLogger($bot->getLogger()); } }