Merge pull request #99 from benedict-erwin/master
Add Method Delete Zone
This commit is contained in:
@@ -233,4 +233,18 @@ class Zones implements API
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Zone
|
||||
*/
|
||||
public function deleteZone(string $identifier): bool
|
||||
{
|
||||
$user = $this->adapter->delete('zones/' . $identifier);
|
||||
$this->body = json_decode($user->getBody());
|
||||
if (isset($this->body->result->id)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
19
tests/Endpoints/ZoneDeleteTest.php
Normal file
19
tests/Endpoints/ZoneDeleteTest.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
class ZoneDeleteTest extends TestCase
|
||||
{
|
||||
public function testDeleteTest()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/deleteZoneTest.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/023e105f4ecef8ad9ca31a8372d0c353')
|
||||
);
|
||||
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
||||
$result = $zones->deleteZone('023e105f4ecef8ad9ca31a8372d0c353');
|
||||
$this->assertTrue($result);
|
||||
$this->assertEquals('9a7806061c88ada191ed06f989cc3dac', $zones->getBody()->result->id);
|
||||
}
|
||||
}
|
||||
8
tests/Fixtures/Endpoints/deleteZoneTest.json
Normal file
8
tests/Fixtures/Endpoints/deleteZoneTest.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": {
|
||||
"id": "9a7806061c88ada191ed06f989cc3dac"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user