public function testSubscribeErrorInvalidParameters()
 {
     $subscribe_xml = file_get_contents(dirname(__FILE__) . '/data/savedsearch_error_invalid_parameters.xml');
     $this->oauthClient->expects($this->once())->method('authenticatedPostAsXml')->with('savedSearch/subscribe', $this->savedSearch->toPostData())->will($this->returnValue($subscribe_xml));
     $this->setExpectedException('CultureFeed_Exception', '\'name\' is a required parameter');
     $this->savedSearches->subscribe($this->savedSearch);
 }
Beispiel #2
0
 /**
  * {@inheritdoc}
  */
 public function subscribe(CultureFeed_SavedSearches_SavedSearch $savedSearch, $use_auth = TRUE)
 {
     if ($use_auth) {
         $result = $this->oauth_client->authenticatedPostAsXml('savedSearch/subscribe', $savedSearch->toPostData());
     } else {
         $result = $this->oauth_client->consumerPostAsXml('savedSearch/subscribe', $savedSearch->toPostData());
     }
     $xml_element = $this->getXmlElementFromXmlString($result);
     $search_element = $xml_element->xpath('/response/savedSearch');
     if (empty($search_element)) {
         $this->throwXmlElementException($xml_element, $result);
     }
     return $this->parseSavedSearch($search_element[0]);
 }
 public function testSavedSearchToPostData()
 {
     $saved_search = new SavedSearch();
     // Expect an empty array with certain keys and empty values.
     $expected = array('id' => NULL, 'userId' => NULL, 'name' => NULL, 'query' => NULL, 'frequency' => NULL);
     $this->assertEquals($expected, $saved_search->toPostData());
     // Set data and test if we receive the same data.
     $saved_search->id = 123456;
     $saved_search->userId = 123789;
     $saved_search->name = 'The name';
     $saved_search->query = 'The string';
     $saved_search->frequency = SavedSearch::ASAP;
     $expected = array('id' => 123456, 'userId' => 123789, 'name' => 'The name', 'query' => 'The string', 'frequency' => SavedSearch::ASAP);
     $this->assertEquals($expected, $saved_search->toPostData());
 }