From e0c986931cc2da006c4c9a3e035893df0fa9fd05 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Tue, 23 Feb 2021 09:57:01 +0000 Subject: [PATCH] add something to test Login::passwordChange() works --- tests/LoginTest.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/LoginTest.php b/tests/LoginTest.php index de07a551..942796c3 100644 --- a/tests/LoginTest.php +++ b/tests/LoginTest.php @@ -39,6 +39,31 @@ class LoginTest extends \PHPUnit\Framework\TestCase { db_query('DELETE FROM domain'); } + public function testPasswordchange() { + $login = new Login('mailbox'); + + $this->assertTrue($login->login('test@example.com', 'foobar')); + + // Can't change - current password wrong. + try { + $login->changePassword('test@example.com', 'foobar2', 'foobar2'); + $this->fail("Exception should have been thrown"); + } catch (\Exception $e) { + $this->assertEquals("You didn't supply your current password!", $e->getMessage()); + } + + + // Should change, current password correct. + $this->assertTrue($login->changePassword('test@example.com', 'foobar2', 'foobar')); + + // Can't now login with the old password + $this->assertFalse($login->login('test@example.com', 'foobar')); + + // Can login with the new one... + $this->assertTrue($login->login('test@example.com', 'foobar2')); + } + + public function testInvalidUsers() { $login = new Login('mailbox');