From 0a4f339fcb851f2c6138ea8d61f558530de97c3d Mon Sep 17 00:00:00 2001 From: Robert Hafner Date: Sat, 6 Jun 2015 22:35:25 -0700 Subject: [PATCH] Added delete mailbox method --- src/Fetch/Server.php | 12 ++++++++++++ tests/Fetch/Test/ServerTest.php | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/src/Fetch/Server.php b/src/Fetch/Server.php index c5c9ced..f82b51e 100644 --- a/src/Fetch/Server.php +++ b/src/Fetch/Server.php @@ -473,4 +473,16 @@ class Server { return imap_list($this->getImapStream(), $this->getServerSpecification(), $pattern); } + + /** + * Deletes the given mailbox. + * + * @param $mailbox + * + * @return bool + */ + public function deleteMailBox($mailbox) + { + return imap_deletemailbox($this->getImapStream(), $this->getServerSpecification() . $mailbox); + } } diff --git a/tests/Fetch/Test/ServerTest.php b/tests/Fetch/Test/ServerTest.php index d9875a6..d8ccddb 100644 --- a/tests/Fetch/Test/ServerTest.php +++ b/tests/Fetch/Test/ServerTest.php @@ -183,6 +183,14 @@ class ServerTest extends \PHPUnit_Framework_TestCase $this->assertTrue($server->hasMailBox('Cheese'), 'Mailbox "Cheese" was created'); } + public function testDeleteMailbox() + { + $server = Static::getServer(); + $this->assertTrue($server->hasMailBox('Cheese'), 'Does have mailbox "Cheese"'); + $this->assertTrue($server->deleteMailBox('Cheese'), 'deleteMailBox returns true.'); + $this->assertFalse($server->hasMailBox('Cheese'), 'Mailbox "Cheese" was deleted'); + } + /** * @expectedException \RuntimeException */