1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- class CryptoTest extends TestCase
- {
- public function testGetOpportunisticEncryptionSetting()
- {
- $response = $this->getPsr7JsonResponseForFixture('Endpoints/getOpportunisticEncryptionSetting.json');
- $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
- $mock->method('get')->willReturn($response);
- $mock->expects($this->once())
- ->method('get')
- ->with(
- $this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/settings/opportunistic_encryption')
- );
- $cryptoMock = new \Cloudflare\API\Endpoints\Crypto($mock);
- $result = $cryptoMock->getOpportunisticEncryptionSetting('c2547eb745079dac9320b638f5e225cf483cc5cfdda41');
- $this->assertEquals('off', $result);
- }
- public function testGetOnionRoutingSetting()
- {
- $response = $this->getPsr7JsonResponseForFixture('Endpoints/getOnionRoutingSetting.json');
- $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
- $mock->method('get')->willReturn($response);
- $mock->expects($this->once())
- ->method('get')
- ->with(
- $this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/settings/opportunistic_onion')
- );
- $cryptoMock = new \Cloudflare\API\Endpoints\Crypto($mock);
- $result = $cryptoMock->getOnionRoutingSetting('c2547eb745079dac9320b638f5e225cf483cc5cfdda41');
- $this->assertEquals('off', $result);
- }
- public function testUpdateOpportunisticEncryptionSetting()
- {
- $response = $this->getPsr7JsonResponseForFixture('Endpoints/updateOpportunisticEncryptionSetting.json');
- $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
- $mock->method('patch')->willReturn($response);
- $mock->expects($this->once())
- ->method('patch')
- ->with(
- $this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/settings/opportunistic_encryption'),
- $this->equalTo(['value' => 'off'])
- );
- $cryptoMock = new \Cloudflare\API\Endpoints\Crypto($mock);
- $result = $cryptoMock->updateOpportunisticEncryptionSetting('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', 'off');
- $this->assertTrue($result);
- }
- public function testUpdateOnionRoutingSetting()
- {
- $response = $this->getPsr7JsonResponseForFixture('Endpoints/updateOnionRoutingSetting.json');
- $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
- $mock->method('patch')->willReturn($response);
- $mock->expects($this->once())
- ->method('patch')
- ->with(
- $this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/settings/opportunistic_onion'),
- $this->equalTo(['value' => 'off'])
- );
- $cryptoMock = new \Cloudflare\API\Endpoints\Crypto($mock);
- $result = $cryptoMock->updateOnionRoutingSetting('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', 'off');
- $this->assertTrue($result);
- }
- }
|