public function testBasicMethods() { $seed = array('from' => '*****@*****.**', 'to' => '*****@*****.**', 'subject' => 'Howdy yoozi.', 'content' => 'hi there.'); $message = new Message(); foreach ($seed as $key => $val) { $message->{$key}($val); } $this->assertEquals($seed, $message->toArray()); $this->assertEquals(json_encode($seed), $message->toJson()); // For magic methods. $message->from = '*****@*****.**'; $this->assertEquals('*****@*****.**', $message->from); }
public function testObjectEncodeInRealtimeMessageContent() { $object = new Message(); $object->from = 'alice'; $object->to = 'bob'; $object->content = 'love'; $testRealtimeMessage = array('string' => 'hello', 'numeric' => 123, 'object' => $object); $message = new RealtimeMessage(); $message->content($testRealtimeMessage); $testRealtimeMessage['object'] = $object->toArray(); $this->assertEquals($message->content, json_encode($testRealtimeMessage)); // For magic methods. $message->from('*****@*****.**'); $this->assertEquals('*****@*****.**', $message->from); }