Ejemplo n.º 1
0
 public function __construct()
 {
     $db = new JsonDbOpensocialService();
     $db->resetDb();
     $this->securityToken = BasicSecurityToken::createFromValues(1, 1, 1, 'partuza', 'test.com', 1, 0)->toSerialForm();
     $this->securityToken = urldecode($this->securityToken);
     $this->restUrl = 'http://localhost' . Config::get('web_prefix') . '/social/rest';
 }
 /**
  * Tests JsonDbOpensocialService->getActivities() with paging.
  */
 public function testGetActivities()
 {
     $token = BasicSecurityToken::createFromValues('jane.doe', 'jane.doe', 1, 1, 1, 1);
     $userId = new UserId('owner', null);
     $userIds = array($userId);
     $groupId = new GroupId('self', null);
     $startIndex = 1;
     $count = 1;
     $ret = $this->service->getActivities($userIds, $groupId, 1, null, null, null, null, $startIndex, $count, null, 1, $token);
     $this->assertEquals($startIndex, $ret->startIndex);
     $this->assertEquals($count, count($ret->entry));
     $this->assertEquals(2, $ret->totalResults);
     $this->assertEquals('2', $ret->entry[0]['id']);
     $this->assertEquals('Jane says George likes yoda!', $ret->entry[0]['title']);
     $this->assertEquals('or is it you?', $ret->entry[0]['body']);
 }
 /**
  * Tests JsonDbOpensocialService->createActivity()
  */
 public function testCreateActivity()
 {
     $userId = new UserId('viewer', null);
     $groupId = new GroupId('self', null);
     $token = BasicSecurityToken::createFromValues('john.doe', 'john.doe', 'app', 'domain', 'appUrl', '1');
     $activity = array();
     $activity['id'] = 2;
     $activity['title'] = 'John Doe wrote: asdasd';
     $activity['body'] = 'write back!';
     $activity['mediaItems'] = array();
     $activity['mediaItems'][0]['type'] = 'image';
     $activity['mediaItems'][0]['mimeType'] = 'image';
     $activity['mediaItems'][0]['image'] = 'http://cdn.davesdaily.com/pictures/784-awesome-hands.jpg';
     $this->JsonDbOpensocialService->createActivity($userId, $activity, $token);
     /*		
     		//Validating the created activity
     		$token = BasicSecurityToken::createFromValues('john.doe', 'john.doe', 'app', 'domain', 'appUrl', '1');
     		$responseItem = $this->JsonDbOpensocialService->getActivity($userId, $groupId, 2, null, null, $token);
     		$entry = $responseItem->getResponse();
     		$this->assertEquals(2, $entry['id']);
     		$this->assertEquals('John Doe wrote: asdasd', $entry['title']);
     		$this->assertEquals('write back!', $entry['body']);
     		$this->assertEquals('image', $activity['mediaItems'][0]['type']);
     		$this->assertEquals('image', $activity['mediaItems'][0]['mimeType']);
     		$this->assertEquals('http://cdn.davesdaily.com/pictures/784-awesome-hands.jpg', $activity['mediaItems'][0]['image']);
     		$this->assertEquals('app', $entry['appId']);
     */
 }
Ejemplo n.º 4
0
 public function testGetMessageCollections()
 {
     $token = BasicSecurityToken::createFromValues('john.doe', 'john.doe', 1, 1, 1, 1, 'default');
     $userId = new UserId('owner', null);
     $ret = $this->service->getMessageCollections($userId, MessageCollection::$DEFAULT_FIELDS, null, $token);
     $this->assertEquals('Notifications', $ret->entry[0]['title']);
     $this->assertEquals('notification', $ret->entry[0]['id']);
     $this->assertEquals(2, $ret->entry[0]['total']);
     $this->assertEquals('Inbox', $ret->entry[1]['title']);
     $this->assertEquals('privateMessage', $ret->entry[1]['id']);
     $this->assertEquals(0, $ret->entry[1]['total']);
     $this->assertEquals('Inbox', $ret->entry[2]['title']);
     $this->assertEquals('publicMessage', $ret->entry[2]['id']);
     $this->assertEquals(0, $ret->entry[2]['total']);
 }