Skip to content

Commit

Permalink
Merge branch 'feat/create-object-support' of github.com:bennetgallein…
Browse files Browse the repository at this point in the history
…/powerdns-php into feat/create-object-support
  • Loading branch information
bennetgallein committed Oct 27, 2023
2 parents 8ca41c9 + d4fa533 commit 909cbe5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public static function createResourceRecord(
return (new ResourceRecord())->setApiResponse($name);
}

['name' => $name, 'type' => $type, 'ttl' => $ttl, 'content' => $content, 'comments' => $comments] = $name;
$comments = $name['comments'] ?? [];
['name' => $name, 'type' => $type, 'ttl' => $ttl, 'content' => $content] = $name;
}

$name = str_replace('@', $zoneName, $name);
Expand Down
2 changes: 1 addition & 1 deletion src/Powerdns.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Powerdns implements PowerdnsInterface
/**
* The version of this package. This is being used for the user-agent header.
*/
public const CLIENT_VERSION = 'v4.5.0';
public const CLIENT_VERSION = 'v4.5.1';

/**
* @var Powerdns The client instance.
Expand Down
21 changes: 21 additions & 0 deletions tests/HelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,27 @@ public function testWithArray(): void
self::assertSame('rooti', $result->getComments()[1]->getAccount());
}

public function testWithArrayWithoutOptionalFields(): void
{
$result = Helper::createResourceRecord(
'unit.test.',
[
'name' => '@',
'type' => RecordType::A,
'content' => ['127.0.0.1', '127.0.0.2'],
'ttl' => 1337,
]
);

self::assertSame('unit.test.', $result->getName());
self::assertSame('A', $result->getType());
self::assertSame(1337, $result->getTtl());
self::assertCount(2, $result->getRecords());
self::assertSame('127.0.0.1', $result->getRecords()[0]->getContent());
self::assertSame('127.0.0.2', $result->getRecords()[1]->getContent());
self::assertEmpty($result->getComments());
}

public function testWithApiResponse(): void
{
foreach (ZoneTest::API_RESPONSE['rrsets'] as $rrset) {
Expand Down

0 comments on commit 909cbe5

Please sign in to comment.