-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add deliberate warning when Mail exception
- Loading branch information
Showing
2 changed files
with
53 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
use UserFrosting\Sprinkle\Core\Testing\RefreshDatabase; | ||
use UserFrosting\Sprinkle\Core\Throttle\Throttler; | ||
use UserFrosting\Sprinkle\Core\Util\Captcha; | ||
use PHPMailer\PHPMailer\Exception as PHPMailerException; | ||
|
||
/** | ||
* Tests RegisterAction | ||
|
@@ -266,6 +267,49 @@ public function testRegisterWithEmailVerification(): void | |
], $response); | ||
} | ||
|
||
public function testRegisterWithFailedEmailVerification(): void | ||
{ | ||
/** @var Mailer */ | ||
$mailer = Mockery::mock(Mailer::class) | ||
->makePartial() | ||
->shouldReceive('send')->once() | ||
->andThrow(PHPMailerException::class) | ||
->getMock(); | ||
$this->ci->set(Mailer::class, $mailer); | ||
|
||
$this->setMasterUser(); | ||
$captcha = $this->getCaptcha(); | ||
$this->forceLocaleConfig(); | ||
$this->setRequireEmailVerification(true); | ||
|
||
// Set POST data | ||
$data = [ | ||
'spiderbro' => 'http://', | ||
'captcha' => $captcha->getCaptcha(), | ||
'user_name' => 'RegisteredUser', | ||
'first_name' => 'Testing', | ||
'last_name' => 'Register', | ||
'email' => '[email protected]', | ||
'password' => 'FooBarFooBar123', | ||
'passwordc' => 'FooBarFooBar123', | ||
'locale' => '', | ||
]; | ||
|
||
// Create request with method and url and fetch response | ||
$request = $this->createJsonRequest('POST', '/account/register', $data); | ||
$response = $this->handleRequest($request); | ||
|
||
// Assert response status & body | ||
$this->assertResponseStatus(500, $response); | ||
$this->assertJsonResponse('Fatal error attempting mail, contact your server administrator. If you are the admin, please check the UserFrosting log.', $response, 'title'); | ||
|
||
// Assert alert | ||
/** @var AlertStream */ | ||
$ms = $this->ci->get(AlertStream::class); | ||
$messages = $ms->getAndClearMessages(); | ||
$this->assertSame('danger', array_reverse($messages)[0]['type']); | ||
} | ||
|
||
public function testRegisterWithFailedThrottle(): void | ||
{ | ||
// Create fake throttler | ||
|