Пример #1
0
 /**
  *    Finds a URL by label. Will find the first link
  *    found with this link text by default, or a later
  *    one if an index is given. The match ignores case and
  *    white space issues.
  *    @param string $label     Text between the anchor tags.
  *    @param integer $index    Link position counting from zero.
  *    @return string/boolean   URL on success.
  *    @access public
  */
 function getLink($label, $index = 0)
 {
     $urls = $this->page->getUrlsByLabel($label);
     if (count($urls) == 0) {
         return false;
     }
     if (count($urls) < $index + 1) {
         return false;
     }
     return $urls[$index];
 }
Пример #2
0
 function testFindLinkWithImage()
 {
     $link = new SimpleAnchorTag(array('href' => './somewhere.php', 'id' => 33));
     $link->addContent('<img src="pic.jpg" alt="&lt;A picture&gt;">');
     $response = new MockSimpleHttpResponse();
     $response->setReturnValue('getUrl', new SimpleUrl('http://host/'));
     $page = new SimplePage($response);
     $page->AcceptTag($link);
     $this->assertEqual($page->getUrlsByLabel('<A picture>'), array(new SimpleUrl('http://host/somewhere.php')));
 }