diff --git a/src/app/Jobs/DomainCreate.php b/src/app/Jobs/DomainCreate.php --- a/src/app/Jobs/DomainCreate.php +++ b/src/app/Jobs/DomainCreate.php @@ -48,6 +48,8 @@ $this->domain->status |= Domain::STATUS_LDAP_READY; $this->domain->save(); + + DomainVerify::dispatch($this->domain); } } } diff --git a/src/app/Observers/DomainObserver.php b/src/app/Observers/DomainObserver.php --- a/src/app/Observers/DomainObserver.php +++ b/src/app/Observers/DomainObserver.php @@ -36,7 +36,8 @@ */ public function created(Domain $domain) { - // Create domain record in LDAP, then check if it exists in DNS + // Create domain record in LDAP + // Note: DomainCreate job will dispatch DomainVerify job \App\Jobs\DomainCreate::dispatch($domain); } diff --git a/src/tests/Feature/Jobs/DomainCreateTest.php b/src/tests/Feature/Jobs/DomainCreateTest.php --- a/src/tests/Feature/Jobs/DomainCreateTest.php +++ b/src/tests/Feature/Jobs/DomainCreateTest.php @@ -44,9 +44,25 @@ $this->assertFalse($domain->isLdapReady()); + // Fake the queue, assert that no jobs were pushed... + Queue::fake(); + Queue::assertNothingPushed(); + $job = new DomainCreate($domain); $job->handle(); $this->assertTrue($domain->fresh()->isLdapReady()); + + Queue::assertPushed(\App\Jobs\DomainVerify::class, 1); + + Queue::assertPushed( + \App\Jobs\DomainVerify::class, + function ($job) use ($domain) { + $job_domain = TestCase::getObjectProperty($job, 'domain'); + + return $job_domain->id === $domain->id && + $job_domain->namespace === $domain->namespace; + } + ); } }