Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Jobs/UserVerifyTest.php
<?php | <?php | ||||
namespace Tests\Feature\Jobs; | namespace Tests\Feature\Jobs; | ||||
use App\Jobs\UserCreate; | use App\Jobs\UserCreate; | ||||
use App\Jobs\UserVerify; | use App\Jobs\UserVerify; | ||||
use App\User; | use App\User; | ||||
use Illuminate\Support\Facades\Mail; | use Illuminate\Support\Facades\Queue; | ||||
use Tests\TestCase; | use Tests\TestCase; | ||||
class UserVerifyTest extends TestCase | class UserVerifyTest extends TestCase | ||||
{ | { | ||||
public function setUp(): void | |||||
{ | |||||
parent::setUp(); | |||||
$this->deleteTestUser('jane@kolabnow.com'); | |||||
} | |||||
public function tearDown(): void | |||||
{ | |||||
$this->deleteTestUser('jane@kolabnow.com'); | |||||
parent::tearDown(); | |||||
} | |||||
/** | /** | ||||
* Test job handle | * Test job handle | ||||
* | * | ||||
* @group imap | * @group imap | ||||
*/ | */ | ||||
public function testHandle(): void | public function testHandle(): void | ||||
{ | { | ||||
$user = $this->getTestUser('john@kolab.org'); | Queue::fake(); | ||||
$user->status ^= User::STATUS_IMAP_READY; | |||||
$user->save(); | $user = $this->getTestUser('jane@kolabnow.com'); | ||||
// This is a valid assertion in a feature, not functional test environment. | |||||
$this->assertFalse($user->isImapReady()); | |||||
$this->assertFalse($user->isLdapReady()); | |||||
$job = new UserCreate($user); | |||||
$job->handle(); | |||||
$this->assertFalse($user->isImapReady()); | $this->assertFalse($user->isImapReady()); | ||||
$this->assertTrue($user->isLdapReady()); | |||||
machniak: It fails for me too sometimes. Maybe $user->fresh()->isImapReady() would fix it. | |||||
Done Inline ActionsNo, it does not make sense. machniak: No, it does not make sense. | |||||
$job = new UserVerify($user); | $job = new UserVerify($user); | ||||
$job->handle(); | $job->handle(); | ||||
$this->assertTrue($user->fresh()->isImapReady()); | $this->assertTrue($user->fresh()->isImapReady()); | ||||
} | } | ||||
} | } |
It fails for me too sometimes. Maybe $user->fresh()->isImapReady() would fix it.