Browse Source

Skip test when unable to connect network

chinpei215 8 years ago
parent
commit
4e5de59913
1 changed files with 21 additions and 4 deletions
  1. 21 4
      tests/TestCase/Network/SocketTest.php

+ 21 - 4
tests/TestCase/Network/SocketTest.php

@@ -260,7 +260,6 @@ class SocketTest extends TestCase
     /**
      * testEncrypt
      *
-     * @expectedException \Cake\Network\Exception\SocketException
      * @return void
      */
     public function testEnableCryptoSocketExceptionNoSsl()
@@ -270,8 +269,21 @@ class SocketTest extends TestCase
 
         // testing exception on no ssl socket server for ssl and tls methods
         $this->Socket = new Socket($configNoSslOrTls);
-        $this->Socket->connect();
-        $this->Socket->enableCrypto('sslv3', 'client');
+
+        try {
+            $this->Socket->connect();
+        } catch (SocketException $e) {
+            $this->markTestSkipped('Cannot test network, skipping.');
+        }
+
+        $e = null;
+        try {
+            $this->Socket->enableCrypto('sslv3', 'client');
+        } catch (SocketException $e) {
+        }
+
+        $this->assertNotNull($e);
+        $this->assertInstanceOf('Exception', $e->getPrevious());
     }
 
     /**
@@ -285,7 +297,12 @@ class SocketTest extends TestCase
 
         // testing exception on no ssl socket server for ssl and tls methods
         $this->Socket = new Socket($configNoSslOrTls);
-        $this->Socket->connect();
+
+        try {
+            $this->Socket->connect();
+        } catch (SocketException $e) {
+            $this->markTestSkipped('Cannot test network, skipping.');
+        }
 
         $e = null;
         try {