forked from moodle/moodle
-
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.
MDL-64148 oauth2: Make email greetings consistent
Some email body strings use first names as greetings, some use full names, and some do not. Using the first name for greeting makes it consistent and a bit more "personal".
- Loading branch information
1 parent
020259d
commit b4f1704
Showing
4 changed files
with
59 additions
and
5 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
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 |
---|---|---|
|
@@ -22,6 +22,8 @@ | |
* @package auth_oauth2 | ||
* @copyright 2017 Damyon Wiese | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
* | ||
* @covers \auth_oauth2\api | ||
*/ | ||
class api_test extends \advanced_testcase { | ||
|
||
|
@@ -227,4 +229,39 @@ public function test_send_confirm_account_email(): void { | |
// Explicitly test the user is not yet confirmed. | ||
$this->assertEquals(0, $userdata->confirmed); | ||
} | ||
|
||
/** | ||
* Test case for checking the email greetings in OAuth2 confirmation emails. | ||
*/ | ||
public function test_email_greetings(): void { | ||
$this->resetAfterTest(); | ||
$this->setAdminUser(); | ||
|
||
$issuer = \core\oauth2\api::create_standard_issuer('microsoft'); | ||
|
||
$userinfo = []; | ||
$userinfo['username'] = 'apple'; | ||
$userinfo['email'] = '[email protected]'; | ||
$userinfo['firstname'] = 'Apple'; | ||
$userinfo['lastname'] = 'Fruit'; | ||
$sink = $this->redirectEmails(); // Make sure we are redirecting emails. | ||
\auth_oauth2\api::send_confirm_account_email($userinfo, $issuer); | ||
$result = $sink->get_messages(); | ||
$sink->close(); | ||
// Test greetings. | ||
$this->assertStringContainsString('Hi ' . $userinfo['firstname'], quoted_printable_decode($result[0]->body)); | ||
|
||
$userinfo = []; | ||
$userinfo['username'] = 'banana'; | ||
$userinfo['email'] = '[email protected]'; | ||
$userinfo['firstname'] = 'Banana'; | ||
$userinfo['lastname'] = 'Fruit'; | ||
$user = $this->getDataGenerator()->create_user(); | ||
$sink = $this->redirectEmails(); // Make sure we are redirecting emails. | ||
\auth_oauth2\api::send_confirm_link_login_email($userinfo, $issuer, $user->id); | ||
$result = $sink->get_messages(); | ||
$sink->close(); | ||
// Test greetings. | ||
$this->assertStringContainsString('Hi ' . $user->firstname, quoted_printable_decode($result[0]->body)); | ||
} | ||
} |
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