Skip to content

Commit

Permalink
- fix negative index problem
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Gopkalo committed Apr 7, 2016
1 parent 5520e88 commit 2ba3ff2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Email/Receive/EmailReceiveCheck.php
Expand Up @@ -186,7 +186,7 @@ private function performReceive(EmailSendReceive $emailSendCheckI)
{
try {
$mails = $this->getMailbox()->searchMailbox(
'FROM '.$emailSendCheckI->getFrom().' SUBJECT '.$emailSendCheckI->getSubject()
'FROM '.$emailSendCheckI->getFrom().' SUBJECT "'.$emailSendCheckI->getSubject().'"'
);

$this->timeReceiveCheck($emailSendCheckI);
Expand Down
13 changes: 8 additions & 5 deletions src/Email/Send/EmailSendCheck.php
Expand Up @@ -22,7 +22,7 @@ class EmailSendCheck extends AbstractEmailCheck
const CHECK = 'email-send-check';
const MESSAGE_BODY = 'This is a test, you don\'t need to reply this massage.';
const SEND_INTERVAL = 600;
const SUBJECT_TEMPLATE = '%s:time:%d';
const SUBJECT_TEMPLATE = '%s:time:%s';

/**
* @var int
Expand Down Expand Up @@ -88,9 +88,12 @@ public function check()
$this->setEmailSendReceiveColl($this->getPersistCollection()->load());


$lastSandedEmail = $this->getEmailSendReceiveColl()->at(
$this->getEmailSendReceiveColl()->count()-1
);

$lastSandedEmail = $this->getEmailSendReceiveColl()->count()-1 >=0 ?
$this->getEmailSendReceiveColl()->at(
$this->getEmailSendReceiveColl()->count()-1
)
:null;
if (null === $lastSandedEmail
|| empty($lastSandedEmail->getSentAt())
|| (time() - $lastSandedEmail->getSentAt()->getTimestamp()) > $this->getSendInterval()
Expand Down Expand Up @@ -195,7 +198,7 @@ protected function setToSubject($toSubject)
*/
protected function genEmailSubject()
{
return sprintf(static::SUBJECT_TEMPLATE, $this->getIndent(), date(DATE_RFC2822));
return sprintf(static::SUBJECT_TEMPLATE, $this->getIndent(), date(DATE_W3C));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Email/SendReceiveCheck.php
Expand Up @@ -65,9 +65,9 @@ public function check()
$resultReceive = $this->emailCheck($this->getEmailReceiveCheck(), self::EMAIL_RECEIVE_CHECK_MSG);

if (! $resultSend->isOk()) {
$result = new Failure($resultSend->getError());
$result = new Failure($resultSend->getError()->getMessage(), $resultSend->getError());
} elseif (! $resultReceive->isOk()) {
$result = new Failure($resultReceive->getError());
$result = new Failure($resultReceive->getError()->getMessage(), $resultReceive->getError());
} else {
$result = new Success();
}
Expand Down

0 comments on commit 2ba3ff2

Please sign in to comment.