-
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.
Merge pull request #1 from nswdpc/upgrade-requirements
Upgrade requirements
- Loading branch information
Showing
145 changed files
with
4,088 additions
and
610 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
/tests export-ignore | ||
/docs export-ignore | ||
/client/src export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.php_cs.dist | ||
/phpcs.xml.dist | ||
/phpstan.neon.dist | ||
/phpunit.xml.dist | ||
/.waratah export-ignore | ||
/README.md export-ignore | ||
/tests export-ignore | ||
/docs export-ignore | ||
/client/src export-ignore | ||
/.editorconfig export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.php-cs-fixer.dist.php export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/.waratah export-ignore | ||
/code-of-conduct.md export-ignore | ||
/CONTRIBUTING.md export-ignore | ||
/README.md export-ignore | ||
/thirdparty/postmark-templates export-ignore |
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 |
---|---|---|
@@ -1,9 +1,5 @@ | ||
/client/node_modules | ||
/vendor/ | ||
.DS_Store | ||
/.php_cs.cache | ||
/resources/ | ||
/_resources/ | ||
/public/ | ||
/assets/ | ||
/.php-cs-fixer.cache | ||
/tests/__output/ |
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
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,14 +1 @@ | ||
<p> | ||
<%t StructuredEmail.THANKS 'Thanks '%> | ||
<br> | ||
<% if $SiteConfig %> | ||
<br> | ||
{$SiteConfig.Title} | ||
<% end_if %> | ||
<% with $Top.EmailDecorator %> | ||
<% if $SignOffLink %> | ||
<br> | ||
{$SignOffLink.XML} | ||
<% end_if %> | ||
<% end_with %> | ||
</p> | ||
<%-- override this template in your project to provide a generic sign-off to the email, if required --%> |
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 |
---|---|---|
|
@@ -14,7 +14,7 @@ class EmailTemplateTest extends SapphireTest { | |
Member::class => '*', | ||
]; | ||
|
||
protected $usesDatabase = false; | ||
protected $usesDatabase = null; | ||
|
||
private function saveOutput($html, $template, $ext = ".html") { | ||
$full = dirname(__FILE__) . '/__output/' . $template; | ||
|
@@ -29,13 +29,15 @@ public function testTemplate() { | |
'Body' => file_get_contents(dirname(__FILE__) . '/data/template.html') | ||
]; | ||
|
||
$subject = 'Welcome to the show'; | ||
|
||
$email = StructuredEmail::create(); | ||
$email->setTo("[email protected]"); | ||
$email->setCc("[email protected]"); | ||
$email->setBcc("[email protected]"); | ||
$email->setFrom(["[email protected]" => "Jiminy Crickets", "[email protected]" => "Bob Pokemon"]); | ||
$email->addFrom("[email protected]"); | ||
$email->setSubject('Welcome to the show'); | ||
$email->setSubject($subject); | ||
$email->setPreheader('Test generic email that needs your attention'); | ||
$email->setData($data); | ||
$email->setViewAction('Confirm your identify', 'https://confirm.example.com?token=suitably-long-token'); | ||
|
@@ -48,6 +50,14 @@ public function testTemplate() { | |
$message = $email->getSwiftMessage(); | ||
$this->saveOutput($message, "StructuredEmail", ".txt"); | ||
|
||
|
||
// assert email contains subject | ||
$this->assertStringContainsString( | ||
"Subject: " . $subject, | ||
$message | ||
); | ||
|
||
|
||
} | ||
|
||
/** | ||
|
@@ -57,16 +67,18 @@ public function testForgotEmail() { | |
$template = 'SilverStripe/Control/Email/ForgotPasswordEmail'; | ||
$token = "really-bad-token"; | ||
$member = $this->objFromFixture(Member::class, 'forgotpassword'); | ||
$resetPasswordLink = Security::getPasswordResetLink($member, $token); | ||
$subject = _t( | ||
'SilverStripe\\Security\\Member.SUBJECTPASSWORDRESET', | ||
"Your password reset link", | ||
'Email subject' | ||
); | ||
/** @var StructuredEmail $email */ | ||
$email = StructuredEmail::create() | ||
->setHTMLTemplate($template) | ||
->setData($member) | ||
->setSubject(_t( | ||
'SilverStripe\\Security\\Member.SUBJECTPASSWORDRESET', | ||
"Your password reset link", | ||
'Email subject' | ||
)) | ||
->addData('PasswordResetLink', Security::getPasswordResetLink($member, $token)) | ||
->setSubject($subject) | ||
->addData('PasswordResetLink', $resetPasswordLink) | ||
->setTo($member->Email); | ||
// test preheader | ||
$email->setPreHeader( | ||
|
@@ -81,31 +93,52 @@ public function testForgotEmail() { | |
$message = $email->getSwiftMessage(); | ||
$this->saveOutput($message, "ForgotPasswordEmail", ".txt"); | ||
|
||
// test that email is rendered with link and in structured email | ||
// test that email is rendered with reset link and in structured email | ||
$this->assertStringContainsString( | ||
htmlspecialchars($resetPasswordLink), // entitised link | ||
$html // in the HTML | ||
); | ||
|
||
// assert email contains subject | ||
$this->assertStringContainsString( | ||
"Subject: " . $subject, | ||
$message | ||
); | ||
|
||
} | ||
|
||
public function testChangePassword() { | ||
$member = $this->objFromFixture(Member::class, 'forgotpassword'); | ||
$subject = _t( | ||
'SilverStripe\\Security\\Member.SUBJECTPASSWORDCHANGED', | ||
"Your password has been changed", | ||
'Email subject' | ||
); | ||
$email = StructuredEmail::create() | ||
->setHTMLTemplate('SilverStripe\\Control\\Email\\ChangePasswordEmail') | ||
->setData($member) | ||
->setTo($member->Email) | ||
->setFrom('[email protected]') | ||
->setSubject(_t( | ||
'SilverStripe\\Security\\Member.SUBJECTPASSWORDCHANGED', | ||
"Your password has been changed", | ||
'Email subject' | ||
)); | ||
->setSubject($subject); | ||
$email->send(); | ||
|
||
$this->saveOutput($email->getBody(), "ChangePasswordEmail"); | ||
|
||
$message = $email->getSwiftMessage(); | ||
$this->saveOutput($message, "ChangePasswordEmail", ".txt"); | ||
|
||
// assert email contains subject | ||
$this->assertStringContainsString( | ||
"Subject: " . $subject, | ||
$message | ||
); | ||
|
||
|
||
} | ||
|
||
public function testStandardEmail() { | ||
$member = $this->objFromFixture(Member::class, 'forgotpassword'); | ||
$subject = 'Subject of an important message'; | ||
$email = StructuredEmail::create() | ||
->setHTMLTemplate('SilverStripe\\Control\\Email\\Email') | ||
->setData([ | ||
|
@@ -114,13 +147,21 @@ public function testStandardEmail() { | |
->setPreHeader('An important message') | ||
->setTo($member->Email) | ||
->setFrom('[email protected]') | ||
->setSubject('Subject of an important message'); | ||
->setSubject($subject); | ||
$email->send(); | ||
|
||
$this->saveOutput($email->getBody(), "StandardEmail"); | ||
|
||
$message = $email->getSwiftMessage(); | ||
$this->saveOutput($message, "StandardEmail", ".txt"); | ||
|
||
// assert email contains subject | ||
$this->assertStringContainsString( | ||
"Subject: " . $subject, | ||
$message | ||
); | ||
|
||
|
||
} | ||
|
||
} |
Oops, something went wrong.