public function testTransport() { $transport = new Transport(null, null, null); $hippy = new Hippy($transport); $this->assertEquals(get_class($hippy->getTransport()), 'rcrowe\\Hippy\\Transport\\Guzzle'); $transport = new Transport(null, null, null); $transport->helloWorld = 'egg'; $hippy = new Hippy($transport); $hippy->setTransport($transport); $this->assertEquals($hippy->getTransport()->helloWorld, 'egg'); }
public function testQueuedMessages() { $entity = m::mock('Guzzle\\Http\\Message\\EntityEnclosingRequest'); $entity->shouldReceive('send')->twice(); $http = m::mock('Guzzle\\Http\\Client'); $http->shouldReceive('post')->andReturn($entity)->twice(); $transport = new Guzzle('123', 'cog', 'vivalacrowe'); $transport->setHttp($http); $hippy = new Hippy($transport); $queue = new Queue(); $queue->add(new Message(true, 'red')); $queue->add(new Message(false, 'random')); $hippy->send($queue); }
/** * Send all messages in the queue. * * @throws RuntimeException When Facade::init() has not been called. * @return void */ public static function go() { if (static::$client === null) { throw new RuntimeException('Must call init first'); } static::$client->send(static::$queue); }
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); } }