Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/GroupTest.php
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | public function testConfigTrait(): void | ||||
$this->assertSame(['unknown' => "The requested configuration parameter is not supported."], $result); | $this->assertSame(['unknown' => "The requested configuration parameter is not supported."], $result); | ||||
$result = $group->setConfig(['sender_policy' => ['test']]); | $result = $group->setConfig(['sender_policy' => ['test']]); | ||||
$this->assertSame(['sender_policy' => ['test']], $group->getConfig()); | $this->assertSame(['sender_policy' => ['test']], $group->getConfig()); | ||||
$this->assertSame('["test","-"]', $group->getSetting('sender_policy')); | $this->assertSame('["test","-"]', $group->getSetting('sender_policy')); | ||||
$this->assertSame([], $result); | $this->assertSame([], $result); | ||||
} | } | ||||
/** | |||||
* Test group status assignment and is*() methods | |||||
*/ | |||||
public function testStatus(): void | |||||
{ | |||||
$group = new Group(); | |||||
$this->assertSame(false, $group->isNew()); | |||||
$this->assertSame(false, $group->isActive()); | |||||
$this->assertSame(false, $group->isDeleted()); | |||||
$this->assertSame(false, $group->isLdapReady()); | |||||
$this->assertSame(false, $group->isSuspended()); | |||||
$group->status = Group::STATUS_NEW; | |||||
$this->assertSame(true, $group->isNew()); | |||||
$this->assertSame(false, $group->isActive()); | |||||
$this->assertSame(false, $group->isDeleted()); | |||||
$this->assertSame(false, $group->isLdapReady()); | |||||
$this->assertSame(false, $group->isSuspended()); | |||||
$group->status |= Group::STATUS_ACTIVE; | |||||
$this->assertSame(true, $group->isNew()); | |||||
$this->assertSame(true, $group->isActive()); | |||||
$this->assertSame(false, $group->isDeleted()); | |||||
$this->assertSame(false, $group->isLdapReady()); | |||||
$this->assertSame(false, $group->isSuspended()); | |||||
$group->status |= Group::STATUS_LDAP_READY; | |||||
$this->assertSame(true, $group->isNew()); | |||||
$this->assertSame(true, $group->isActive()); | |||||
$this->assertSame(false, $group->isDeleted()); | |||||
$this->assertSame(true, $group->isLdapReady()); | |||||
$this->assertSame(false, $group->isSuspended()); | |||||
$group->status |= Group::STATUS_DELETED; | |||||
$this->assertSame(true, $group->isNew()); | |||||
$this->assertSame(true, $group->isActive()); | |||||
$this->assertSame(true, $group->isDeleted()); | |||||
$this->assertSame(true, $group->isLdapReady()); | |||||
$this->assertSame(false, $group->isSuspended()); | |||||
$group->status |= Group::STATUS_SUSPENDED; | |||||
$this->assertSame(true, $group->isNew()); | |||||
$this->assertSame(true, $group->isActive()); | |||||
$this->assertSame(true, $group->isDeleted()); | |||||
$this->assertSame(true, $group->isLdapReady()); | |||||
$this->assertSame(true, $group->isSuspended()); | |||||
// Unknown status value | |||||
$this->expectException(\Exception::class); | |||||
$group->status = 111; | |||||
} | |||||
/** | /** | ||||
* Test creating a group | * Test creating a group | ||||
*/ | */ | ||||
public function testCreate(): void | public function testCreate(): void | ||||
{ | { | ||||
Queue::fake(); | Queue::fake(); | ||||
$group = Group::create(['email' => 'GROUP-test@kolabnow.com']); | $group = Group::create(['email' => 'GROUP-test@kolabnow.com']); | ||||
$this->assertSame('group-test@kolabnow.com', $group->email); | $this->assertSame('group-test@kolabnow.com', $group->email); | ||||
$this->assertSame('group-test', $group->name); | |||||
$this->assertMatchesRegularExpression('/^[0-9]{1,20}$/', $group->id); | $this->assertMatchesRegularExpression('/^[0-9]{1,20}$/', $group->id); | ||||
$this->assertSame([], $group->members); | $this->assertSame([], $group->members); | ||||
$this->assertTrue($group->isNew()); | $this->assertTrue($group->isNew()); | ||||
$this->assertTrue($group->isActive()); | $this->assertTrue($group->isActive()); | ||||
Queue::assertPushed( | Queue::assertPushed( | ||||
\App\Jobs\Group\CreateJob::class, | \App\Jobs\Group\CreateJob::class, | ||||
function ($job) use ($group) { | function ($job) use ($group) { | ||||
▲ Show 20 Lines • Show All 172 Lines • ▼ Show 20 Lines | public function testSettings(): void | ||||
Queue::assertPushed(\App\Jobs\Group\UpdateJob::class, 1); | Queue::assertPushed(\App\Jobs\Group\UpdateJob::class, 1); | ||||
$this->assertSame(null, $group->getSetting('unknown')); | $this->assertSame(null, $group->getSetting('unknown')); | ||||
$this->assertSame(null, $group->fresh()->getSetting('sender_policy')); | $this->assertSame(null, $group->fresh()->getSetting('sender_policy')); | ||||
} | } | ||||
/** | /** | ||||
* Test group status assignment and is*() methods | |||||
*/ | |||||
public function testStatus(): void | |||||
{ | |||||
$group = new Group(); | |||||
$this->assertSame(false, $group->isNew()); | |||||
$this->assertSame(false, $group->isActive()); | |||||
$this->assertSame(false, $group->isDeleted()); | |||||
$this->assertSame(false, $group->isLdapReady()); | |||||
$this->assertSame(false, $group->isSuspended()); | |||||
$group->status = Group::STATUS_NEW; | |||||
$this->assertSame(true, $group->isNew()); | |||||
$this->assertSame(false, $group->isActive()); | |||||
$this->assertSame(false, $group->isDeleted()); | |||||
$this->assertSame(false, $group->isLdapReady()); | |||||
$this->assertSame(false, $group->isSuspended()); | |||||
$group->status |= Group::STATUS_ACTIVE; | |||||
$this->assertSame(true, $group->isNew()); | |||||
$this->assertSame(true, $group->isActive()); | |||||
$this->assertSame(false, $group->isDeleted()); | |||||
$this->assertSame(false, $group->isLdapReady()); | |||||
$this->assertSame(false, $group->isSuspended()); | |||||
$group->status |= Group::STATUS_LDAP_READY; | |||||
$this->assertSame(true, $group->isNew()); | |||||
$this->assertSame(true, $group->isActive()); | |||||
$this->assertSame(false, $group->isDeleted()); | |||||
$this->assertSame(true, $group->isLdapReady()); | |||||
$this->assertSame(false, $group->isSuspended()); | |||||
$group->status |= Group::STATUS_DELETED; | |||||
$this->assertSame(true, $group->isNew()); | |||||
$this->assertSame(true, $group->isActive()); | |||||
$this->assertSame(true, $group->isDeleted()); | |||||
$this->assertSame(true, $group->isLdapReady()); | |||||
$this->assertSame(false, $group->isSuspended()); | |||||
$group->status |= Group::STATUS_SUSPENDED; | |||||
$this->assertSame(true, $group->isNew()); | |||||
$this->assertSame(true, $group->isActive()); | |||||
$this->assertSame(true, $group->isDeleted()); | |||||
$this->assertSame(true, $group->isLdapReady()); | |||||
$this->assertSame(true, $group->isSuspended()); | |||||
// Unknown status value | |||||
$this->expectException(\Exception::class); | |||||
$group->status = 111; | |||||
} | |||||
/** | |||||
* Tests for Group::suspend() | * Tests for Group::suspend() | ||||
*/ | */ | ||||
public function testSuspend(): void | public function testSuspend(): void | ||||
{ | { | ||||
Queue::fake(); | Queue::fake(); | ||||
$group = $this->getTestGroup('group-test@kolabnow.com'); | $group = $this->getTestGroup('group-test@kolabnow.com'); | ||||
$group->suspend(); | $group->suspend(); | ||||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |