/** * 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']); */ }
public function testActivityLifeCycle() { $token = BasicSecurityToken::createFromValues('jane.doe', 'jane.doe', 1, 1, 1, 1, 'default'); $userId = new UserId('owner', null); $userIds = array($userId); $groupId = new GroupId('self', null); $title = 'activity life cycle unit test title'; $activity = array('id' => '1', 'userId' => 'userId', 'title' => $title); $ret = $this->service->getActivities($userIds, $groupId, 1, null, null, null, null, 0, 4, null, 1, $token); $this->assertEquals(2, count($ret->entry)); $this->service->createActivity($userId, $groupId, $token->getAppId(), null, $activity, $token); $ret = $this->service->getActivities($userIds, $groupId, 1, null, null, null, null, 0, 4, null, 1, $token); $this->assertEquals(3, count($ret->entry)); $id = null; foreach ($ret->entry as $entity) { if ($entity['title'] == $title) { $id = $entity['id']; } } $this->assertNotNull($id); $this->service->deleteActivities($userId, $groupId, $token->getAppId(), array($id), $token); $ret = $this->service->getActivities($userIds, $groupId, 1, null, null, null, null, 0, 4, null, 1, $token); $this->assertEquals(2, count($ret->entry)); }