public function testSetText() { $message = new Message(); $message->setText('egg and spoon race'); $this->assertEquals($message->getMessage(), 'egg and spoon race'); $message->setText('<a href="#">hello</a>'); $this->assertEquals($message->getMessage(), '<a href="#">hello</a>'); $this->assertEquals($message->getMessageFormat(), Message::FORMAT_TEXT); }
public function testPlainMessageLength() { $msg = str_pad('', 9999, 'jnk3j1'); $message = new Message(); $message->setText($msg); $msg = str_pad('', 10000, 'jnk3j1'); $message = new Message(); $message->setText($msg); try { $msg = str_pad('', 10001, 'jnk3j1'); $message = new Message(); $message->setText($msg); $this->assertFalse(true); } catch (InvalidArgumentException $ex) { $this->assertEquals($ex->getMessage(), 'Message more than 10,000 characters'); } catch (Exception $ex) { $this->assertFalse(true); } }
public function main($transport = null) { $transport or $transport = new Guzzle($this->getToken(), $this->getRoom(), $this->getFrom()); $client = new Client($transport); foreach ($this->msgStore as $msg) { $message = new Message($this->getNotify(), $this->getBackground()); switch ($msg['format']) { case Message::FORMAT_TEXT: $message->setText($msg['msg']); break; case Message::FORMAT_HTML: $message->setHtml($msg['msg']); break; default: throw new BuildException('Unknown message format'); } $client->send($message); } }
public function testQueueIteratorInterface() { $values = array('RC', 'Dog', 'Cat', 'Carrot Cake'); foreach ($values as $value) { $message = new Message(); $message->setText($value); $this->queue->add($message); } foreach ($this->queue as $value) { $this->assertTrue(in_array($value->getMessage(), $values)); } foreach ($this->queue as $key => $value) { $this->assertTrue(is_integer($key)); $this->assertEquals($value->getMessage(), $values[$key]); } }
/** * Add a plain text message to the queue. * * @param string $msg * @param bool $notify * @param string $background * @throws RuntimeException When Facade::init() has not been called. * @return void */ public static function add($msg, $notify = false, $background = Message::BACKGROUND_YELLOW) { if (static::$client === null) { throw new RuntimeException('Must call init first'); } $message = new Message($notify, $background); $message->setText($msg); static::$queue->add($message); }