Page MenuHomePhorge

SharedFolderTest.php
No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None

SharedFolderTest.php

<?php
namespace Tests\Unit;
use App\SharedFolder;
use Tests\TestCase;
class SharedFolderTest extends TestCase
{
/**
* Test SharedFolder status property and is*() methods
*/
public function testSharedFolderStatus(): void
{
$statuses = [
SharedFolder::STATUS_NEW,
SharedFolder::STATUS_ACTIVE,
SharedFolder::STATUS_DELETED,
SharedFolder::STATUS_LDAP_READY,
SharedFolder::STATUS_IMAP_READY,
];
$folders = \App\Utils::powerSet($statuses);
$folder = new SharedFolder(['name' => 'test']);
foreach ($folders as $folderStatuses) {
$folder->status = \array_sum($folderStatuses);
$folderStatuses = [];
foreach ($statuses as $status) {
if ($folder->status & $status) {
$folderStatuses[] = $status;
}
}
$this->assertSame($folder->status, \array_sum($folderStatuses));
// either one is true, but not both
$this->assertSame(
$folder->isNew() === in_array(SharedFolder::STATUS_NEW, $folderStatuses),
$folder->isActive() === in_array(SharedFolder::STATUS_ACTIVE, $folderStatuses)
);
$this->assertTrue(
$folder->isNew() === in_array(SharedFolder::STATUS_NEW, $folderStatuses)
);
$this->assertTrue(
$folder->isActive() === in_array(SharedFolder::STATUS_ACTIVE, $folderStatuses)
);
$this->assertTrue(
$folder->isDeleted() === in_array(SharedFolder::STATUS_DELETED, $folderStatuses)
);
$this->assertTrue(
$folder->isLdapReady() === in_array(SharedFolder::STATUS_LDAP_READY, $folderStatuses)
);
$this->assertTrue(
$folder->isImapReady() === in_array(SharedFolder::STATUS_IMAP_READY, $folderStatuses)
);
}
$this->expectException(\Exception::class);
$folder->status = 111;
}
/**
* Test basic SharedFolder funtionality
*/
public function testSharedFolderType(): void
{
$folder = new SharedFolder(['name' => 'test']);
foreach (SharedFolder::SUPPORTED_TYPES as $type) {
$folder->type = $type;
}
$this->expectException(\Exception::class);
$folder->type = 'unknown';
}
}

File Metadata

Mime Type
text/x-php
Expires
Sun, Apr 5, 11:38 PM (1 w, 5 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
6a/7f/0dfd21ff7fb52140bc996d5914a6
Default Alt Text
SharedFolderTest.php (2 KB)

Event Timeline