From 3816cccb0c5fbf6986822d78deba558178406d8a Mon Sep 17 00:00:00 2001 From: Martin Jansen Date: Wed, 4 Oct 2006 14:43:19 +0000 Subject: [PATCH] * Added three more tests. git-svn-id: http://svn.php.net/repository/pear/packages/Services_Yahoo/trunk@221121 c90b9560-bf6c-de11-be94-00142212c4b1 --- Yahoo/Tests/Search.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Yahoo/Tests/Search.php b/Yahoo/Tests/Search.php index ae7ad26..7645a6c 100755 --- a/Yahoo/Tests/Search.php +++ b/Yahoo/Tests/Search.php @@ -83,6 +83,16 @@ public function testWithResults20() { $this->assertEquals(20, $result->getTotalResultsReturned()); } + public function testWithResultsBoundaries() { + $client = Services_Yahoo_Search::factory("web"); + + $result = $client->withResults(-1)->searchFor("Madonna"); + $this->assertEquals(10, $result->getTotalResultsReturned()); + + $result = $client->withResults(51)->searchFor("Madonna"); + $this->assertEquals(10, $result->getTotalResultsReturned()); + } + public function testStartingAt() { $client = Services_Yahoo_Search::factory("web"); @@ -126,4 +136,30 @@ public function testOnSites() { $this->matchesRegularExpression("~^pecl\.php\.net~"))); } } + + public function testNewsSortedBy() { + $client = Services_Yahoo_Search::factory("news"); + + $results = $client->sortedBy("date")->searchFor("Madonna"); + + $lastDate = 0; + foreach ($results as $result) { + if ($lastDate == 0) { + $lastDate = $result['PublishDate']; + } + + $this->assertTrue($result['PublishDate'] <= $lastDate); + $lastDate = $result['PublishDate']; + } + } + + public function testNewsInLanguage() { + $client = Services_Yahoo_Search::factory("news"); + + $results = $client->inLanguage("sv")->searchFor("Madonna"); + + foreach ($results as $result) { + $this->assertEquals("sv", $result['Language']); + } + } }