Feature: add pause
This commit is contained in:
@@ -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 = '',
|
||||
|
||||
@@ -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');
|
||||
|
||||
8
tests/Fixtures/Endpoints/pauseTest.json
Normal file
8
tests/Fixtures/Endpoints/pauseTest.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": {
|
||||
"id": "023e105f4ecef8ad9ca31a8372d0c353"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user