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 */