Page MenuHomePhorge

VerifyTest.php
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

VerifyTest.php

<?php
namespace Tests\Feature\Jobs\Resource;
use App\Resource;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class VerifyTest extends TestCase
{
/**
* {@inheritDoc}
*/
public function setUp(): void
{
parent::setUp();
$resource = $this->getTestResource('resource-test1@kolab.org');
$resource->status |= Resource::STATUS_IMAP_READY;
$resource->save();
}
/**
* {@inheritDoc}
*/
public function tearDown(): void
{
$resource = $this->getTestResource('resource-test1@kolab.org');
$resource->status |= Resource::STATUS_IMAP_READY;
$resource->save();
parent::tearDown();
}
/**
* Test job handle
*
* @group imap
*/
public function testHandle(): void
{
Queue::fake();
// Test non-existing resource ID
$job = new \App\Jobs\Resource\VerifyJob(123);
$job->handle();
$this->assertTrue($job->hasFailed());
$this->assertSame("Resource 123 could not be found in the database.", $job->failureMessage);
// Test existing resource
$resource = $this->getTestResource('resource-test1@kolab.org');
if ($resource->isImapReady()) {
$resource->status ^= Resource::STATUS_IMAP_READY;
$resource->save();
}
$this->assertFalse($resource->isImapReady());
for ($i = 0; $i < 10; $i++) {
$job = new \App\Jobs\Resource\VerifyJob($resource->id);
$job->handle();
if ($resource->fresh()->isImapReady()) {
$this->assertTrue(true);
return;
}
sleep(1);
}
$this->assertTrue(false, "Unable to verify the shared folder is set up in time");
}
}

File Metadata

Mime Type
text/x-php
Expires
Thu, Jul 9, 9:27 PM (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1057160
Default Alt Text
VerifyTest.php (1 KB)

Event Timeline