From 4f7b794d9c1e127c237150ba6c859950e0817e3a Mon Sep 17 00:00:00 2001 From: Jeffrey Guo Date: Wed, 30 Apr 2014 17:30:50 +1200 Subject: [PATCH] get the last one email --- src/SilverStripe/BehatExtension/Utility/TestMailer.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/SilverStripe/BehatExtension/Utility/TestMailer.php b/src/SilverStripe/BehatExtension/Utility/TestMailer.php index aae7baa..50febd4 100644 --- a/src/SilverStripe/BehatExtension/Utility/TestMailer.php +++ b/src/SilverStripe/BehatExtension/Utility/TestMailer.php @@ -80,7 +80,10 @@ class TestMailer extends \Mailer { */ public function findEmail($to = null, $from = null, $subject = null, $content = null) { $matches = $this->findEmails($to, $from, $subject, $content); - return $matches ? $matches[0] : null; + //got the count of matches emails + $emailCount = count($matches); + //get the last(latest) one + return $matches ? $matches[$emailCount-1] : null; } /**