/** * Test if the calendar date property is correctly added to the post data. */ public function testCalendarDateToPostData() { $activity = new CultureFeed_Activity(); $result = $activity->toPostData(); $this->assertFALSE(array_key_exists('calendarDate', $result)); $activity->calendarDate = '2011-07-25T22:03Z'; $result = $activity->toPostData(); $this->assertTRUE(array_key_exists('calendarDate', $result)); }
/** * Create a new activity. * * The object should be initialized with the consumer token and user access token of the user who is acted upon. * * @param CultureFeed_Activity $activity * The activity to create. * * @return CultureFeed_Activity * * @throws CultureFeed_ParseException * If the result could not be parsed. */ public function createActivity(CultureFeed_Activity $activity) { $data = $activity->toPostData(); $result = $this->oauth_client->authenticatedPostAsXml('activity', $data); try { $xml = new CultureFeed_SimpleXMLElement($result); } catch (Exception $e) { throw new CultureFeed_ParseException($result); } $id = $xml->xpath_str('/response/activityId'); if (!empty($id)) { $activity->id = $id; $activityPoints = $xml->xpath('/response/activityPointsList/activityPoints'); if (!empty($activityPoints)) { $activity->newTotalPoints = $activityPoints[0]->xpath_float('newTotalPoints'); $activity->points = $activityPoints[0]->xpath_float('savedPoints'); $activity->userpointsUserId = $activityPoints[0]->xpath_str('uitIdUser/rdf:id'); } return $activity; } throw new CultureFeed_ParseException($result); }