From 0a4f339fcb851f2c6138ea8d61f558530de97c3d Mon Sep 17 00:00:00 2001 From: Robert Hafner Date: Sat, 6 Jun 2015 22:35:25 -0700 Subject: [PATCH 1/2] 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 */ From 1ca08ba1044e899033e7a688612dce222e94077a Mon Sep 17 00:00:00 2001 From: Robert Hafner Date: Sat, 6 Jun 2015 22:48:30 -0700 Subject: [PATCH 2/2] Fixed PSR formatting --- tests/Fetch/Test/ServerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Fetch/Test/ServerTest.php b/tests/Fetch/Test/ServerTest.php index d8ccddb..553f002 100644 --- a/tests/Fetch/Test/ServerTest.php +++ b/tests/Fetch/Test/ServerTest.php @@ -185,7 +185,7 @@ class ServerTest extends \PHPUnit_Framework_TestCase public function testDeleteMailbox() { - $server = Static::getServer(); + $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');