ZoneSettingsTest.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. declare(strict_types=1);
  3. use Cloudflare\API\Adapter\Adapter;
  4. use Cloudflare\API\Endpoints\ZoneSettings;
  5. class ZoneSettingsTest extends TestCase
  6. {
  7. public function testGetServerSideExcludeSetting()
  8. {
  9. $response = $this->getPsr7JsonResponseForFixture('Endpoints/getServerSideExclude.json');
  10. $mock = $this->getMockBuilder(Adapter::class)->getMock();
  11. $mock->method('get')->willReturn($response);
  12. $mock->expects($this->once())->method('get');
  13. $zones = new ZoneSettings($mock);
  14. $result = $zones->getServerSideExcludeSetting('023e105f4ecef8ad9ca31a8372d0c353');
  15. $this->assertSame('on', $result);
  16. }
  17. public function testUpdateServerSideExcludeSetting()
  18. {
  19. $response = $this->getPsr7JsonResponseForFixture('Endpoints/updateServerSideExclude.json');
  20. $mock = $this->getMockBuilder(Adapter::class)->getMock();
  21. $mock->method('patch')->willReturn($response);
  22. $mock->expects($this->once())->method('patch');
  23. $zones = new ZoneSettings($mock);
  24. $result = $zones->updateServerSideExcludeSetting('023e105f4ecef8ad9ca31a8372d0c353', 'on');
  25. $this->assertSame('on', $result);
  26. }
  27. public function testGetBrowserCacheTtlSetting()
  28. {
  29. $response = $this->getPsr7JsonResponseForFixture('Endpoints/getBrowserCacheTtlSetting.json');
  30. $mock = $this->getMockBuilder(Adapter::class)->getMock();
  31. $mock->method('get')->willReturn($response);
  32. $mock->expects($this->once())->method('get');
  33. $zones = new ZoneSettings($mock);
  34. $result = $zones->getBrowserCacheTtlSetting('023e105f4ecef8ad9ca31a8372d0c353');
  35. $this->assertSame(14400, $result);
  36. }
  37. public function testUpdateBrowserCacheTtlSetting()
  38. {
  39. $response = $this->getPsr7JsonResponseForFixture('Endpoints/updateBrowserCacheTtlSetting.json');
  40. $mock = $this->getMockBuilder(Adapter::class)->getMock();
  41. $mock->method('patch')->willReturn($response);
  42. $mock->expects($this->once())->method('patch');
  43. $zones = new ZoneSettings($mock);
  44. $result = $zones->updateBrowserCacheTtlSetting('023e105f4ecef8ad9ca31a8372d0c353', 16070400);
  45. $this->assertTrue($result);
  46. }
  47. }