/** * Converts price from one currency to another * * @param object $user User Object * @param array $msg Message Array * * @return void */ private function command_convert($user, $msg) { // if sufficient params are given if (count($msg) == 4 && is_numeric($msg[3])) { // currency conversion $price = $this->_priceMarket->convert($msg[1], $msg[2], $msg[3]); // broadcast conversion result $this->internalSendMessage($price); } else { // message $outputMsg = 'Convert example: (!convert|cv btc usd 0.1) will convert 1 btc to usd price :)'; // show command usage $this->internalSendMessage($outputMsg, true, $user); } }
/** * Tests the conversion. * * @param string $text A text. * @param string $expected An expected result. * * @return void * * @dataProvider dataForConversion */ public function testConversion($text, $expected) { $actual = $this->bbcode->convert($text); $this->assertEquals($expected, $actual); }