Example #1
0
 public function testGetUser()
 {
     $item = new Conversation();
     $user = User::fromResponse(array('id' => 1));
     $item->user = $user;
     $this->assertInstanceOf(User::class, $item->user);
     $this->assertEquals($user, $item->user);
 }
Example #2
0
 public function testGetPresences()
 {
     $this->assertEquals(['online', 'idle', 'offline'], User::getPresences());
 }
Example #3
0
 /**
  * Set user status.
  *
  * @param int $id - userId
  * @param string $presence - status
  * @param string $sessionId - session id
  *
  * @throws InvalidArgumentException
  * @throws Exception
  */
 public function setPresence($id, $presence, $sessionId)
 {
     if ($this->isEmptyId($id)) {
         throw new InvalidArgumentException();
     }
     if (!in_array($presence, User::getPresences())) {
         throw new InvalidArgumentException();
     }
     if (!$sessionId) {
         throw new InvalidArgumentException();
     }
     $params = ['presence' => $presence, 'session' => $sessionId];
     $this->call('users/' . $id . '/setpresence', $params, 'post');
 }
Example #4
0
 public function testGetFrom()
 {
     $item = new Message();
     $from = User::fromResponse(array('id' => 1));
     $item->from = $from;
     $this->assertInstanceOf(User::class, $item->from);
     $this->assertEquals($from, $item->from);
 }