mirror of
https://github.com/retailcrm/Fetch.git
synced 2024-11-25 20:36:01 +03:00
Merge pull request #84 from luxifer/imap-list
Add: listMailbox function
This commit is contained in:
commit
94f2a5fceb
@ -159,8 +159,6 @@ class Server
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$this->mailbox = $mailbox;
|
$this->mailbox = $mailbox;
|
||||||
if (isset($this->imapStream)) {
|
if (isset($this->imapStream)) {
|
||||||
$this->setImapStream();
|
$this->setImapStream();
|
||||||
@ -445,4 +443,16 @@ class Server
|
|||||||
{
|
{
|
||||||
return imap_createmailbox($this->getImapStream(), $this->getServerSpecification() . $mailbox);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,6 +164,16 @@ class ServerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertFalse($server->hasMailBox('Cheese'), 'Does not have mailbox "Cheese"');
|
$this->assertFalse($server->hasMailBox('Cheese'), 'Does not have mailbox "Cheese"');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testListMailbox()
|
||||||
|
{
|
||||||
|
$server = Static::getServer();
|
||||||
|
$spec = sprintf('{%s:143/novalidate-cert}', TESTING_SERVER_HOST);
|
||||||
|
|
||||||
|
$list = $server->listMailbox('*');
|
||||||
|
$this->assertContains($spec.'Sent', $list, 'Has mailbox "Sent"');
|
||||||
|
$this->assertNotContains($spec.'Cheese', $list, 'Does not have mailbox "Cheese"');
|
||||||
|
}
|
||||||
|
|
||||||
public function testCreateMailbox()
|
public function testCreateMailbox()
|
||||||
{
|
{
|
||||||
$server = Static::getServer();
|
$server = Static::getServer();
|
||||||
|
Loading…
Reference in New Issue
Block a user