Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/PowerDNS/DomainTest.php
Show All 12 Lines | class DomainTest extends TestCase | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
public function setUp(): void | public function setUp(): void | ||||
{ | { | ||||
parent::setUp(); | parent::setUp(); | ||||
$this->domain = Domain::firstOrCreate( | $this->domain = Domain::firstOrCreate(['name' => 'test-domain.com']); | ||||
[ | |||||
'name' => 'test-domain.com' | |||||
] | |||||
); | |||||
} | } | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
public function tearDown(): void | public function tearDown(): void | ||||
{ | { | ||||
$this->domain->delete(); | $this->domain->delete(); | ||||
parent::tearDown(); | parent::tearDown(); | ||||
} | } | ||||
/** | |||||
* Test domain record creation (observer) | |||||
*/ | |||||
public function testDomainCreate(): void | public function testDomainCreate(): void | ||||
{ | { | ||||
$this->assertCount(1, $this->domain->records()->where('type', 'SOA')->get()); | $this->assertCount(1, $this->domain->records()->where('type', 'SOA')->get()); | ||||
$this->assertCount(2, $this->domain->records()->where('type', 'NS')->get()); | $this->assertCount(2, $this->domain->records()->where('type', 'NS')->get()); | ||||
} | $this->assertCount(2, $this->domain->records()->where('type', 'A')->get()); | ||||
$this->assertCount(5, $this->domain->records()->get()); | |||||
public function testCreateRecord(): void | |||||
{ | |||||
$before = $this->domain->getSerial(); | |||||
Record::create( | |||||
[ | |||||
'domain_id' => $this->domain->id, | |||||
'name' => $this->domain->{'name'}, | |||||
'type' => "MX", | |||||
'content' => '10 mx01.' . $this->domain->{'name'} . '.' | |||||
] | |||||
); | |||||
Record::create( | |||||
[ | |||||
'domain_id' => $this->domain->id, | |||||
'name' => 'mx01.' . $this->domain->{'name'}, | |||||
'type' => "A", | |||||
'content' => '127.0.0.1' | |||||
] | |||||
); | |||||
$after = $this->domain->getSerial(); | $this->assertCount(1, $this->domain->settings()->get()); | ||||
$this->assertTrue($before < $after); | // TODO: Test content of every domain record/setting | ||||
} | } | ||||
} | } |