Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/SharedFolderTest.php
Show All 23 Lines | public function tearDown(): void | ||||
SharedFolder::withTrashed()->where('email', 'like', '%@kolabnow.com')->each(function ($folder) { | SharedFolder::withTrashed()->where('email', 'like', '%@kolabnow.com')->each(function ($folder) { | ||||
$this->deleteTestSharedFolder($folder->email); | $this->deleteTestSharedFolder($folder->email); | ||||
}); | }); | ||||
parent::tearDown(); | parent::tearDown(); | ||||
} | } | ||||
/** | /** | ||||
* Tests for AliasesTrait methods | |||||
*/ | |||||
public function testAliases(): void | |||||
{ | |||||
Queue::fake(); | |||||
Queue::assertNothingPushed(); | |||||
$folder = $this->getTestSharedFolder('folder-test@kolabnow.com'); | |||||
$this->assertCount(0, $folder->aliases->all()); | |||||
// Add an alias | |||||
$folder->setAliases(['FolderAlias1@kolabnow.com']); | |||||
Queue::assertPushed(\App\Jobs\SharedFolder\UpdateJob::class, 1); | |||||
$aliases = $folder->aliases()->get(); | |||||
$this->assertCount(1, $aliases); | |||||
$this->assertSame('folderalias1@kolabnow.com', $aliases[0]->alias); | |||||
$this->assertTrue(SharedFolder::aliasExists('folderalias1@kolabnow.com')); | |||||
// Add another alias | |||||
$folder->setAliases(['FolderAlias1@kolabnow.com', 'FolderAlias2@kolabnow.com']); | |||||
Queue::assertPushed(\App\Jobs\SharedFolder\UpdateJob::class, 2); | |||||
$aliases = $folder->aliases()->orderBy('alias')->get(); | |||||
$this->assertCount(2, $aliases); | |||||
$this->assertSame('folderalias1@kolabnow.com', $aliases[0]->alias); | |||||
$this->assertSame('folderalias2@kolabnow.com', $aliases[1]->alias); | |||||
// Remove an alias | |||||
$folder->setAliases(['FolderAlias1@kolabnow.com']); | |||||
Queue::assertPushed(\App\Jobs\SharedFolder\UpdateJob::class, 3); | |||||
$aliases = $folder->aliases()->get(); | |||||
$this->assertCount(1, $aliases); | |||||
$this->assertSame('folderalias1@kolabnow.com', $aliases[0]->alias); | |||||
$this->assertFalse(SharedFolder::aliasExists('folderalias2@kolabnow.com')); | |||||
// Remove all aliases | |||||
$folder->setAliases([]); | |||||
Queue::assertPushed(\App\Jobs\SharedFolder\UpdateJob::class, 4); | |||||
$this->assertCount(0, $folder->aliases()->get()); | |||||
$this->assertFalse(SharedFolder::aliasExists('folderalias1@kolabnow.com')); | |||||
$this->assertFalse(SharedFolder::aliasExists('folderalias2@kolabnow.com')); | |||||
} | |||||
/** | |||||
* Tests for SharedFolder::assignToWallet() | * Tests for SharedFolder::assignToWallet() | ||||
*/ | */ | ||||
public function testAssignToWallet(): void | public function testAssignToWallet(): void | ||||
{ | { | ||||
$user = $this->getTestUser('user-test@kolabnow.com'); | $user = $this->getTestUser('user-test@kolabnow.com'); | ||||
$folder = $this->getTestSharedFolder('folder-test@kolabnow.com'); | $folder = $this->getTestSharedFolder('folder-test@kolabnow.com'); | ||||
$result = $folder->assignToWallet($user->wallets->first()); | $result = $folder->assignToWallet($user->wallets->first()); | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | class SharedFolderTest extends TestCase | ||||
* Test creating a shared folder | * Test creating a shared folder | ||||
*/ | */ | ||||
public function testCreate(): void | public function testCreate(): void | ||||
{ | { | ||||
Queue::fake(); | Queue::fake(); | ||||
$folder = new SharedFolder(); | $folder = new SharedFolder(); | ||||
$folder->name = 'Reśo'; | $folder->name = 'Reśo'; | ||||
$folder->domain = 'kolabnow.com'; | $folder->domainName = 'kolabnow.com'; | ||||
$folder->save(); | $folder->save(); | ||||
$this->assertMatchesRegularExpression('/^[0-9]{1,20}$/', $folder->id); | $this->assertMatchesRegularExpression('/^[0-9]{1,20}$/', $folder->id); | ||||
$this->assertMatchesRegularExpression('/^mail-[0-9]{1,20}@kolabnow\.com$/', $folder->email); | $this->assertMatchesRegularExpression('/^mail-[0-9]{1,20}@kolabnow\.com$/', $folder->email); | ||||
$this->assertSame('Reśo', $folder->name); | $this->assertSame('Reśo', $folder->name); | ||||
$this->assertTrue($folder->isNew()); | $this->assertTrue($folder->isNew()); | ||||
$this->assertTrue($folder->isActive()); | $this->assertTrue($folder->isActive()); | ||||
$this->assertFalse($folder->isDeleted()); | $this->assertFalse($folder->isDeleted()); | ||||
▲ Show 20 Lines • Show All 177 Lines • Show Last 20 Lines |