示例#1
0
    /**
     * Ensures that pageDataSearch() works as expected given 'http://framework.zend.com/' as a query
     *
     * @return void
     */
    public function testPageDataSearchPhp()
    {
        $pageDataResultSet = $this->_yahoo->pageDataSearch('http://framework.zend.com/');

        $this->assertTrue($pageDataResultSet instanceof Zend_Service_Yahoo_PageDataResultSet);
        $this->assertTrue($pageDataResultSet->totalResultsAvailable > 10);
        $this->assertEquals(50, $pageDataResultSet->totalResultsReturned);
        $this->assertEquals(50, $pageDataResultSet->totalResults());
        $this->assertEquals(1, $pageDataResultSet->firstResultPosition);
        $this->assertEquals(0, $pageDataResultSet->key());

        try {
            $pageDataResultSet->seek(-1);
            $this->fail('Expected OutOfBoundsException not thrown');
        } catch (OutOfBoundsException $e) {
            $this->assertContains('Illegal index', $e->getMessage());
        }

        foreach ($pageDataResultSet as $pageDataResult) {
            $this->assertTrue($pageDataResult instanceof Zend_Service_Yahoo_PageDataResult);
        }

        $this->assertEquals(50, $pageDataResultSet->key());
        $pageDataResultSet->seek(0);
        $this->assertEquals(0, $pageDataResultSet->key());
    }
示例#2
0
 /**
  * Ensures that pageDataSearch() throws an exception when the start option is invalid
  *
  * @return void
  */
 public function testPageDataSearchExceptionStartInvalid()
 {
     try {
         $this->_yahoo->pageDataSearch('http://framework.zend.com/', array('start' => 1001));
         $this->fail('Expected Zend_Service_Exception not thrown');
     } catch (Zend_Service_Exception $e) {
         $this->assertContains("option 'start'", $e->getMessage());
     }
 }