示例#1
0
 /**
  * test configuring the context from the flat keys.
  *
  * @return void
  */
 public function testConfigContext()
 {
     $this->skipIf(!extension_loaded('openssl'), 'OpenSSL is not enabled cannot test SSL.');
     $this->skipIf(!empty(getenv('http_proxy')) || !empty(getenv('https_proxy')), 'Proxy detected and cannot test SSL.');
     $config = ['host' => 'smtp.gmail.com', 'port' => 465, 'timeout' => 5, 'ssl_verify_peer' => true, 'ssl_allow_self_signed' => false, 'ssl_verify_depth' => 5, 'ssl_verify_host' => true];
     $socket = new Socket($config);
     $socket->connect();
     $result = $socket->context();
     $this->assertTrue($result['ssl']['verify_peer']);
     $this->assertFalse($result['ssl']['allow_self_signed']);
     $this->assertEquals(5, $result['ssl']['verify_depth']);
     $this->assertEquals('smtp.gmail.com', $result['ssl']['CN_match']);
     $this->assertArrayNotHasKey('ssl_verify_peer', $socket->config());
     $this->assertArrayNotHasKey('ssl_allow_self_signed', $socket->config());
     $this->assertArrayNotHasKey('ssl_verify_host', $socket->config());
     $this->assertArrayNotHasKey('ssl_verify_depth', $socket->config());
 }
 /**
  * testReset method
  *
  * @return void
  */
 public function testReset()
 {
     $config = ['persistent' => true, 'host' => '127.0.0.1', 'protocol' => 'udp', 'port' => 80, 'timeout' => 20];
     $anotherSocket = new Socket($config);
     $anotherSocket->reset();
     $expected = ['persistent' => false, 'host' => 'localhost', 'protocol' => 'tcp', 'port' => 80, 'timeout' => 30];
     $this->assertEquals($expected, $anotherSocket->config(), 'Reset should cause config to return the defaults defined in _defaultConfig');
 }