private static function parseListview($item, $read)
 {
     $crawler = new Crawler($item);
     $message = new Messages();
     # Message id.
     $message->setId((int) str_replace('?go=read&id=', '', $crawler->filterXPath('//div[contains(@class, "mym_subject")]/a')->attr('href')));
     # Action id.
     $message->setActionId((int) str_replace('msgchecker', '', $crawler->filterXPath('//div[contains(@class, "mym_checkboxes")]/input')->attr('id')));
     # Thread id.
     $message->setThreadId((int) str_replace('&toname=' . $message->getUsername(), '', str_replace('?go=send&replyid=' . $message->GetActionId() . '&threadid=', '', $crawler->filterXPath('//span[contains(@class, "mym_actions")]/a')->attr('href'))));
     # Username of the sender.
     $message->setUsername($crawler->filterXPath('//div[contains(@class, "mym_user")]/a')->text());
     # Time of the received message.
     $message->setTime($crawler->filterXPath('//span[@class="mym_date"]')->text());
     # Read (if the user has read this message).
     $message->setRead($read);
     # Subject and Preview are linked together
     $messagePreview = trim($crawler->filterXPath('//div[contains(@class, "mym_subject")]/a/span')->text());
     $messageSubject = trim(str_replace($messagePreview, '', $crawler->filterXPath('//div[contains(@class, "mym_subject")]/a')->text()));
     $messageSubject = preg_replace('/ -$/', '', $messageSubject);
     # Subject.
     $message->setSubject($messageSubject);
     # Preview message.
     $message->setPreview($messagePreview);
     return $message;
 }
Exemplo n.º 2
0
 public function testUsername()
 {
     $msgUsername = '******';
     $message = new Messages();
     $message->setUsername($msgUsername);
     $this->assertEquals($msgUsername, $message->getUsername());
 }