This PR moves the JSON API responses used in the tests to fixture files within the tests folder. This allows reuse and the ability to lint/validate these fixtures if required - although not covered in this PR. I've added TestCase::getPsr7StreamForFixture and TestCase::getPsr7JsonResponseForFixture to reduce code duplication and enable some assertions around the expected fixures/responses. Thanks,
33 lines
822 B
PHP
33 lines
822 B
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: junade
|
|
* Date: 04/09/2017
|
|
* Time: 20:16
|
|
*/
|
|
|
|
use Cloudflare\API\Endpoints\IPs;
|
|
|
|
class IPsTest extends TestCase
|
|
{
|
|
public function testListIPs()
|
|
{
|
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/listIPs.json');
|
|
|
|
$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->listIPs();
|
|
$this->assertObjectHasAttribute("ipv4_cidrs", $ips);
|
|
$this->assertObjectHasAttribute("ipv6_cidrs", $ips);
|
|
}
|
|
}
|