2017-01-27 00:30:13 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
|
|
|
*
|
|
|
|
* Mail
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCA\Mail\Tests;
|
|
|
|
|
2018-02-12 14:41:56 +03:00
|
|
|
use ChristophWurst\Nextcloud\Testing\TestCase;
|
2017-01-27 00:30:13 +03:00
|
|
|
use Horde_Imap_Client_Mailbox;
|
|
|
|
use OCA\Mail\Folder;
|
|
|
|
use PHPUnit_Framework_MockObject_MockObject;
|
|
|
|
|
|
|
|
class FolderTest extends TestCase {
|
2019-08-28 19:25:54 +03:00
|
|
|
/** @var int */
|
|
|
|
private $accountId;
|
2017-01-27 00:30:13 +03:00
|
|
|
|
|
|
|
/** @var Horde_Imap_Client_Mailbox|PHPUnit_Framework_MockObject_MockObject */
|
|
|
|
private $mailbox;
|
|
|
|
|
|
|
|
/** @var Folder */
|
|
|
|
private $folder;
|
|
|
|
|
|
|
|
private function mockFolder(array $attributes = [], $delimiter = '.') {
|
2019-08-28 19:25:54 +03:00
|
|
|
$this->accountId = 15;
|
2017-01-27 00:30:13 +03:00
|
|
|
$this->mailbox = $this->createMock(Horde_Imap_Client_Mailbox::class);
|
|
|
|
|
2023-05-04 09:29:51 +03:00
|
|
|
$this->folder = new Folder($this->accountId, $this->mailbox, $attributes, $delimiter, []);
|
2017-01-27 00:30:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetMailbox() {
|
|
|
|
$this->mockFolder();
|
|
|
|
$this->mailbox->expects($this->once())
|
|
|
|
->method('__get')
|
|
|
|
->with($this->equalTo('utf8'))
|
|
|
|
->willReturn('Sent');
|
|
|
|
|
|
|
|
$this->assertSame('Sent', $this->folder->getMailbox());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetDelimiter() {
|
|
|
|
$this->mockFolder([], ',');
|
|
|
|
|
|
|
|
$this->assertSame(',', $this->folder->getDelimiter());
|
|
|
|
}
|
|
|
|
|
2021-09-08 14:55:11 +03:00
|
|
|
public function testGetDelimiterNull(): void {
|
|
|
|
$this->mockFolder([], null);
|
|
|
|
|
|
|
|
$this->assertNull($this->folder->getDelimiter());
|
|
|
|
}
|
|
|
|
|
2017-01-27 00:30:13 +03:00
|
|
|
public function testGetAttributes() {
|
|
|
|
$this->mockFolder(['\noselect']);
|
|
|
|
|
|
|
|
$this->assertSame(['\noselect'], $this->folder->getAttributes());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSetStatus() {
|
|
|
|
$this->mockFolder();
|
|
|
|
|
|
|
|
$this->folder->setStatus([
|
|
|
|
'unseen' => 4,
|
|
|
|
]);
|
2019-08-29 11:50:46 +03:00
|
|
|
|
|
|
|
$this->addToAssertionCount(1);
|
2017-01-27 00:30:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testSpecialUse() {
|
|
|
|
$this->mockFolder();
|
|
|
|
|
|
|
|
$this->folder->addSpecialUse('flagged');
|
|
|
|
|
|
|
|
$this->assertCount(1, $this->folder->getSpecialUse());
|
|
|
|
$this->assertSame('flagged', $this->folder->getSpecialUse()[0]);
|
|
|
|
}
|
|
|
|
}
|