public function testParseRow() { $googleEngine = new GoogleEngine('phpunit brutal ololo'); $link = 'url?q=http://youtube.com'; $title = 'mocking Question,<em>PHPUnit</em> - creating Mock objects to act as stubs <b>...</b>'; $description = '<span class="f">21 Jul 2010 </span>I am trying to configure a Mock object in <em>PHPunit</em><br>'; $nodeHTML = ' <li class="g"> <div sig="BSU" class="vsc"> <h3 class="r"> <a href="%s">%s</a> </h3> <div class="s"> <span class="st">%s</span> </div> </div> </li> '; $dom = new \DOMDocument('1.0', 'utf-8'); $dom->loadHTML(sprintf($nodeHTML, $link, $title, $description)); $resultRow = new \Virm\Search\Engine\EngineResultRow(); $resultRow->setTitle(strip_tags($title)); $resultRow->setLink($googleEngine->getDomain() . $link); $resultRow->setDescription(strip_tags($description)); $this->assertEquals($resultRow, $googleEngine->parseRow($dom), '->parseRow() returns an EngineResultRow object'); }
public function testOffsetGet() { $googleEngine = new GoogleEngine('phpunit brutal ololo'); $search = new Search($googleEngine); $resultRow = new \Virm\Search\Engine\EngineResultRow(); $resultRow->setTitle('[00:00:47] <gerrit-wm> New review: jenkins-bot; "Build Failed ...'); $resultRow->setLink('http://bots.wmflabs.org/~wm-bot/logs/%2523mediawiki/20120528.txt'); $resultRow->setDescription('28 May 2012... <MaxSem> ololo [13:18:58] <Reedy> I\'m planning on branching and making up .... [15:03:54] <chughakshay16> Reedy: i m running a phpunit test. ...... I don\'t even need a clean way, i jus want to put some brutal code in this ...'); preg_match('#q=(.*)&sa.*#', $search[0]->getLink(), $match); $this->assertEquals($resultRow->getLink(), $match[1], '[0]->getLink() returns an EngineResultRow Link of first position'); $this->assertEquals($resultRow->getTitle(), $search[0]->getTitle(), '[0]->getTitle() returns an EngineResultRow Link of first position'); $this->assertEquals($resultRow->getDescription(), $search[0]->getDescription(), '[0]->getDescription() returns an EngineResultRow Link of first position'); }