curlRest($url, $postData, $postDataFormat); $this->assertTrue(empty($ret), "Create activity failed. Response: $ret"); // Verifyies data was written correctly $ret = $this->curlRest($url . '?count=20', '', 'application/json', 'GET'); $retDecoded = json_decode($ret, true); $this->assertTrue($ret != $retDecoded && $ret != null, "Invalid json string in return: $ret"); // Sees if we can find our just created activity $activityId = null; foreach ($retDecoded['entry'] as $entry) { if ($entry['title'] == $randomTitle) { $activityId = $entry['id']; break; } } $this->assertNotNull($activityId, "Couldn't find created activity."); $ret = $this->curlRest($url . "/@app/$activityId", '', 'application/json', 'DELETE'); $this->assertTrue(empty($ret), "Delete activity failed. Repsonse: $ret"); } public function testLifeCycleInJson() { $randomTitle = "[" . rand(0, 2048) . "] test activity"; $postData = '{ "id" : "http://example.org/activities/example.org:87ead8dead6beef/self/af3778", "title" : "' . $randomTitle . '", "updated" : "2008-02-20T23:35:37.266Z", "body" : "Some details for some activity", "bodyId" : "383777272", "url" : "http://api.example.org/activity/feeds/.../af3778", "userId" : "example.org:34KJDCSKJN2HHF0DW20394" }'; $this->verifyLifeCycle($postData, 'application/json', $randomTitle); } public function testLifeCycleInAtom() { $randomTitle = "[" . rand(0, 2048) . "] test activity"; $postData = ' http://example.org/activities/example.org:87ead8dead6beef/self/af3778 ' . $randomTitle . ' Some details for some activity 2008-02-20T23:35:37.266Z urn:guid:example.org:34KJDCSKJN2HHF0DW20394 383777272 '; $this->verifyLifeCycle($postData, 'application/atom+xml', $randomTitle); } public function testLifeCycleInXml() { $randomTitle = "[" . rand(0, 2048) . "] test activity"; $postData = ' http://example.org/activities/example.org:87ead8dead6beef/self/af3778 ' . $randomTitle . ' 2008-02-20T23:35:37.266Z Some details for some activity 383777272 http://api.example.org/activity/feeds/.../af3778 example.org:34KJDCSKJN2HHF0DW20394 '; $this->verifyLifeCycle($postData, 'application/xml', $randomTitle); } }