public function testEmptyProfileEntryToAndFromStringShouldMatch() { $this->entry->transferFromXML($this->entryText); $entryXml = $this->entry->saveXML(); $newProfileEntry = new Health\ProfileEntry(); $newProfileEntry->transferFromXML($entryXml); $newProfileEntryXML = $newProfileEntry->saveXML(); $this->assertTrue($entryXml == $newProfileEntryXML); }
public function testSendNoticeWithoutCcrUsingDirectInsert() { $this->setupProfileID(); $profileID = $this->health->getProfileID(); $subject = "Title of your notice goes here"; $body = "Notice body goes here"; $entry = new Health\ProfileEntry(); $author = $this->health->newAuthor(); $author->name = $this->health->newName('John Doe'); $author->email = $this->health->newEmail('*****@*****.**'); $entry->setAuthor(array(0 => $author)); $entry->title = $this->health->newTitle($subject); $entry->content = $this->health->newContent($body); $entry->content->type = 'text'; $ccrXML = file_get_contents('Zend/GData/Health/_files/ccr_notice_sample.xml', true); $entry->setCcr($ccrXML); $uri = "https://www.google.com/health/feeds/register/ui/{$profileID}"; $responseEntry = $this->health->insertEntry($entry, $uri, '\\Zend\\GData\\Health\\ProfileEntry'); $this->assertTrue($responseEntry instanceof Health\ProfileEntry); $this->assertEquals($subject, $responseEntry->title->text); $this->assertEquals($author->name->text, 'John Doe'); $this->assertEquals($author->email->text, '*****@*****.**'); $this->assertEquals($body, $responseEntry->content->text); }
/** * Posts a new notice using the register feed. This function constructs * the atom profile entry. * * @param string $subject The subject line of the notice * @param string $body The message body of the notice * @param string $bodyType The (optional) type of message body * (text, xhtml, html, etc.) * @param string $ccrXML The (optional) CCR to add to the user's profile * @return \Zend\GData\Health\ProfileEntry */ public function sendHealthNotice($subject, $body, $bodyType = null, $ccrXML = null) { if ($this->_httpClient->getClientLoginToken()) { $profileID = $this->getProfileID(); if ($profileID !== null) { $uri = self::CLIENTLOGIN_REGISTER_FEED_URI . '/' . $profileID; } else { throw new App\AuthException('Profile ID must not be null. Did you call setProfileID()?'); } } else { $uri = self::AUTHSUB_REGISTER_FEED_URI; } $entry = new ProfileEntry(); $entry->title = $this->newTitle($subject); $entry->content = $this->newContent($body); $entry->content->type = $bodyType ? $bodyType : 'text'; $entry->setCcr($ccrXML); // use correct feed for /h9 or /health if ($this->_useH9Sandbox) { $uri = preg_replace('/\\/health\\//', '/h9/', $uri); } return $this->insertEntry($entry, $uri, '\\Zend\\GData\\Health\\ProfileEntry'); }