IPsTest.php 927 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: junade
  5. * Date: 04/09/2017
  6. * Time: 20:16
  7. */
  8. class IPsTest extends TestCase
  9. {
  10. public function testListIPs()
  11. {
  12. $response = $this->getPsr7JsonResponseForFixture('Endpoints/listIPs.json');
  13. $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
  14. $mock->method('get')->willReturn($response);
  15. $mock->expects($this->once())
  16. ->method('get')
  17. ->with(
  18. $this->equalTo('ips')
  19. );
  20. $ipsMock = new \Cloudflare\API\Endpoints\IPs($mock);
  21. $ips = $ipsMock->listIPs();
  22. $this->assertObjectHasAttribute('ipv4_cidrs', $ips);
  23. $this->assertObjectHasAttribute('ipv6_cidrs', $ips);
  24. $this->assertObjectHasAttribute('ipv4_cidrs', $ipsMock->getBody()->result);
  25. $this->assertObjectHasAttribute('ipv6_cidrs', $ipsMock->getBody()->result);
  26. }
  27. }