public function testWebSearchBasic() { $this->_boss->getHttpClient()->setAdapter($this->_httpClientAdapterTest); $this->_httpClientAdapterTest->setResponse($this->_loadResponse(__FUNCTION__)); $options = array('start' => 0, 'count' => 10); $resultSet = $this->_boss->webSearch('zend framework', $options); // Check the meta-data $this->assertEquals(10, $resultSet->getCount()); $this->assertEquals(0, $resultSet->getStart()); $this->assertEquals(417996, $resultSet->getTotalHits()); $this->assertEquals(10500000, $resultSet->getDeepHits()); $this->assertEquals(0, $resultSet->key()); // Attempt to seek below the lower bound try { $resultSet->seek(-1); $this->fail('Expected OutOfBoundsException not thrown'); } catch (OutOfBoundsException $e) { $this->assertContains('Illegal index', $e->getMessage()); } $resultSet->seek(9); // Attempt to seek above the upper bound try { $resultSet->seek(10); $this->fail('Expected OutOfBoundsException not thrown'); } catch (OutOfBoundsException $e) { $this->assertContains('Illegal index', $e->getMessage()); } $resultSet->rewind(); $this->assertTrue($resultSet->valid()); // Check the results are available $result = $resultSet->current(); $this->assertEquals('Data-centric Adobe Flash Builder development with the <b>Zend</b> <b>Framework</b> <b>...</b> Jeroen Keppens on: Creating a modular application with <b>Zend</b> <b>Framework</b> <b>...</b>', $result->getAbstract()); $this->assertEquals('<b>Zend</b> <b>Framework</b>', $result->getTitle()); $this->assertEquals('http://framework.zend.com/', $result->getUrl()); $this->assertEquals('http://lrd.yahooapis.com/_ylc=X3oDMTQ4dGRvaGxvBF9TAzIwMjMxNTI3MDIEYXBwaWQDQkVEVmZRWElrWTBKUExtS002QkFYd2ZnRnQxLkVFYy0EY2xpZW50A2Jvc3MEc2VydmljZQNCT1NTBHNsawN0aXRsZQRzcmNwdmlkA0RIX2F0V0tJY3JvQXE3cEdPQlZ5R0FFWVZnNFdBMHBGUmlvQUNRU0M-/SIG=10vtopo9u/**http%3A//framework.zend.com/', $result->getClickUrl()); $this->assertEquals('<b>framework.zend.com</b>', $result->getDisplayUrl()); $this->assertEquals('14409', $result->getSize()); $this->assertEquals('2009/06/18', $result->getDate()); }
public function indexAction() { $query = trim($this->getRequest()->getQuery('q', '')); $this->view->query = $query; if (!empty($query)) { $count = 10; $page = (int) $this->getRequest()->getQuery('p', 1); if ($page < 1) { $page = 1; } // Perform the search! $boss = new Noginn_Service_YahooBoss(''); $webResults = $boss->webSearch($query, array('count' => $count, 'start' => $count * ($page - 1), 'sites' => 'noginn.com')); // Paginate the results $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Null($webResults->getTotalHits())); $paginator->setCurrentPageNumber($page); $paginator->setItemCountPerPage($count); $this->view->webResults = $webResults; $this->view->paginator = $paginator; } }