Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/DomainTest.php
Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | public function testCreateJobs(): void | ||||
Queue::assertNothingPushed(); | Queue::assertNothingPushed(); | ||||
$domain = Domain::create([ | $domain = Domain::create([ | ||||
'namespace' => 'gmail.com', | 'namespace' => 'gmail.com', | ||||
'status' => Domain::STATUS_NEW, | 'status' => Domain::STATUS_NEW, | ||||
'type' => Domain::TYPE_EXTERNAL, | 'type' => Domain::TYPE_EXTERNAL, | ||||
]); | ]); | ||||
Queue::assertPushed(\App\Jobs\DomainCreate::class, 1); | Queue::assertPushed(\App\Jobs\Domain\CreateJob::class, 1); | ||||
Queue::assertPushed( | Queue::assertPushed( | ||||
\App\Jobs\DomainCreate::class, | \App\Jobs\Domain\CreateJob::class, | ||||
function ($job) use ($domain) { | function ($job) use ($domain) { | ||||
$job_domain = TestCase::getObjectProperty($job, 'domain'); | $domainId = TestCase::getObjectProperty($job, 'domainId'); | ||||
$domainNamespace = TestCase::getObjectProperty($job, 'domainNamespace'); | |||||
return $job_domain->id === $domain->id && | return $domainId === $domain->id && | ||||
$job_domain->namespace === $domain->namespace; | $domainNamespace === $domain->namespace; | ||||
} | } | ||||
); | ); | ||||
$job = new \App\Jobs\DomainCreate($domain); | $job = new \App\Jobs\Domain\CreateJob($domain->id); | ||||
$job->handle(); | $job->handle(); | ||||
} | } | ||||
/** | /** | ||||
* Tests getPublicDomains() method | * Tests getPublicDomains() method | ||||
*/ | */ | ||||
public function testGetPublicDomains(): void | public function testGetPublicDomains(): void | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | public function testDelete(): void | ||||
]); | ]); | ||||
$domain->delete(); | $domain->delete(); | ||||
$this->assertTrue($domain->fresh()->trashed()); | $this->assertTrue($domain->fresh()->trashed()); | ||||
$this->assertFalse($domain->fresh()->isDeleted()); | $this->assertFalse($domain->fresh()->isDeleted()); | ||||
// Delete the domain for real | // Delete the domain for real | ||||
$job = new \App\Jobs\DomainDelete($domain->id); | $job = new \App\Jobs\Domain\DeleteJob($domain->id); | ||||
$job->handle(); | $job->handle(); | ||||
$this->assertTrue(Domain::withTrashed()->where('id', $domain->id)->first()->isDeleted()); | $this->assertTrue(Domain::withTrashed()->where('id', $domain->id)->first()->isDeleted()); | ||||
$domain->forceDelete(); | $domain->forceDelete(); | ||||
$this->assertCount(0, Domain::withTrashed()->where('id', $domain->id)->get()); | $this->assertCount(0, Domain::withTrashed()->where('id', $domain->id)->get()); | ||||
} | } | ||||
} | } |