Browse Source

[tests] Handle failing test on OS X.

Daniele Alessandri 11 years ago
parent
commit
6ce09a2a8b
1 changed files with 8 additions and 2 deletions
  1. 8 2
      tests/PHPUnit/ConnectionTestCase.php

+ 8 - 2
tests/PHPUnit/ConnectionTestCase.php

@@ -281,11 +281,17 @@ abstract class ConnectionTestCase extends StandardTestCase
     /**
     /**
      * @group connected
      * @group connected
      * @group slow
      * @group slow
-     * @expectedException Predis\Connection\ConnectionException
-     * @expectedExceptionMessage Connection timed out
      */
      */
     public function testThrowsExceptionOnConnectionTimeout()
     public function testThrowsExceptionOnConnectionTimeout()
     {
     {
+        // We must differentiate here since OS X can randomly emit up to three
+        // different error messages while other platforms are more consistent.
+        if (strcasecmp(PHP_OS, 'darwin') == 0) {
+            $this->setExpectedException('Predis\Connection\ConnectionException');
+        } else {
+            $this->setExpectedException('Predis\Connection\ConnectionException', 'Connection timed out');
+        }
+
         $connection = $this->getConnection($_, false, array('host' => '169.254.10.10', 'timeout' => 0.5));
         $connection = $this->getConnection($_, false, array('host' => '169.254.10.10', 'timeout' => 0.5));
 
 
         $connection->connect();
         $connection->connect();