protected function assertMailCount($actualMail, $expectedCount = null)
    {
        $actualCount = count($actualMail);
        if (is_null($expectedCount)) {
            // If number to expect is not specified, expect more than zero.
            if ($actualCount === 0) {
                throw new \Exception("Expected some mail, but none found.");
            }
        } else {
            if ($expectedCount != $actualCount) {
                // Prepare a simple list of actual mail.
                $prettyActualMail = [];
                foreach ($actualMail as $singleActualMail) {
                    $prettyActualMail[] = [
                    'to' => $singleActualMail['to'],
                    'subject' => $singleActualMail['subject'],
                    ];
                }
                throw new \Exception(sprintf("Expected %s mail, but %s found:\n\n%s", $expectedCount, $actualCount, print_r($prettyActualMail, true)));
            }
        }
    }
protected function assertMailCount($actualMail, $expectedCount = null)
    {
        $actualCount = count($actualMail);
        if (is_null($expectedCount)) {
            // If number to expect is not specified, expect more than zero.
            if ($actualCount === 0) {
                throw new \Exception("Expected some mail, but none found.");
            }
        } else {
            if ($expectedCount != $actualCount) {
                // Prepare a simple list of actual mail.
                $prettyActualMail = [];
                foreach ($actualMail as $singleActualMail) {
                    $prettyActualMail[] = [
                    'to' => $singleActualMail['to'],
                    'subject' => $singleActualMail['subject'],
                    ];
                }
                throw new \Exception(sprintf("Expected %s mail, but %s found:\n\n%s", $expectedCount, $actualCount, print_r($prettyActualMail, true)));
            }
        }
    }
protected function assertMailCount ( $ actualMail , $ expectedCount = null ) { $ actualCount = count ( $ actualMail ) ; if ( is_null ( $ expectedCount ) ) { // If number to expect is not specified, expect more than zero. if ( $ actualCount === 0 ) { throw new \ Exception ( "Expected some mail, but none found." ) ; } } else { if ( $ expectedCount != $ actualCount ) { // Prepare a simple list of actual mail. $ prettyActualMail = [ ] ; foreach ( $ actualMail as $ singleActualMail ) { $ prettyActualMail [ ] = [ 'to' => $ singleActualMail [ 'to' ] , 'subject' => $ singleActualMail [ 'subject' ] , ] ; } throw new \ Exception ( sprintf ( "Expected %s mail, but %s found:\n\n%s" , $ expectedCount , $ actualCount , print_r ( $ prettyActualMail , true ) ) ) ; } } }
Assert there is the expected number of mails, or that there are some mails
if the exact number expected is not specified.

@param array $actualMail
An array of actual mail.
@param int $expectedCount
Optional. The number of mails expected.
Assert there is the expected number of mails or that there are some mails if the exact number expected is not specified .