forked from captbaritone/codeception-mailcatcher-module
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -339,6 +339,28 @@ public function grabUrlsFromLastEmail() | |
return $results; | ||
} | ||
|
||
/** | ||
* See Attachment In Last Email | ||
* | ||
* Look for a attachement with certain filename in the most recent email | ||
* | ||
* @param string $expectedFilename | ||
* @return void | ||
* @author Marcelo Briones <[email protected]> | ||
**/ | ||
public function seeAttachmentInLastEmail($expectedFilename) | ||
{ | ||
$email = $this->lastMessage(); | ||
$message = Message::from($email->getSource()); | ||
|
||
foreach ($message->getAllAttachmentParts() as $attachmentPart) { | ||
if ($attachmentPart->getFilename() == $expectedFilename ) { | ||
return; | ||
} | ||
} | ||
$this->fail("Filename not found in attachments"); | ||
} | ||
|
||
/** | ||
* Test email count equals expected value | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,6 +160,43 @@ public function test_grab_urls_from_last_email_with_encoding( | |
$I->assertEquals($example[0], $urls[0]); | ||
} | ||
|
||
/** | ||
* @param AcceptanceTester $I | ||
*/ | ||
public function test_see_attachment_in_last(AcceptanceTester $I) | ||
{ | ||
$user = "[email protected]"; | ||
|
||
$attachments = [ | ||
"image.jpg" => codecept_data_dir('image.jpg') | ||
]; | ||
|
||
$I->sendEmail($user, 'Email with attachments', "I have attachments.", null, $attachments); | ||
|
||
$I->seeAttachmentInLastEmail("image.jpg"); | ||
} | ||
|
||
/** | ||
* @param AcceptanceTester $I | ||
*/ | ||
public function test_fail_see_attachment_in_last(AcceptanceTester $I) | ||
{ | ||
$user = "[email protected]"; | ||
|
||
$attachments = [ | ||
"image.jpg" => codecept_data_dir('image.jpg') | ||
]; | ||
|
||
$I->sendEmail($user, 'Email with attachments', "I have attachments.", null, $attachments); | ||
|
||
try{ | ||
$I->seeAttachmentInLastEmail("no.jpg"); | ||
$I->fail("seeAttachmentInLastEmail should fail"); | ||
} catch (Exception $e) { | ||
// test successful | ||
} | ||
} | ||
|
||
/** | ||
* @param AcceptanceTester $I | ||
*/ | ||
|