Skip to content

Commit

Permalink
Allow to return statistics endpoint data
Browse files Browse the repository at this point in the history
  • Loading branch information
akondas committed Oct 29, 2020
1 parent b81ed43 commit 602817a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Powerdns.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,16 @@ public function cryptokeys(string $canonicalDomain): Cryptokey
return new Cryptokey($this->connector, $canonicalDomain);
}

/**
* Query PowerDNS internal statistics.
*
* @return mixed[]
*/
public function statistics(): array
{
return $this->connector->get('statistics');
}

/**
* Get the PowerDNS server version.
*
Expand Down
17 changes: 17 additions & 0 deletions tests/PowerdnsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ public function testConfigViaMethods(): void
$this->assertSame('test-key', $config['apiKey']);
}

public function testStatistics(): void
{
$connector = Mockery::mock(Connector::class);
$connector->shouldReceive('get')->withArgs(['statistics'])->once()->andReturn($example = [
[
'name' => 'corrupt-packets',
'type' => 'StatisticItem',
'value' => 0
]
]);

$powerDns = new Powerdns(null, null, null, null, $connector);
$stats = $powerDns->statistics();

self::assertEquals($example, $stats);
}

public function testZone(): void
{
$connector = Mockery::mock(Connector::class);
Expand Down

0 comments on commit 602817a

Please sign in to comment.