Applied PSR2 formatting to existing files

This commit is contained in:
Anthony Sterling
2017-09-23 18:50:51 +01:00
parent 90196ea836
commit 2faff272df
33 changed files with 144 additions and 103 deletions

View File

@@ -72,4 +72,4 @@ interface Adapter
* @return mixed * @return mixed
*/ */
public function delete(String $uri, array $headers, array $body): ResponseInterface; public function delete(String $uri, array $headers, array $body): ResponseInterface;
} }

View File

@@ -7,7 +7,6 @@
namespace Cloudflare\API\Adapter; namespace Cloudflare\API\Adapter;
use Cloudflare\API\Auth\Auth; use Cloudflare\API\Auth\Auth;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
@@ -44,7 +43,6 @@ class Guzzle implements Adapter
$this->checkError($response); $this->checkError($response);
return $response; return $response;
} }
/** /**
@@ -52,7 +50,9 @@ class Guzzle implements Adapter
*/ */
public function post(String $uri, array $headers = array(), array $body = array()): ResponseInterface public function post(String $uri, array $headers = array(), array $body = array()): ResponseInterface
{ {
$response = $this->client->post($uri, [ $response = $this->client->post(
$uri,
[
'headers' => $headers, 'headers' => $headers,
'json' => $body 'json' => $body
] ]
@@ -69,7 +69,9 @@ class Guzzle implements Adapter
{ {
$jsonBody = json_encode($body); $jsonBody = json_encode($body);
$response = $this->client->put($uri, [ $response = $this->client->put(
$uri,
[
'headers' => $headers, 'headers' => $headers,
'json' => $jsonBody 'json' => $jsonBody
] ]
@@ -86,7 +88,9 @@ class Guzzle implements Adapter
{ {
$jsonBody = json_encode($body); $jsonBody = json_encode($body);
$response = $this->client->patch($uri, [ $response = $this->client->patch(
$uri,
[
'headers' => $headers, 'headers' => $headers,
'json' => $jsonBody 'json' => $jsonBody
] ]
@@ -101,7 +105,9 @@ class Guzzle implements Adapter
*/ */
public function delete(String $uri, array $headers = array(), array $body = array()): ResponseInterface public function delete(String $uri, array $headers = array(), array $body = array()): ResponseInterface
{ {
$response = $this->client->delete($uri, [ $response = $this->client->delete(
$uri,
[
'headers' => $headers, 'headers' => $headers,
'json' => $body 'json' => $body
] ]

View File

@@ -8,8 +8,6 @@
namespace Cloudflare\API\Adapter; namespace Cloudflare\API\Adapter;
class JSONException extends \Exception class JSONException extends \Exception
{ {
}
}

View File

@@ -8,8 +8,6 @@
namespace Cloudflare\API\Adapter; namespace Cloudflare\API\Adapter;
class ResponseException extends \Exception class ResponseException extends \Exception
{ {
}
}

View File

@@ -7,7 +7,6 @@
namespace Cloudflare\API\Auth; namespace Cloudflare\API\Auth;
class APIKey implements Auth class APIKey implements Auth
{ {
private $email; private $email;
@@ -26,4 +25,4 @@ class APIKey implements Auth
'X-Auth-Key' => $this->apiKey 'X-Auth-Key' => $this->apiKey
]; ];
} }
} }

View File

@@ -7,8 +7,7 @@
namespace Cloudflare\API\Auth; namespace Cloudflare\API\Auth;
interface Auth interface Auth
{ {
public function getHeaders(): array; public function getHeaders(): array;
} }

View File

@@ -8,11 +8,10 @@
namespace Cloudflare\API\Auth; namespace Cloudflare\API\Auth;
class None implements Auth class None implements Auth
{ {
public function getHeaders(): array public function getHeaders(): array
{ {
return []; return [];
} }
} }

View File

@@ -7,7 +7,6 @@
namespace Cloudflare\API\Auth; namespace Cloudflare\API\Auth;
class UserServiceKey implements Auth class UserServiceKey implements Auth
{ {
private $userServiceKey; private $userServiceKey;
@@ -23,4 +22,4 @@ class UserServiceKey implements Auth
'X-Auth-User-Service-Key' => $this->userServiceKey, 'X-Auth-User-Service-Key' => $this->userServiceKey,
]; ];
} }
} }

View File

@@ -8,8 +8,7 @@
namespace Cloudflare\API\Configurations; namespace Cloudflare\API\Configurations;
interface Configurations interface Configurations
{ {
public function getArray(): array; public function getArray(): array;
} }

View File

@@ -8,8 +8,6 @@
namespace Cloudflare\API\Configurations; namespace Cloudflare\API\Configurations;
class ConfigurationsException extends \Exception class ConfigurationsException extends \Exception
{ {
}
}

View File

@@ -366,4 +366,4 @@ class PageRulesActions implements Configurations
{ {
return $this->configs; return $this->configs;
} }
} }

View File

@@ -8,7 +8,6 @@
namespace Cloudflare\API\Configurations; namespace Cloudflare\API\Configurations;
class PageRulesTargets implements Configurations class PageRulesTargets implements Configurations
{ {
private $targets; private $targets;
@@ -28,4 +27,4 @@ class PageRulesTargets implements Configurations
{ {
return $this->targets; return $this->targets;
} }
} }

View File

@@ -8,7 +8,6 @@
namespace Cloudflare\API\Configurations; namespace Cloudflare\API\Configurations;
class UARules implements Configurations class UARules implements Configurations
{ {
private $configs = array(); private $configs = array();
@@ -26,4 +25,4 @@ class UARules implements Configurations
{ {
return $this->configs; return $this->configs;
} }
} }

View File

@@ -8,7 +8,6 @@
namespace Cloudflare\API\Configurations; namespace Cloudflare\API\Configurations;
class ZoneLockdown implements Configurations class ZoneLockdown implements Configurations
{ {
private $configs = array(); private $configs = array();
@@ -35,4 +34,4 @@ class ZoneLockdown implements Configurations
{ {
return $this->configs; return $this->configs;
} }
} }

View File

@@ -7,10 +7,9 @@
namespace Cloudflare\API\Endpoints; namespace Cloudflare\API\Endpoints;
use Cloudflare\API\Adapter\Adapter; use Cloudflare\API\Adapter\Adapter;
interface API interface API
{ {
public function __construct(Adapter $adapter); public function __construct(Adapter $adapter);
} }

View File

@@ -121,5 +121,4 @@ class DNS implements API
return false; return false;
} }
}
}

View File

@@ -8,8 +8,6 @@
namespace Cloudflare\API\Endpoints; namespace Cloudflare\API\Endpoints;
class EndpointException extends \Exception class EndpointException extends \Exception
{ {
}
}

View File

@@ -8,7 +8,6 @@
namespace Cloudflare\API\Endpoints; namespace Cloudflare\API\Endpoints;
use Cloudflare\API\Adapter\Adapter; use Cloudflare\API\Adapter\Adapter;
class IPs implements API class IPs implements API
@@ -20,10 +19,11 @@ class IPs implements API
$this->adapter = $adapter; $this->adapter = $adapter;
} }
public function listIPs(): \stdClass { public function listIPs(): \stdClass
{
$ips = $this->adapter->get('ips', [], []); $ips = $this->adapter->get('ips', [], []);
$body = json_decode($ips->getBody()); $body = json_decode($ips->getBody());
return $body->result; return $body->result;
} }
} }

