subject = $subj; $mail->from = $from; $mail->to = $to; $mail->imap_uid = $imap_uid; $mail->date = $date; $mail->message_id = ''; $mail->size = '1234'; $mail->uid = $uid; $mail->msgno = 0; $mail->recent = 0; $mail->flagged = 0; $mail->answered = 0; $mail->deleted = 0; $mail->draft = 0; $mail->seen = 1; return $mail; } /** * @group 49543 */ public function testSetCacheValue() { global $timedate; $ie_id = '123'; $mailbox = 'trash'; $time = mt_rand(); $subj = 'test ' . $time; $GLOBALS['db']->query(sprintf("INSERT INTO email_cache (ie_id, mbox, subject, fromaddr, toaddr, imap_uid) VALUES ('%s', '%s', '%s', 'from@test.com', 'to@test.com', '11')", $ie_id, $mailbox, $subj)); //deleted item from inbox which will be inserted in trash $insert[0] = $this->createMail($subj.'_new', 'from@test.com', 'to@test.com', '12', '2012-11-11 11:11:11', '12'); //old trash item which should be updated $insert[1] = $this->createMail($subj.'_old', 'from@test.com', 'to@test.com', '11', '2011-11-11 11:11:11', '11'); $ie = new InboundEmail(); $ie->id = $ie_id; $ie->setCacheValue($mailbox, $insert, '', ''); $fr = $GLOBALS['db']->fetchRow($GLOBALS['db']->query("SELECT subject FROM email_cache WHERE imap_uid = '11'")); //if old trash item was updated successfully then 'subject' has new value $this->assertTrue($fr['subject'] == $subj.'_old'); $GLOBALS['db']->query(sprintf("DELETE FROM email_cache WHERE mbox = '%s'", $mailbox)); } } ?>