Просмотр исходного кода

fixes issue ZF-2358. site based searches now work. removed license from default params.

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@18624 44c647ce-9c0f-0410-b52a-842ac1e357ba
klassicd 16 лет назад
Родитель
Сommit
bd4e831087
2 измененных файлов с 25 добавлено и 2 удалено
  1. 4 2
      library/Zend/Service/Yahoo.php
  2. 21 0
      tests/Zend/Service/Yahoo/OnlineTest.php

+ 4 - 2
library/Zend/Service/Yahoo.php

@@ -411,7 +411,6 @@ class Zend_Service_Yahoo
     {
         static $defaultOptions = array('type'     => 'all',
                                        'start'    => 1,
-                                       'license'  => 'any',
                                        'results'  => 10,
                                        'format'   => 'any');
 
@@ -837,8 +836,11 @@ class Zend_Service_Yahoo
         $this->_validateInArray('type', $options['type'], array('all', 'any', 'phrase'));
         $this->_validateInArray('format', $options['format'], array('any', 'html', 'msword', 'pdf', 'ppt', 'rss',
                                                                     'txt', 'xls'));
-        $this->_validateInArray('license', $options['license'], array('any', 'cc_any', 'cc_commercial',
+        if (isset($options['license'])) {
+        	$this->_validateInArray('license', $options['license'], array('any', 'cc_any', 'cc_commercial',
                                                                       'cc_modifiable'));
+        }
+        
         if (isset($options['region'])){
             $this->_validateInArray('region', $options['region'], array('ar', 'au', 'at', 'br', 'ca', 'ct', 'dk', 'fi',
                                                                           'fr', 'de', 'in', 'id', 'it', 'my', 'mx',

+ 21 - 0
tests/Zend/Service/Yahoo/OnlineTest.php

@@ -344,6 +344,27 @@ class Zend_Service_Yahoo_OnlineTest extends PHPUnit_Framework_TestCase
     		$this->assertContains("Invalid value for option 'region': oops", $e->getMessage());
     	}
     }
+    
+    /**
+     * Ensures that webSearch() works as expected when searching for 'php'
+     *
+     * @return void
+     */
+    public function testWebSearchForSite()
+    {
+        $webResultSet = $this->_yahoo->webSearch('php', array('site' => 'www.php.net'));
+
+        $this->assertTrue($webResultSet instanceof Zend_Service_Yahoo_WebResultSet);
+
+        $this->assertTrue($webResultSet->totalResultsAvailable > 10);
+        $this->assertEquals(10, $webResultSet->totalResultsReturned);
+        $this->assertEquals(10, $webResultSet->totalResults());
+        $this->assertEquals(1, $webResultSet->firstResultPosition);
+
+        foreach ($webResultSet as $webResult) {
+            $this->assertTrue($webResult instanceof Zend_Service_Yahoo_WebResult);
+        }
+    }
 }
 
 /**