api eliminazione lista
This commit is contained in:
@@ -70,6 +70,15 @@ class RulesLists implements API
|
||||
return $this->body->result;
|
||||
}
|
||||
|
||||
public function deleteList(string $accountId, string $listId)
|
||||
{
|
||||
|
||||
$response = $this->adapter->delete('accounts/' . $accountId . '/rules/lists/' . $listId);
|
||||
$this->body = json_decode($response->getBody());
|
||||
|
||||
return $this->body->result;
|
||||
}
|
||||
|
||||
public function createListItem(string $accountId, string $listId, array $ip)
|
||||
{
|
||||
$options = [];
|
||||
|
||||
@@ -35,6 +35,27 @@ class RulesListsTest extends TestCase
|
||||
$this->assertEquals('2c0fc9fa937b11eaa1b71c4d701ab86e', $rulesLists->getBody()->result->id);
|
||||
}
|
||||
|
||||
public function testDeleteRulesList()
|
||||
{
|
||||
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/deleteRulesList.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('post')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('delete')
|
||||
->with(
|
||||
$this->equalTo('accounts/01a7362d577a6c3019a474fd6f485823/rules/lists/2c0fc9fa937b11eaa1b71c4d701ab86e')
|
||||
);
|
||||
|
||||
$rulesLists = new \Cloudflare\API\Endpoints\RulesLists($mock);
|
||||
$result = $rulesLists->deleteList('01a7362d577a6c3019a474fd6f485823', '2c0fc9fa937b11eaa1b71c4d701ab86e');
|
||||
|
||||
$this->assertEquals(true, $result->success);
|
||||
$this->assertEquals(true, $rulesLists->getBody()->result->success);
|
||||
}
|
||||
|
||||
public function testGetRulesLists()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/listRulesLists.json');
|
||||
|
||||
18
tests/Fixtures/Endpoints/deleteRulesList.json
Executable file
18
tests/Fixtures/Endpoints/deleteRulesList.json
Executable file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"errors": [
|
||||
{
|
||||
"code": 1000,
|
||||
"message": "message"
|
||||
}
|
||||
],
|
||||
"messages": [
|
||||
{
|
||||
"code": 1000,
|
||||
"message": "message"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"id": "34b12448945f11eaa1b71c4d701ab86e"
|
||||
},
|
||||
"success": true
|
||||
}
|
||||
Reference in New Issue
Block a user