From 5e1a4e27dd4437c69b6083e63ff4f9b9458f86f0 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Tue, 3 Mar 2020 09:49:46 +0000 Subject: [PATCH] ensure edit works --- tests/MailboxHandlerTest.php | 44 +++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/tests/MailboxHandlerTest.php b/tests/MailboxHandlerTest.php index 98b69079..8f6a6899 100644 --- a/tests/MailboxHandlerTest.php +++ b/tests/MailboxHandlerTest.php @@ -117,9 +117,8 @@ class MailboxHandlerTest extends \PHPUnit\Framework\TestCase { $found = false; - foreach ($list as $alias => $details) { - if ($alias == 'david.test@example.com') { - // Found! + foreach ($list as $key => $details) { + if ($key == 'david.test@example.com') { $this->assertEquals('example.com', $details['domain']); $this->assertEquals('david.test@example.com', $details['username']); $this->assertEquals('test person', $details['name']); @@ -129,6 +128,45 @@ class MailboxHandlerTest extends \PHPUnit\Framework\TestCase { } $this->assertTrue($found, "check output : " . json_encode($list)); + + + // Try and edit. + + $h = new MailboxHandler(0, 'admin', true); + $h->init('david.test@example.com'); + + $r = $h->set([ + 'password' => '', + 'password2' => '', + 'name' => 'test person 1234', + 'quota' => 123456, + 'active' => 1, + 'email_other' => 'fred@example.com', + 'username' => 'david.test@example.com' + ]); + + $this->assertEmpty($h->errormsg); + $this->assertEmpty($h->infomsg); + $this->assertTrue($r); + $this->assertTrue($h->store()); + + $h->getList(''); + $list = $h->result(); + $this->assertEquals(1, count($list)); + $found = false; + foreach ($list as $key => $details) { + if ($key == 'david.test@example.com') { + // Found! + $this->assertEquals('example.com', $details['domain']); + $this->assertEquals('david.test@example.com', $details['username']); + $this->assertEquals(123456, $details['quota']); + $this->assertEquals('test person 1234', $details['name']); + $found = true; + break; + } + } + + $this->assertTrue($found); } }