From 487678711887f5863bee031458c65a5f95133d83 Mon Sep 17 00:00:00 2001 From: Junade Ali Date: Mon, 4 Sep 2017 20:22:23 +0100 Subject: [PATCH] COM-40 :: Added None Auth class, IPs endpoint and associated tests --- src/Auth/None.php | 18 +++++++++++ src/Endpoints/IPs.php | 30 ++++++++++++++++++ {tests => src}/Endpoints/PageRules.php | 0 tests/Auth/NoneTest.php | 20 ++++++++++++ tests/Endpoints/IPsTest.php | 42 ++++++++++++++++++++++++++ 5 files changed, 110 insertions(+) create mode 100644 src/Auth/None.php create mode 100644 src/Endpoints/IPs.php rename {tests => src}/Endpoints/PageRules.php (100%) create mode 100644 tests/Auth/NoneTest.php create mode 100644 tests/Endpoints/IPsTest.php diff --git a/src/Auth/None.php b/src/Auth/None.php new file mode 100644 index 0000000..aa203e3 --- /dev/null +++ b/src/Auth/None.php @@ -0,0 +1,18 @@ +adapter = $adapter; + } + + public function get(): \stdClass { + $ips = $this->adapter->get('ips', []); + $body = json_decode($ips->getBody()); + + return $body->result; + } + +} \ No newline at end of file diff --git a/tests/Endpoints/PageRules.php b/src/Endpoints/PageRules.php similarity index 100% rename from tests/Endpoints/PageRules.php rename to src/Endpoints/PageRules.php diff --git a/tests/Auth/NoneTest.php b/tests/Auth/NoneTest.php new file mode 100644 index 0000000..7fcc81f --- /dev/null +++ b/tests/Auth/NoneTest.php @@ -0,0 +1,20 @@ +getHeaders(); + + $this->assertEquals([], $headers); + } +} diff --git a/tests/Endpoints/IPsTest.php b/tests/Endpoints/IPsTest.php new file mode 100644 index 0000000..35726f4 --- /dev/null +++ b/tests/Endpoints/IPsTest.php @@ -0,0 +1,42 @@ + 'application/json'], $stream); + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('get')->willReturn($response); + + $mock->expects($this->once()) + ->method('get') + ->with($this->equalTo('ips'), $this->equalTo([]) + ); + + $ips = new \Cloudflare\API\Endpoints\IPs($mock); + $ips = $ips->get(); + $this->assertObjectHasAttribute("ipv4_cidrs", $ips); + $this->assertObjectHasAttribute("ipv6_cidrs", $ips); + } +}