Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Commit

Permalink
Merge pull request #43 from WyriHaximus/patch-1
Browse files Browse the repository at this point in the history
Add autorun argument to run
  • Loading branch information
svpernova09 committed Mar 7, 2016
2 parents d8587c5 + eb91d00 commit 11ecece
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 35 deletions.
16 changes: 1 addition & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,12 @@
},
"require": {
"php": ">=5.5",
"phergie/phergie-irc-client-react": "~3",
"phergie/phergie-irc-client-react": "~3.1",
"phergie/phergie-irc-connection": "~2.0",
"phergie/phergie-irc-event": "~1.0",
"evenement/evenement": "~2.0",
"monolog/monolog": "~1.6"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/phergie/phergie-irc-client-react"
},
{
"type": "vcs",
"url": "https://github.com/phergie/phergie-irc-connection"
},
{
"type": "vcs",
"url": "https://github.com/phergie/phergie-irc-event"
}
],
"require-dev": {
"phergie/phergie-irc-bot-react-development": "~1.0"
},
Expand Down
26 changes: 8 additions & 18 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/Bot.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,17 @@ public function getEventQueueFactory()
* Initiates an event loop for the bot in which it will connect to servers
* and monitor those connections for events to forward to plugins.
*
* @param bool $autorun
*
* @throws \RuntimeException if configuration is inconsistent with
* expected structure
*/
public function run()
public function run($autorun = true)
{
$this->setDependencyOverrides($this->config);
$this->getPlugins($this->config);
$connections = $this->getConnections($this->config);
$this->getClient()->run($connections);
$this->getClient()->run($connections, $autorun);
}

/**
Expand Down
28 changes: 28 additions & 0 deletions tests/BotTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,34 @@ public function testOverrideDependencies()
$this->assertSame($eventQueueFactory, $this->bot->getEventQueueFactory());
}

/**
* Tests that autorun flag is passed to the underlying client.
*/
public function testAutorunOff()
{
$client = $this->getMockClient();
$logger = $this->getMockLogger();
$parser = $this->getMockParser();
$converter = $this->getMockConverter();
$eventQueueFactory = $this->getMockEventQueueFactory();

$config = [
'client' => $client,
'logger' => $logger,
'parser' => $parser,
'converter' => $converter,
'eventQueueFactory' => $eventQueueFactory,
'plugins' => [],
'connections' => [ $this->getMockConnection() ],
];

$this->bot->setConfig($config);

$this->bot->run(false);

Phake::verify($client)->run($this->isType('array'), false);
}

/*** SUPPORTING METHODS ***/

/**
Expand Down

0 comments on commit 11ecece

Please sign in to comment.