public function testReply() { $now = new \DateTime('now'); $reply = array(); $reply['username'] = '******'; $reply['time'] = $now->format('Y-m-d\\TH:iO'); $forum = new Forum(); $forum->setReply($reply); $this->assertEquals($reply, $forum->getReply()); }
private static function parseTopicsDetails($item) { $crawler = new Crawler($item); if ($crawler->filter('td')->count() >= 4) { $topics = new Forum(); # id. # Example: # <span id="wt439011">...</span> $topics->setId(str_replace('/forum/?topicid=', '', $crawler->filter('td[class="forum_boardrow1"] a')->attr('href'))); //->filter('span')->attr('id'))); # name. # Example: # <a href="/forum/?topicid=439011">BBCode Fixes</a> $topics->setName($crawler->filter('td[class="forum_boardrow1"] a')->text()); # username. # Example: # <a href="/profile/ratan12">ratan12</a> $topics->setUsername(str_replace('?board=', '', $crawler->filter('span[class="forum_postusername"] a')->text())); # replies. # Example: # <td align="center" width="75" class="forum_boardrow2" style="border-width: 0px 1px 1px 0px;">159</td> $topics->setReplies(str_replace('?board=', '', $crawler->filter('td[class="forum_boardrow2"]')->eq(1)->text())); # creation time. # Example: # <span class="lightLink">Jun 25, 2008</span> $topics->setTime($crawler->filter('span[class="lightLink"]')->text()); //note: eq(1) is the second node and !first. $username = $crawler->filter('td[class="forum_boardrow1"]')->eq(1)->filter('a')->text(); $time = explode("»»", $crawler->filter('td[class="forum_boardrow1"]')->eq(1)->text()); $topics->setReply(array('username' => $username, 'time' => Date::formatTime($time[1]))); return $topics; } else { return; } }