Skip to content

Instantly share code, notes, and snippets.

@tarmstrong
Created December 5, 2012 21:07
Show Gist options
  • Save tarmstrong/4219498 to your computer and use it in GitHub Desktop.
Save tarmstrong/4219498 to your computer and use it in GitHub Desktop.
Phergie test additional method
<?php
class Phergie_Plugin_PhpTest extends Phergie_Plugin_TestCase
{
/**
* Tests for appropriate plugin requirements.
*
* @return void
*/
public function testPluginRequirements()
{
$this->assertRequiresPlugin('Command');
$this->setConfig('plugin.php.source', 'test');
$this->plugin->onLoad();
}
/**
* Test that the bot will respond with function documentation.
*/
public function testOnCommmandPhp()
{
$this->setConfig('plugin.php.source', 'test');
$this->plugin->onLoad();
$this->initializePhpEvent('array_map');
$this->assertEmitsEvent('privmsg', array($this->source, $this->nick. ': hello'));
$this->plugin->onCommandPhp('array_map');
$this->initializePhpEvent('xxxx');
$this->assertEmitsEvent('notice', array($this->source, 'Search for function xxxx returned no results.'));
$this->plugin->onCommandPhp('xxxx');
}
private function initializePhpEvent($function) {
$args = array(
'receiver' => $this->source,
'text' => 'php ' . $function
);
$event = $this->getMockEvent('privmsg', $args);
$this->plugin->setEvent($event);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment