From 8d29ddeb7381d054a45e2fd2718fd2a9efd2fe9c Mon Sep 17 00:00:00 2001 From: Florent Viel Date: Tue, 26 Aug 2014 17:59:05 +0200 Subject: [PATCH] Add: listMailbox function --- src/Fetch/Server.php | 12 ++++++++++++ tests/Fetch/Test/ServerTest.php | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/Fetch/Server.php b/src/Fetch/Server.php index 4fca523..25fc606 100644 --- a/src/Fetch/Server.php +++ b/src/Fetch/Server.php @@ -445,4 +445,16 @@ class Server { return imap_createmailbox($this->getImapStream(), $this->getServerSpecification() . $mailbox); } + + /** + * List available mailboxes + * + * @param string $pattern + * + * @return array + */ + public function listMailbox($pattern = '*') + { + return imap_list($this->getImapStream(), $this->getServerSpecification(), $pattern); + } } diff --git a/tests/Fetch/Test/ServerTest.php b/tests/Fetch/Test/ServerTest.php index 4255ed2..ee0566d 100644 --- a/tests/Fetch/Test/ServerTest.php +++ b/tests/Fetch/Test/ServerTest.php @@ -205,6 +205,16 @@ class ServerTest extends \PHPUnit_Framework_TestCase $this->assertFalse($server->getMessageByUid(12), 'Message successfully expunged'); } + public function testListMailbox() + { + $server = Static::getServer(); + $spec = sprintf('{%s:143/novalidate-cert}', TESTING_SERVER_HOST); + + $list = $server->listMailbox('*'); + $this->assertContains($spec.'Sent', $list); + $this->assertNotContains($spec.'Cheese', $list); + } + public static function getServer() { $server = new Server(TESTING_SERVER_HOST, 143);