diff --git a/src/Powerdns.php b/src/Powerdns.php index 335c9d0..9fe0f60 100644 --- a/src/Powerdns.php +++ b/src/Powerdns.php @@ -194,15 +194,19 @@ public function deleteZone(string $canonicalDomain): bool /** * Retrieve all zones. * + * @param bool $omitDnssecAndEditedSerialFields When set to true dnssec and edited_serial are omitted + * * @return Zone[] Array containing the zones + * + * @link https://doc.powerdns.com/authoritative/http-api/zone.html#get--servers-server_id-zones */ - public function listZones(): array + public function listZones(bool $omitDnssecAndEditedSerialFields = false): array { return array_map( function (array $args) { return new Zone($this->connector, $args['id']); }, - $this->connector->get('zones') + $this->connector->get('zones?dnssec='.($omitDnssecAndEditedSerialFields ? 'true' : 'false')) ); } diff --git a/tests/PowerdnsTest.php b/tests/PowerdnsTest.php index 75913ba..f895534 100644 --- a/tests/PowerdnsTest.php +++ b/tests/PowerdnsTest.php @@ -90,10 +90,18 @@ public function testZone(): void $this->assertTrue($powerDns->deleteZone('test.nl.')); } - public function testListZones(): void + public function listZonesArgumentDataProvider(): array + { + return [['true', true], ['false', false]]; + } + + /** + * @dataProvider listZonesArgumentDataProvider + */ + public function testListZones(string $dnssecArgument, bool $listZonesArgument): void { $connector = Mockery::mock(Connector::class); - $connector->shouldReceive('get')->withArgs(['zones'])->once()->andReturn( + $connector->shouldReceive('get')->withArgs(['zones?dnssec='.$dnssecArgument])->once()->andReturn( [ [ 'account' => '', @@ -124,7 +132,7 @@ public function testListZones(): void $powerDns = new Powerdns(null, null, null, null, $connector); - $response = $powerDns->listZones(); + $response = $powerDns->listZones($listZonesArgument); $this->assertIsArray($response); $this->assertCount(2, $response); foreach ($response as $zone) {