В проекте laravel у меня есть следующий Mailable:
class MyMail extends Mailable
{
public function build()
{
return $this
->from('hentaiouji@neko.com', 'Hentai Prince witouh Story cat')
->subject("Stony Cat Lists")
->attach('myFile.xlsx', [
'as' => 'myFile.xlsx',
'mime' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
])
->bcc('konekochan@example.com');
}
}
И я хочу заявить, что прикреплен правильный файл, поэтому мне нужно найти путь и сравнить md5, сгенерированные чтение файлов.
Вопрос в том, как из почтового сообщения можно получить вложения, чтобы я мог вручную прочитать их в php. Подход, которому я хочу следовать, следующий:
public function testAtachmentIsTheSame()
{
$expectedAttatchmentMd5=md5(file_get_contents('myFile.xlsx'));
$mailable=(new MyMail())->build();
$attatchmentMd5; //Contains the md5 read from the mailable Atachment
$this->assertEquals($expectedAttatchmentMd5,$attatchmentMd5);
}
Итак, в моем тесте, как я могу получить вложение из Mailable, не отправляя фактическое электронное письмо?