Merge pull request #135 from pjjonesnz/pjjonesnz-fix-mx-priority-0
Fix for MX with priority 0
This commit is contained in:
@@ -56,7 +56,7 @@ class DNS implements API
|
||||
$options['ttl'] = $ttl;
|
||||
}
|
||||
|
||||
if (!empty($priority)) {
|
||||
if (is_numeric($priority)) {
|
||||
$options['priority'] = (int)$priority;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,57 @@ class DNSTest extends TestCase
|
||||
$dns->addRecord('023e105f4ecef8ad9ca31a8372d0c353', 'A', 'example.com', '127.0.0.1', '120', false);
|
||||
}
|
||||
|
||||
public function testAddMXRecordPriority10()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/addRecord.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('post')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('post')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records'),
|
||||
$this->equalTo([
|
||||
'type' => 'MX',
|
||||
'name' => 'example.com',
|
||||
'content' => '127.0.0.1',
|
||||
'ttl' => 120,
|
||||
'proxied' => false,
|
||||
'priority' => 10,
|
||||
])
|
||||
);
|
||||
|
||||
$dns = new \Cloudflare\API\Endpoints\DNS($mock);
|
||||
$dns->addRecord('023e105f4ecef8ad9ca31a8372d0c353', 'MX', 'example.com', '127.0.0.1', '120', false, 10);
|
||||
}
|
||||
|
||||
public function testAddMXRecordPriority0()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/addRecord.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('post')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('post')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records'),
|
||||
$this->equalTo([
|
||||
'type' => 'MX',
|
||||
'name' => 'example.com',
|
||||
'content' => '127.0.0.1',
|
||||
'ttl' => 120,
|
||||
'proxied' => false,
|
||||
'priority' => 0,
|
||||
])
|
||||
);
|
||||
|
||||
$dns = new \Cloudflare\API\Endpoints\DNS($mock);
|
||||
$dns->addRecord('023e105f4ecef8ad9ca31a8372d0c353', 'MX', 'example.com', '127.0.0.1', '120', false, 0);
|
||||
}
|
||||
|
||||
|
||||
public function testListRecords()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/listRecords.json');
|
||||
|
||||
Reference in New Issue
Block a user