View File

@@ -8,7 +8,6 @@
namespace Cloudflare\API\Endpoints; namespace Cloudflare\API\Endpoints;
use Cloudflare\API\Adapter\Adapter; use Cloudflare\API\Adapter\Adapter;
use Cloudflare\API\Configurations\PageRulesActions; use Cloudflare\API\Configurations\PageRulesActions;
use Cloudflare\API\Configurations\PageRulesTargets; use Cloudflare\API\Configurations\PageRulesTargets;
@@ -146,4 +145,4 @@ class PageRules implements API
return false; return false;
} }
} }

View File

@@ -46,7 +46,6 @@ class UARules implements API
string $id = null, string $id = null,
string $description = null string $description = null
): bool { ): bool {
$options = [ $options = [
'mode' => $mode, 'mode' => $mode,
'configurations' => $configuration->getArray() 'configurations' => $configuration->getArray()
@@ -85,7 +84,6 @@ class UARules implements API
\Cloudflare\API\Configurations\UARules $configuration, \Cloudflare\API\Configurations\UARules $configuration,
string $description = null string $description = null
): bool { ): bool {
$options = [ $options = [
'mode' => $mode, 'mode' => $mode,
'id' => $ruleID, 'id' => $ruleID,
@@ -119,4 +117,4 @@ class UARules implements API
return false; return false;
} }
} }

View File

@@ -7,7 +7,6 @@
namespace Cloudflare\API\Endpoints; namespace Cloudflare\API\Endpoints;
use Cloudflare\API\Adapter\Adapter; use Cloudflare\API\Adapter\Adapter;
class User implements API class User implements API
@@ -41,4 +40,4 @@ class User implements API
$response = $this->adapter->patch("user", [], $details); $response = $this->adapter->patch("user", [], $details);
return json_decode($response->getBody()); return json_decode($response->getBody());
} }
} }

