Commit: 29b3ce9d5a7af68b6a05c9c892c7e1d01314a60b

Author: gwoo | Date: 2010-01-28 21:23:47 -0800
adding tests and fixing Tell plugin
diff --git a/extensions/command/bot/plugins/Tell.php b/extensions/command/bot/plugins/Tell.php index 61abd0a..441acea 100644 --- a/extensions/command/bot/plugins/Tell.php +++ b/extensions/command/bot/plugins/Tell.php @@ -70,6 +70,7 @@ class Tell extends \li3_bot\extensions\command\bot\Plugin { $answer = null; $response = $responses['unknown']; if (isset($tells[$key])) { + $user = $to; $answer = $tells[$key]; $response = $responses['success']; } @@ -105,10 +106,10 @@ class Tell extends \li3_bot\extensions\command\bot\Plugin { protected function _forget($tell) { $model = $this->_classes['model']; - $response = $responses['forget_unknown']; + $response = $this->_responses['forget_unknown']; if ($model::delete($tell)) { - $response = $responses['forgot']; + $response = $this->_responses['forgot']; } return $response; } diff --git a/tests/cases/extensions/command/bot/plugins/TellTest.php b/tests/cases/extensions/command/bot/plugins/TellTest.php index a9cd5a3..c61b9b2 100644 --- a/tests/cases/extensions/command/bot/plugins/TellTest.php +++ b/tests/cases/extensions/command/bot/plugins/TellTest.php @@ -44,7 +44,7 @@ class TellTest extends \lithium\test\Unit { public function tearDown() { unset($this->tell); - unlink(MockTellModel::$path); + $this->_cleanUp(); } public function testProcess() { @@ -68,6 +68,44 @@ class TellTest extends \lithium\test\Unit { 'user' => 'gwoo', 'message' => '~lithium' )); $this->assertEqual($expected, $result); + + $expected = 'bob, lithium is cool'; + $result = $this->tell->process(array( + 'channel' => '#li3', 'nick'=> 'Li3Bot', + 'user' => 'gwoo', 'message' => '~tell bob about lithium' + )); + $this->assertEqual($expected, $result); + + $expected = 'gwoo, I do not know about something'; + $result = $this->tell->process(array( + 'channel' => '#li3', 'nick'=> 'Li3Bot', + 'user' => 'gwoo', 'message' => '~tell bob about something' + )); + $this->assertEqual($expected, $result); + } + + public function testForget() { + MockTellModel::reset(); + $expected = 'gwoo, I will remember lithium'; + $result = $this->tell->process(array( + 'channel' => '#li3', 'nick'=> 'Li3Bot', + 'user' => 'gwoo', 'message' => 'Li3Bot: lithium is cool' + )); + $this->assertEqual($expected, $result); + + $expected = 'gwoo, I forgot about lithium'; + $result = $this->tell->process(array( + 'channel' => '#li3', 'nick'=> 'Li3Bot', + 'user' => 'gwoo', 'message' => '~forget lithium' + )); + $this->assertEqual($expected, $result); + + $expected = 'gwoo, I never knew about lithium'; + $result = $this->tell->process(array( + 'channel' => '#li3', 'nick'=> 'Li3Bot', + 'user' => 'gwoo', 'message' => '~forget lithium' + )); + $this->assertEqual($expected, $result); } }