Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/DomainsTest.php
Show First 20 Lines • Show All 531 Lines • ▼ Show 20 Lines | public function testStore(): void | ||||
$domain = Domain::where('namespace', $post['namespace'])->first(); | $domain = Domain::where('namespace', $post['namespace'])->first(); | ||||
$this->assertInstanceOf(Domain::class, $domain); | $this->assertInstanceOf(Domain::class, $domain); | ||||
$this->assertEntitlements($domain, ['domain-hosting']); | $this->assertEntitlements($domain, ['domain-hosting']); | ||||
$wallet = $domain->wallet(); | $wallet = $domain->wallet(); | ||||
$this->assertSame($john->wallets->first()->id, $wallet->id); | $this->assertSame($john->wallets->first()->id, $wallet->id); | ||||
// Test creating a domain that is soft-deleted and belongs to another user | // Test creating a domain that is soft-deleted and belongs to another user | ||||
$domain->delete(); | $domain->delete(); | ||||
$domain->entitlement()->withTrashed()->update(['wallet_id' => $jack->wallets->first()->id]); | $domain->entitlements()->withTrashed()->update(['wallet_id' => $jack->wallets->first()->id]); | ||||
$response = $this->actingAs($john)->post("/api/v4/domains", $post); | $response = $this->actingAs($john)->post("/api/v4/domains", $post); | ||||
$response->assertStatus(422); | $response->assertStatus(422); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertSame('error', $json['status']); | $this->assertSame('error', $json['status']); | ||||
$this->assertCount(2, $json); | $this->assertCount(2, $json); | ||||
$this->assertSame('The specified domain is not available.', $json['errors']['namespace']); | $this->assertSame('The specified domain is not available.', $json['errors']['namespace']); | ||||
// Test acting as account controller (not owner) | // Test acting as account controller (not owner) | ||||
$this->markTestIncomplete(); | $this->markTestIncomplete(); | ||||
} | } | ||||
} | } |