View File

@@ -46,7 +46,6 @@ class ZoneLockdown implements API
string $id = null, string $id = null,
string $description = null string $description = null
): bool { ): bool {
$options = [ $options = [
'urls' => $urls, 'urls' => $urls,
'configurations' => $configuration->getArray() 'configurations' => $configuration->getArray()
@@ -85,7 +84,6 @@ class ZoneLockdown implements API
\Cloudflare\API\Configurations\ZoneLockdown $configuration, \Cloudflare\API\Configurations\ZoneLockdown $configuration,
string $description = null string $description = null
): bool { ): bool {
$options = [ $options = [
'urls' => $urls, 'urls' => $urls,
'id' => $lockdownID, 'id' => $lockdownID,
@@ -119,4 +117,4 @@ class ZoneLockdown implements API
return false; return false;
} }
} }

View File

@@ -63,8 +63,11 @@ class GuzzleTest extends PHPUnit_Framework_TestCase
public function testPatch() public function testPatch()
{ {
$response = $this->client->patch('https://httpbin.org/patch', [], $response = $this->client->patch(
['X-Patch-Test' => 'Testing a PATCH request.']); 'https://httpbin.org/patch',
[],
['X-Patch-Test' => 'Testing a PATCH request.']
);
$headers = $response->getHeaders(); $headers = $response->getHeaders();
$this->assertEquals("application/json", $headers["Content-Type"][0]); $this->assertEquals("application/json", $headers["Content-Type"][0]);
@@ -75,8 +78,11 @@ class GuzzleTest extends PHPUnit_Framework_TestCase
public function testDelete() public function testDelete()
{ {
$response = $this->client->delete('https://httpbin.org/delete', [], $response = $this->client->delete(
['X-Delete-Test' => 'Testing a DELETE request.']); 'https://httpbin.org/delete',
[],
['X-Delete-Test' => 'Testing a DELETE request.']
);
$headers = $response->getHeaders(); $headers = $response->getHeaders();
$this->assertEquals("application/json", $headers["Content-Type"][0]); $this->assertEquals("application/json", $headers["Content-Type"][0]);
@@ -124,9 +130,9 @@ class GuzzleTest extends PHPUnit_Framework_TestCase
$method->invokeArgs($this->client, [$response]); $method->invokeArgs($this->client, [$response]);
} }
public function testNotFound() { public function testNotFound()
{
$this->expectException(\GuzzleHttp\Exception\RequestException::class); $this->expectException(\GuzzleHttp\Exception\RequestException::class);
$response = $this->client->get('https://httpbin.org/status/404'); $response = $this->client->get('https://httpbin.org/status/404');
} }
} }

View File

@@ -19,6 +19,5 @@ class APIKeyTest extends PHPUnit_Framework_TestCase
$this->assertEquals('1234567893feefc5f0q5000bfo0c38d90bbeb', $headers['X-Auth-Key']); $this->assertEquals('1234567893feefc5f0q5000bfo0c38d90bbeb', $headers['X-Auth-Key']);
$this->assertEquals(2, sizeof($headers)); $this->assertEquals(2, sizeof($headers));
} }
} }

