ahmedsamy / codeception-smtp-mail
在您的 Codeception 接受测试中进行邮件测试
v0.8.2
2017-10-23 08:33 UTC
Requires
- php-imap/php-imap: ~2.0
README
安装
$ composer require ahmedsamy/codeception-smtp-mail
配置
在 acceptance.yml
modules: enabled: - Smtp: username: name@email.com password: password
构建 codeception
$ bin/codecept build
可用方法
seeEmail($criteria)
canSeeEmail($criteria)
seeEmail($criteria)
cantSeeEmail($criteria)
dontSeeEmail($criteria)
openEmail($criteria)
grabEmail()
grabLinkFromEmail($url)
clickInEmail($url)
canSeeLinkInEmail($url)
seeLinkInEmail($url)
cantSeeLinkInEmail($url)
dontSeeLinkInEmail($url)
canSeeEmailAttachmentsCount($count)
canSeeEmailAttachment($name)
countEmailsByCriteria($criteria)
- $criteria 是根据 imap 语法,见 https://php.ac.cn/manual/en/function.imap-search.php
示例
检查具有主题和日期的邮件
$I->seeEmailBy('SUBJECT "HOWTO be Awesome" SINCE "8 August 2008"'); $I->canSeeEmail('SUBJECT "Welcome Email"'); $I->openEmail('SUBJECT "Open me"'); $I->canSeeEmail('SUBJECT "good words"'); $I->seeLinkInEmail('http://google.com/awesome'); $I->clickInEmail("http://google.com/awesome"); $I->grabLinkFromEmail("http://google.com/awesome"); $I->canSeeEmailAttachmentsCount(2); $I->canSeeEmailAttachment('contract.pdf'); //accepts full file name or part of it
配置参考
Smtp: username: username@domain.com #required password: password123 #required imap_path: {imap.gmail.com:993/imap/ssl}INBOX #imap path defaults to gmail config wait_interval: 1 #waiting interval between trials in seconds retry_counts: 3 # how many trials till attachments_dir: tests/_data #where email attachments are stored auto_clear_attachments: true #whether to clear attachments folder every run or not
###TODOs
- 编写测试
- 添加 travis.yml