Feature: add pause

This commit is contained in:
Kyle Yee
2019-06-06 15:00:57 +08:00
parent 44eb77f9ca
commit b04abe73bc
3 changed files with 46 additions and 0 deletions

View File

@@ -58,6 +58,21 @@ class Zones implements API
return false;
}
public function pause(string $zoneID, bool $paused = true): bool
{
$options = [
'paused' => $paused,
];
$user = $this->adapter->patch('zones/' . $zoneID, $options);
$this->body = json_decode($user->getBody());
if (isset($this->body->result->id)) {
return true;
}
return false;
}
public function listZones(
string $name = '',
string $status = '',

View File

@@ -49,6 +49,29 @@ class ZonesTest extends TestCase
$this->assertEquals('9a7806061c88ada191ed06f989cc3dac', $zones->getBody()->result->id);
}
public function testPauseTest()
{
$response = $this->getPsr7JsonResponseForFixture('Endpoints/pauseTest.json');
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
$mock->method('patch')->willReturn($response);
$mock->expects($this->once())
->method('patch')
->with(
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41'),
$this->equalTo([
'pause' => true,
])
);
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
$result = $zones->pause('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', true);
$this->assertTrue($result);
$this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $zones->getBody()->result->id);
}
public function testActivationTest()
{
$response = $this->getPsr7JsonResponseForFixture('Endpoints/activationTest.json');

View File

@@ -0,0 +1,8 @@
{
"success": true,
"errors": [],
"messages": [],
"result": {
"id": "023e105f4ecef8ad9ca31a8372d0c353"
}
}