/** * Overrides the parent class to set the poll time. * * @param Phergie_Bot $bot Main bot class * @param array $options Processor arguments * * @return void */ public function __construct(Phergie_Bot $bot, array $options) { if (!$bot->getDriver() instanceof Phergie_Driver_Streams) { throw new Phergie_Process_Exception('The Async event processor requires the Streams driver'); } foreach (array('sec', 'usec') as $var) { if (isset($options[$var])) { if (!is_int($options[$var])) { throw new Phergie_Process_Exception('Processor option "' . $var . '" must be an integer'); } $this->{$var} = $options[$var]; } } if (!isset($this->sec) && !isset($this->usec)) { throw new Phergie_Process_Exception('One of the processor options "sec" or "usec" must be specified'); } parent::__construct($bot, $options); }
/** * Tests that the bot handles events when a connection is present. * * @return void */ public function testRunHandlesEvents() { $this->injectDependencies(); $connections = $this->getMockConnectionHandler(); $connections->expects($this->exactly(2))->method('count')->will($this->onConsecutiveCalls(1, 0)); $ui = $this->getMockUi(); $ui->expects($this->once())->method('onShutdown'); $processor = $this->getMockProcessor($this->bot); $processor->expects($this->once())->method('handleEvents'); $this->bot->run(); }
/** * Gets the required class refences from Phergie_Bot. * * @param Phergie_Bot $bot Current bot instance in use * @param array $options Optional processor arguments * * @return void */ public function __construct(Phergie_Bot $bot, array $options = array()) { $this->driver = $bot->getDriver(); $this->plugins = $bot->getPluginHandler(); $this->connections = $bot->getConnectionHandler(); $this->events = $bot->getEventHandler(); $this->ui = $bot->getUi(); $this->options = $options; }
* It is also available through the world-wide-web at this URL: * http://phergie.org/license * * @category Phergie * @package Phergie * @author Phergie Development Team <*****@*****.**> * @copyright 2008-2010 Phergie Development Team (http://phergie.org) * @license http://phergie.org/license New BSD License * @link http://pear.phergie.org/package/Phergie */ /** * @see Phergie_Autoload */ require 'Phergie/Autoload.php'; Phergie_Autoload::registerAutoloader(); $bot = new Phergie_Bot(); if (!isset($argc)) { echo 'The PHP setting register_argc_argv must be enabled for Phergie ', 'configuration files to be specified using command line arguments; ', 'defaulting to Settings.php in the current working directory', PHP_EOL; } else { if ($argc > 0) { // Skip the current file for manual installations // ex: php phergie.php Settings.php if (realpath($argv[0]) == __FILE__) { array_shift($argv); } // If configuration files were specified, override default behavior if (count($argv) > 0) { $config = new Phergie_Config(); foreach ($argv as $file) { $config->read($file); }