示例#1
0
 /**
  * @NoAdminRequired
  * @return JSONResponse
  */
 public function initVar()
 {
     session_write_close();
     $this->greet->setRequestData(array("timestamp" => time(), "user" => $this->app->getCurrentUser()));
     $sessionId = $this->greet->execute();
     $contacts = $this->app->getContacts();
     $backends = $this->app->getBackends();
     $backendsToArray = array();
     foreach ($backends as $backend) {
         $backendsToArray[$backend->getId()] = $backend->toArray();
     }
     $initConvs = $this->app->getInitConvs();
     return array("contacts" => $contacts['contacts'], "contactsList" => $contacts['contactsList'], "contactsObj" => $contacts['contactsObj'], "backends" => $backendsToArray, "initConvs" => $initConvs, "sessionId" => $sessionId['session_id'], "avatars_enabled" => $this->config->getSystemValue('enable_avatars', true));
 }
示例#2
0
文件: Greet.php 项目: arun-TK/chat
 public function testUserOnlineMapperInsert()
 {
     $this->container['UserOnlineMapper'] = $this->getMockBuilder('\\OCA\\Chat\\OCH\\Db\\UserOnlineMapper')->disableOriginalConstructor()->getMock();
     $this->container['UserOnlineMapper']->expects($this->any())->method('insert')->will($this->returnCallback(function ($userOnline) {
         GreetTest::$userOnline = $userOnline;
     }));
     $time = time();
     $greet = new Greet($this->container);
     $greet->setRequestData(array('timestamp' => $time, 'user' => array('id' => 'admin', 'online' => false, 'displayname' => 'admin', 'backends' => array('och' => array('id' => NULL, 'displayname' => 'ownCloud Handle', 'protocol' => 'x-owncloud-handle', 'namespace' => 'och', 'value' => 'admin')), 'address_book_id' => 'admin', 'address_book_backend' => 'localusers')));
     $greet->execute();
     $expectedUserOnline = new UserOnline();
     $expectedUserOnline->setUser('admin');
     $expectedUserOnline->setSessionId(md5("sessionID" . $time));
     $expectedUserOnline->setLastOnline($time);
     $this->assertEquals($expectedUserOnline, GreetTest::$userOnline);
 }