Skip to content

Commit

Permalink
refs #478-custom-emails add tests to custom mailer
Browse files Browse the repository at this point in the history
  • Loading branch information
steinkel committed Aug 29, 2017
1 parent 0ccd8d0 commit 11c7803
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions tests/TestCase/Model/Behavior/PasswordBehaviorTest.php
Expand Up @@ -136,7 +136,7 @@ public function testResetTokenNoExpiration()
/**
* Test resetToken
*
* @expectedException CakeDC\Users\Exception\UserNotFoundException
* @expectedException \CakeDC\Users\Exception\UserNotFoundException
*/
public function testResetTokenNotExistingUser()
{
Expand All @@ -148,7 +148,7 @@ public function testResetTokenNotExistingUser()
/**
* Test resetToken
*
* @expectedException CakeDC\Users\Exception\UserAlreadyActiveException
* @expectedException \CakeDC\Users\Exception\UserAlreadyActiveException
*/
public function testResetTokenUserAlreadyActive()
{
Expand All @@ -168,7 +168,7 @@ public function testResetTokenUserAlreadyActive()
/**
* Test resetToken
*
* @expectedException CakeDC\Users\Exception\UserNotActiveException
* @expectedException \CakeDC\Users\Exception\UserNotActiveException
*/
public function testResetTokenUserNotActive()
{
Expand Down Expand Up @@ -205,10 +205,27 @@ public function testChangePassword()
$result = $this->Behavior->changePassword($user);
}

/**
* test Email Override
*/
public function testEmailOverride()
{
$overrideMailer = $this->getMockBuilder(OverrideMailer::class)
->setMethods(['send'])
->getMock();
Configure::write('Users.Email.mailerClass', OverrideMailer::class);
$this->Behavior = new PasswordBehavior($this->table);
$this->Behavior = $this->getMockBuilder(PasswordBehavior::class)
->setConstructorArgs([$this->table])
->setMethods(['getMailer'])
->getMock();
$overrideMailer->expects($this->once())
->method('send')
->with('resetPassword')
->willReturn(true);
$this->Behavior->expects($this->once())
->method('getMailer')
->with(OverrideMailer::class)
->willReturn($overrideMailer);
$this->Behavior->resetToken('user-1', [
'expiration' => 3600,
'checkActive' => true,
Expand Down

0 comments on commit 11c7803

Please sign in to comment.