< wp_mail(): Send Helper   (Previous) Table of Contents (Next)   wp_mail(): Full Test >

wp_mail(): Verification Helper

abstract class TestCase extends PHPUnit_Framework_TestCase {
    protected function check_mail_file() {
        // Ensure the actual output was generated.
        if (!self::$mail_file) {
            $this->fail('wp_mail() has not been called.');
        }

        $basedir = dirname(__FILE__) . '/expected/';
        $locale = get_locale();
        if (!file_exists("$basedir/$locale")) {
            $locale = 'en_US';
        }

        // Placate Microsoft.
        $basename = str_replace('::', '--', self::$mail_file_basename);

        // Use PHPUnit's file diff method.
        $this->assertStringMatchesFormatFile(
            "$basedir/$locale/$basename",
            file_get_contents(self::$mail_file)
        );
    }
}