View File

@@ -14,10 +14,11 @@ class UserServiceKeyTest extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('X-Auth-User-Service-Key', $headers); $this->assertArrayHasKey('X-Auth-User-Service-Key', $headers);
$this->assertEquals('v1.0-e24fd090c02efcfecb4de8f4ff246fd5c75b48946fdf0ce26c59f91d0d90797b-cfa33fe60e8e34073c149323454383fc9005d25c9b4c502c2f063457ef65322eade065975001a0b4b4c591c5e1bd36a6e8f7e2d4fa8a9ec01c64c041e99530c2-07b9efe0acd78c82c8d9c690aacb8656d81c369246d7f996a205fe3c18e9254a', $this->assertEquals(
$headers['X-Auth-User-Service-Key']); 'v1.0-e24fd090c02efcfecb4de8f4ff246fd5c75b48946fdf0ce26c59f91d0d90797b-cfa33fe60e8e34073c149323454383fc9005d25c9b4c502c2f063457ef65322eade065975001a0b4b4c591c5e1bd36a6e8f7e2d4fa8a9ec01c64c041e99530c2-07b9efe0acd78c82c8d9c690aacb8656d81c369246d7f996a205fe3c18e9254a',
$headers['X-Auth-User-Service-Key']
);
$this->assertEquals(1, sizeof($headers)); $this->assertEquals(1, sizeof($headers));
} }
} }

View File

@@ -19,7 +19,9 @@ class ConfigurationsUARulesTest extends PHPUnit_Framework_TestCase
$this->assertObjectHasAttribute('target', $array[0]); $this->assertObjectHasAttribute('target', $array[0]);
$this->assertEquals('ua', $array[0]->target); $this->assertEquals('ua', $array[0]->target);
$this->assertObjectHasAttribute('value', $array[0]); $this->assertObjectHasAttribute('value', $array[0]);
$this->assertEquals('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4', $this->assertEquals(
$array[0]->value); 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4',
$array[0]->value
);
} }
} }

View File

