Merge branch 'master' into fix-refresh-cache
This commit is contained in:
@@ -52,7 +52,7 @@ class DNS implements API
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($priority)) {
|
if (!empty($priority)) {
|
||||||
$options['priority'] = $priority;
|
$options['priority'] = (int)$priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = $this->adapter->post('zones/' . $zoneID . '/dns_records', $options);
|
$user = $this->adapter->post('zones/' . $zoneID . '/dns_records', $options);
|
||||||
|
|||||||
@@ -158,10 +158,10 @@ class Zones implements API
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cachePurge(string $zoneID, array $files = null, array $tags = null): bool
|
public function cachePurge(string $zoneID, array $files = null, array $tags = null, array $hosts = null): bool
|
||||||
{
|
{
|
||||||
if ($files === null && $tags === null) {
|
if ($files === null && $tags === null && $hosts === null) {
|
||||||
throw new EndpointException('No files or tags to purge.');
|
throw new EndpointException('No files, tags or hosts to purge.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$options = [];
|
$options = [];
|
||||||
@@ -172,6 +172,10 @@ class Zones implements API
|
|||||||
if (!is_null($tags)) {
|
if (!is_null($tags)) {
|
||||||
$options['tags'] = $tags;
|
$options['tags'] = $tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!is_null($hosts)) {
|
||||||
|
$options['tags'] = $tags;
|
||||||
|
}
|
||||||
|
|
||||||
$user = $this->adapter->delete('zones/' . $zoneID . '/purge_cache', $options);
|
$user = $this->adapter->delete('zones/' . $zoneID . '/purge_cache', $options);
|
||||||
|
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ class ZonesTest extends TestCase
|
|||||||
$this->assertObjectHasAttribute('since', $analytics->totals);
|
$this->assertObjectHasAttribute('since', $analytics->totals);
|
||||||
$this->assertObjectHasAttribute('since', $analytics->timeseries[0]);
|
$this->assertObjectHasAttribute('since', $analytics->timeseries[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testChangeDevelopmentMode()
|
public function testChangeDevelopmentMode()
|
||||||
{
|
{
|
||||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/changeDevelopmentMode.json');
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/changeDevelopmentMode.json');
|
||||||
@@ -184,4 +184,30 @@ class ZonesTest extends TestCase
|
|||||||
|
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCachePurgeHost()
|
||||||
|
{
|
||||||
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/cachePurgeHost.json');
|
||||||
|
|
||||||
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
|
$mock->method('delete')->willReturn($response);
|
||||||
|
|
||||||
|
$mock->expects($this->once())
|
||||||
|
->method('delete')
|
||||||
|
->with(
|
||||||
|
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/purge_cache'),
|
||||||
|
$this->equalTo(
|
||||||
|
[
|
||||||
|
'files' => [],
|
||||||
|
'tags' => [],
|
||||||
|
'hosts' => ['dash.cloudflare.com']
|
||||||
|
]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
||||||
|
$result = $zones->cachePurge('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', [], [], ['dash.cloudflare.com']);
|
||||||
|
|
||||||
|
$this->assertTrue($result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
8
tests/Fixtures/Endpoints/cachePurgeHost.json
Normal file
8
tests/Fixtures/Endpoints/cachePurgeHost.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [],
|
||||||
|
"messages": [],
|
||||||
|
"result": {
|
||||||
|
"id": "023e105f4ecef8ad9ca31a8372d0c353"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user