예제 #1
0
 /**
  * Ensures that newsSearch() throws an exception when the language option is invalid
  *
  * @return void
  */
 public function testNewsSearchExceptionLanguageInvalid()
 {
     try {
         $this->_yahoo->newsSearch('php', array('language' => 'oops'));
         $this->fail('Expected Zend_Service_Exception not thrown');
     } catch (Zend_Service_Exception $e) {
         $this->assertContains('selected language', $e->getMessage());
     }
 }
예제 #2
0
 /**
  * Ensures that newsSearch() works as expected when searching for 'php'
  *
  * @return void
  */
 public function testNewsSearchPhp()
 {
     $newsResultSet = $this->_yahoo->newsSearch('php');
     $this->assertTrue($newsResultSet instanceof Zend_Service_Yahoo_NewsResultSet);
     $this->assertTrue($newsResultSet->totalResultsAvailable > 10);
     $this->assertEquals(10, $newsResultSet->totalResultsReturned);
     $this->assertEquals(10, $newsResultSet->totalResults());
     $this->assertEquals(1, $newsResultSet->firstResultPosition);
     foreach ($newsResultSet as $newsResult) {
         $this->assertTrue($newsResult instanceof Zend_Service_Yahoo_NewsResult);
     }
 }
            foreach ($results as $result) {
                echo "<a href='{$result->ClickUrl}' title='{$result->Title}'><img src='{$result->Thumbnail->Url->getUri()}'></a>";
            }
            echo '</div>';
        }
        $results = $yahoo->webSearch($keywords);
        if ($results->totalResults() > 0) {
            echo '<div id="web">';
            echo '<h2>Web Search Results</h2>';
            foreach ($results as $result) {
                echo "<h3><a href='{$result->ClickUrl}'>{$result->Title}</a></h3>";
                echo "<p>{$result->Summary} <br> [<a href='{$result->CacheUrl}'>Cached Version</a>]</p>";
            }
            echo '</div>';
        }
        $results = $yahoo->newsSearch($keywords);
        if ($results->totalResults() > 0) {
            echo '<div id="news">';
            echo '<h2>News Search Results</h2>';
            foreach ($results as $result) {
                echo "<h3><a href='{$result->ClickUrl}'>{$result->Title}</a></h3>";
                echo "<p>{$result->Summary}</p>";
            }
            echo '</div>';
        }
    } catch (Zend_Service_Exception $e) {
        echo '<p style="color: red; font-weight: bold">An error occured, please try again later.</p>';
    }
}
?>
<p id="poweredby" style="text-align: center; font-size: 9px;">Powered by the <a href="http://framework.zend.com">Zend Framework</a></p>