@@ -10,7 +10,8 @@ use Cloudflare\API\Configurations\PageRulesTargets;
class PageRulesTargetTest extends PHPUnit_Framework_TestCase class PageRulesTargetTest extends PHPUnit_Framework_TestCase
{ {
public function testGetArray() { public function testGetArray()
{
$targets = new PageRulesTargets('junade.com/*'); $targets = new PageRulesTargets('junade.com/*');
$array = $targets->getArray(); $array = $targets->getArray();

View File

@@ -37,7 +37,9 @@ class DNSTest extends PHPUnit_Framework_TestCase
$mock->expects($this->once()) $mock->expects($this->once())
->method('post') ->method('post')
->with($this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records'), $this->equalTo([]), ->with(
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records'),
$this->equalTo([]),
$this->equalTo([ $this->equalTo([
'type' => 'A', 'type' => 'A',
'name' => 'example.com', 'name' => 'example.com',
@@ -88,7 +90,8 @@ class DNSTest extends PHPUnit_Framework_TestCase
$mock->expects($this->once()) $mock->expects($this->once())
->method('get') ->method('get')
->with($this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records'), ->with(
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records'),
$this->equalTo([ $this->equalTo([
'page' => 1, 'page' => 1,
'per_page' => 20, 'per_page' => 20,
@@ -102,7 +105,7 @@ class DNSTest extends PHPUnit_Framework_TestCase
); );
$zones = new \Cloudflare\API\Endpoints\DNS($mock); $zones = new \Cloudflare\API\Endpoints\DNS($mock);
$result = $zones->listRecords("023e105f4ecef8ad9ca31a8372d0c353","A", "example.com", "127.0.0.1", 1, 20, "type", "desc", "all"); $result = $zones->listRecords("023e105f4ecef8ad9ca31a8372d0c353", "A", "example.com", "127.0.0.1", 1, 20, "type", "desc", "all");
$this->assertObjectHasAttribute('result', $result); $this->assertObjectHasAttribute('result', $result);
$this->assertObjectHasAttribute('result_info', $result); $this->assertObjectHasAttribute('result_info', $result);
@@ -140,7 +143,8 @@ class DNSTest extends PHPUnit_Framework_TestCase
$mock->expects($this->once()) $mock->expects($this->once())
->method('get') ->method('get')
->with($this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records/372e67954025e0ba6aaa6d586b9e0b59'), ->with(
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records/372e67954025e0ba6aaa6d586b9e0b59'),
$this->equalTo([]) $this->equalTo([])
); );

View File

@@ -10,7 +10,8 @@ use Cloudflare\API\Endpoints\IPs;
class IPsTest extends PHPUnit_Framework_TestCase class IPsTest extends PHPUnit_Framework_TestCase
{ {
public function testListIPs() { public function testListIPs()
{
$stream = GuzzleHttp\Psr7\stream_for(' $stream = GuzzleHttp\Psr7\stream_for('
{ {
"success": true, "success": true,
@@ -31,7 +32,9 @@ class IPsTest extends PHPUnit_Framework_TestCase
$mock->expects($this->once()) $mock->expects($this->once())
->method('get') ->method('get')
->with($this->equalTo('ips'), $this->equalTo([]) ->with(
$this->equalTo('ips'),
$this->equalTo([])
); );
$ips = new \Cloudflare\API\Endpoints\IPs($mock); $ips = new \Cloudflare\API\Endpoints\IPs($mock);

View File

@@ -53,7 +53,9 @@ class PageRulesTest extends PHPUnit_Framework_TestCase
$mock->expects($this->once()) $mock->expects($this->once())
->method('post') ->method('post')
->with($this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/pagerules'), $this->equalTo([]), ->with(
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/pagerules'),
$this->equalTo([]),
$this->equalTo([ $this->equalTo([
'targets' => $target->getArray(), 'targets' => $target->getArray(),
'actions' => $action->getArray(), 'actions' => $action->getArray(),
@@ -116,7 +118,8 @@ class PageRulesTest extends PHPUnit_Framework_TestCase
$mock->expects($this->once()) $mock->expects($this->once())
->method('get') ->method('get')
->with($this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/pagerules'), ->with(
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/pagerules'),
$this->equalTo([ $this->equalTo([
'status' => 'active', 'status' => 'active',
'order' => 'status', 'order' => 'status',
@@ -170,7 +173,9 @@ class PageRulesTest extends PHPUnit_Framework_TestCase
$mock->expects($this->once()) $mock->expects($this->once())
->method('get') ->method('get')
->with($this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/pagerules/9a7806061c88ada191ed06f989cc3dac'), $this->equalTo([]) ->with(
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/pagerules/9a7806061c88ada191ed06f989cc3dac'),
$this->equalTo([])
); );
$pr = new \Cloudflare\API\Endpoints\PageRules($mock); $pr = new \Cloudflare\API\Endpoints\PageRules($mock);
@@ -220,7 +225,9 @@ class PageRulesTest extends PHPUnit_Framework_TestCase
$mock->expects($this->once()) $mock->expects($this->once())
->method('patch') ->method('patch')
->with($this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/pagerules'), $this->equalTo([]), ->with(
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/pagerules'),
$this->equalTo([]),
$this->equalTo([ $this->equalTo([
'targets' => $target->getArray(), 'targets' => $target->getArray(),
'actions' => $action->getArray(), 'actions' => $action->getArray(),
@@ -256,7 +263,9 @@ class PageRulesTest extends PHPUnit_Framework_TestCase
$mock->expects($this->once()) $mock->expects($this->once())
->method('delete') ->method('delete')
->with($this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/pagerules/9a7806061c88ada191ed06f989cc3dac'), $this->equalTo([]), ->with(
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/pagerules/9a7806061c88ada191ed06f989cc3dac'),
$this->equalTo([]),
$this->equalTo([]) $this->equalTo([])
); );

View File

@@ -45,7 +45,8 @@ class UARulesTest extends PHPUnit_Framework_TestCase
$mock->expects($this->once()) $mock->expects($this->once())
->method('get') ->method('get')
->with($this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/ua_rules'), ->with(
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/ua_rules'),
$this->equalTo([ $this->equalTo([
'page' => 1, 'page' => 1,
'per_page' => 20 'per_page' => 20
@@ -93,7 +94,9 @@ class UARulesTest extends PHPUnit_Framework_TestCase
$mock->expects($this->once()) $mock->expects($this->once())
->method('post') ->method('post')
->with($this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/ua_rules'), $this->equalTo([]), ->with(
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/ua_rules'),
$this->equalTo([]),
$this->equalTo([ $this->equalTo([
'mode' => 'js_challenge', 'mode' => 'js_challenge',
'id' => '372e67954025e0ba6aaa6d586b9e0b59', 'id' => '372e67954025e0ba6aaa6d586b9e0b59',
@@ -103,9 +106,13 @@ class UARulesTest extends PHPUnit_Framework_TestCase
); );
$ld = new \Cloudflare\API\Endpoints\UARules($mock); $ld = new \Cloudflare\API\Endpoints\UARules($mock);
$ld->createRule('023e105f4ecef8ad9ca31a8372d0c353', 'js_challenge', $config, $ld->createRule(
'023e105f4ecef8ad9ca31a8372d0c353',
'js_challenge',
$config,
'372e67954025e0ba6aaa6d586b9e0b59', '372e67954025e0ba6aaa6d586b9e0b59',
'Prevent access from abusive clients identified by this UserAgent to mitigate DDoS attack'); 'Prevent access from abusive clients identified by this UserAgent to mitigate DDoS attack'
);
} }
public function getRuleDetails() public function getRuleDetails()
@@ -135,7 +142,8 @@ class UARulesTest extends PHPUnit_Framework_TestCase
$mock->expects($this->once()) $mock->expects($this->once())
->method('get') ->method('get')
->with($this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/ua_rules/372e67954025e0ba6aaa6d586b9e0b59'), ->with(
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/ua_rules/372e67954025e0ba6aaa6d586b9e0b59'),
$this->equalTo([]) $this->equalTo([])
); );
@@ -175,7 +183,8 @@ class UARulesTest extends PHPUnit_Framework_TestCase
$mock->expects($this->once()) $mock->expects($this->once())
->method('put') ->method('put')
->with($this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/ua_rules/372e67954025e0ba6aaa6d586b9e0b59'), ->with(
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/ua_rules/372e67954025e0ba6aaa6d586b9e0b59'),
$this->equalTo([]), $this->equalTo([]),
$this->equalTo([ $this->equalTo([
'mode' => 'js_challenge', 'mode' => 'js_challenge',
@@ -186,9 +195,13 @@ class UARulesTest extends PHPUnit_Framework_TestCase
); );
$ld = new \Cloudflare\API\Endpoints\UARules($mock); $ld = new \Cloudflare\API\Endpoints\UARules($mock);
$ld->updateRule('023e105f4ecef8ad9ca31a8372d0c353', '372e67954025e0ba6aaa6d586b9e0b59', $ld->updateRule(
'js_challenge', $config, '023e105f4ecef8ad9ca31a8372d0c353',
'Restrict access to these endpoints to requests from a known IP address'); '372e67954025e0ba6aaa6d586b9e0b59',
'js_challenge',
$config,
'Restrict access to these endpoints to requests from a known IP address'
);
} }
public function testDeleteRule() public function testDeleteRule()
@@ -211,7 +224,8 @@ class UARulesTest extends PHPUnit_Framework_TestCase
$mock->expects($this->once()) $mock->expects($this->once())
->method('delete') ->method('delete')
->with($this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/ua_rules/372e67954025e0ba6aaa6d586b9e0b59'), ->with(
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/ua_rules/372e67954025e0ba6aaa6d586b9e0b59'),
$this->equalTo([]), $this->equalTo([]),
$this->equalTo([]) $this->equalTo([])
); );

View File

@@ -43,7 +43,8 @@ class ZoneLockdownTest extends PHPUnit_Framework_TestCase
$mock->expects($this->once()) $mock->expects($this->once())
->method('get') ->method('get')
->with($this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/lockdowns'), ->with(
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/lockdowns'),
$this->equalTo([ $this->equalTo([
'page' => 1, 'page' => 1,
'per_page' => 20, 'per_page' => 20,
@@ -91,7 +92,9 @@ class ZoneLockdownTest extends PHPUnit_Framework_TestCase
$mock->expects($this->once()) $mock->expects($this->once())
->method('post') ->method('post')
->with($this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/lockdowns'), $this->equalTo([]), ->with(
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/lockdowns'),
$this->equalTo([]),
$this->equalTo([ $this->equalTo([
'urls' => ["api.mysite.com/some/endpoint*"], 'urls' => ["api.mysite.com/some/endpoint*"],
'id' => '372e67954025e0ba6aaa6d586b9e0b59', 'id' => '372e67954025e0ba6aaa6d586b9e0b59',
@@ -101,9 +104,13 @@ class ZoneLockdownTest extends PHPUnit_Framework_TestCase
); );
$ld = new \Cloudflare\API\Endpoints\ZoneLockdown($mock); $ld = new \Cloudflare\API\Endpoints\ZoneLockdown($mock);
$ld->createLockdown('023e105f4ecef8ad9ca31a8372d0c353', ["api.mysite.com/some/endpoint*"], $config, $ld->createLockdown(
'023e105f4ecef8ad9ca31a8372d0c353',
["api.mysite.com/some/endpoint*"],
$config,
'372e67954025e0ba6aaa6d586b9e0b59', '372e67954025e0ba6aaa6d586b9e0b59',
'Restrict access to these endpoints to requests from a known IP address'); 'Restrict access to these endpoints to requests from a known IP address'
);
} }
public function testGetRecordDetails() public function testGetRecordDetails()
@@ -137,7 +144,8 @@ class ZoneLockdownTest extends PHPUnit_Framework_TestCase
$mock->expects($this->once()) $mock->expects($this->once())
->method('get') ->method('get')
->with($this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/lockdowns/372e67954025e0ba6aaa6d586b9e0b59'), ->with(
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/lockdowns/372e67954025e0ba6aaa6d586b9e0b59'),
$this->equalTo([]) $this->equalTo([])
); );
@@ -181,7 +189,8 @@ class ZoneLockdownTest extends PHPUnit_Framework_TestCase
$mock->expects($this->once()) $mock->expects($this->once())
->method('put') ->method('put')
->with($this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/lockdowns/372e67954025e0ba6aaa6d586b9e0b59'), ->with(
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/lockdowns/372e67954025e0ba6aaa6d586b9e0b59'),
$this->equalTo([]), $this->equalTo([]),
$this->equalTo([ $this->equalTo([
'urls' => ["api.mysite.com/some/endpoint*"], 'urls' => ["api.mysite.com/some/endpoint*"],
@@ -192,9 +201,13 @@ class ZoneLockdownTest extends PHPUnit_Framework_TestCase
); );
$ld = new \Cloudflare\API\Endpoints\ZoneLockdown($mock); $ld = new \Cloudflare\API\Endpoints\ZoneLockdown($mock);
$ld->updateLockdown('023e105f4ecef8ad9ca31a8372d0c353', '372e67954025e0ba6aaa6d586b9e0b59', $ld->updateLockdown(
["api.mysite.com/some/endpoint*"], $config, '023e105f4ecef8ad9ca31a8372d0c353',
'Restrict access to these endpoints to requests from a known IP address'); '372e67954025e0ba6aaa6d586b9e0b59',
["api.mysite.com/some/endpoint*"],
$config,
'Restrict access to these endpoints to requests from a known IP address'
);
} }
public function testDeleteLockdown() public function testDeleteLockdown()
@@ -221,7 +234,8 @@ class ZoneLockdownTest extends PHPUnit_Framework_TestCase
$mock->expects($this->once()) $mock->expects($this->once())
->method('delete') ->method('delete')
->with($this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/lockdowns/372e67954025e0ba6aaa6d586b9e0b59'), ->with(
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/lockdowns/372e67954025e0ba6aaa6d586b9e0b59'),
$this->equalTo([]), $this->equalTo([]),
$this->equalTo([]) $this->equalTo([])
); );

View File

@@ -70,7 +70,8 @@ class ZonesTest extends PHPUnit_Framework_TestCase
$mock->expects($this->once()) $mock->expects($this->once())
->method('post') ->method('post')
->with($this->equalTo('zones'), ->with(
$this->equalTo('zones'),
$this->equalTo([]), $this->equalTo([]),
$this->equalTo(['name' => 'example.com', 'jumpstart' => false]) $this->equalTo(['name' => 'example.com', 'jumpstart' => false])
); );
@@ -90,7 +91,8 @@ class ZonesTest extends PHPUnit_Framework_TestCase
$mock->expects($this->once()) $mock->expects($this->once())
->method('post') ->method('post')
->with($this->equalTo('zones'), ->with(
$this->equalTo('zones'),
$this->equalTo([]), $this->equalTo([]),
$this->equalTo(['name' => 'example.com', 'jumpstart' => true, 'organization' => $org]) $this->equalTo(['name' => 'example.com', 'jumpstart' => true, 'organization' => $org])
); );
@@ -115,7 +117,8 @@ class ZonesTest extends PHPUnit_Framework_TestCase
$mock->expects($this->once()) $mock->expects($this->once())
->method('put') ->method('put')
->with($this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/activation_check'), ->with(
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/activation_check'),
$this->equalTo([]), $this->equalTo([]),
$this->equalTo([]) $this->equalTo([])
); );
@@ -196,7 +199,8 @@ class ZonesTest extends PHPUnit_Framework_TestCase
$mock->expects($this->once()) $mock->expects($this->once())
->method('get') ->method('get')
->with($this->equalTo('zones'), ->with(
$this->equalTo('zones'),
$this->equalTo([ $this->equalTo([
'page' => 1, 'page' => 1,
'per_page' => 20, 'per_page' => 20,
@@ -289,7 +293,8 @@ class ZonesTest extends PHPUnit_Framework_TestCase
$mock->expects($this->once()) $mock->expects($this->once())
->method('get') ->method('get')
->with($this->equalTo('zones'), ->with(
$this->equalTo('zones'),
$this->equalTo([ $this->equalTo([
'page' => 1, 'page' => 1,
'per_page' => 20, 'per_page' => 20,
@@ -321,7 +326,8 @@ class ZonesTest extends PHPUnit_Framework_TestCase
$mock->expects($this->once()) $mock->expects($this->once())
->method('delete') ->method('delete')
->with($this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/purge_cache'), ->with(
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/purge_cache'),
$this->equalTo([]), $this->equalTo([]),
$this->equalTo(["purge_everything" => true]) $this->equalTo(["purge_everything" => true])
); );