Adapter::get, post, put, patch and delete all had non-optional parameters for $headers and $query or $body. These have been made optional. I also re-ordered the parameters as $headers was never used while $query/$body were heavily used. I also condensed and removed some duplicate calls so that every call to Adapter::get/post sends that call to Adapter::request. It could use a magic method to do this but it might make it more difficult to test.
35 lines
995 B
PHP
35 lines
995 B
PHP
<?php
|
|
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: junade
|
|
* Date: 05/09/2017
|
|
* Time: 13:50
|
|
*/
|
|
class ConfigurationsZoneLockdownTest extends TestCase
|
|
{
|
|
public function testGetArray()
|
|
{
|
|
$configuration = new \Cloudflare\API\Configurations\ZoneLockdown();
|
|
$configuration->addIP('1.2.3.4');
|
|
|
|
$array = $configuration->getArray();
|
|
$this->assertCount(1, $array);
|
|
|
|
$this->assertArrayHasKey('target', $array[0]);
|
|
$this->assertEquals('ip', $array[0]['target']);
|
|
$this->assertArrayHasKey('value', $array[0]);
|
|
$this->assertEquals('1.2.3.4', $array[0]['value']);
|
|
|
|
$configuration->addIPRange('1.2.3.4/24');
|
|
|
|
$array = $configuration->getArray();
|
|
$this->assertCount(2, $array);
|
|
|
|
$this->assertArrayHasKey('target', $array[1]);
|
|
$this->assertEquals('ip_range', $array[1]['target']);
|
|
$this->assertArrayHasKey('value', $array[1]);
|
|
$this->assertEquals('1.2.3.4/24', $array[1]['value']);
|
|
}
|
|
}
|