فهرست منبع

[tests] Move utility method into base test class.

Daniele Alessandri 9 سال پیش
والد
کامیت
843ad23ea7

+ 26 - 0
tests/PHPUnit/PredisTestCase.php

@@ -203,6 +203,32 @@ abstract class PredisTestCase extends \PHPUnit_Framework_TestCase
         return $client;
     }
 
+    /**
+     * Returns a base mocked connection from Predis\Connection\NodeConnectionInterface.
+     *
+     * @param mixed $parameters Optional parameters.
+     *
+     * @return mixed
+     */
+    protected function getMockConnection($parameters = null)
+    {
+        $connection = $this->getMock('Predis\Connection\NodeConnectionInterface');
+
+        if ($parameters) {
+            $parameters = Connection\Parameters::create($parameters);
+            $hash = "{$parameters->host}:{$parameters->port}";
+
+            $connection->expects($this->any())
+                       ->method('getParameters')
+                       ->will($this->returnValue($parameters));
+            $connection->expects($this->any())
+                       ->method('__toString')
+                       ->will($this->returnValue($hash));
+        }
+
+        return $connection;
+    }
+
     /**
      * Returns the server version of the Redis instance used by the test suite.
      *

+ 0 - 26
tests/Predis/ClientTest.php

@@ -892,30 +892,4 @@ class ClientTest extends PredisTestCase
 
         return $uriString;
     }
-
-    /**
-     * Returns a base mocked connection from Predis\Connection\NodeConnectionInterface.
-     *
-     * @param mixed $parameters Optional parameters.
-     *
-     * @return mixed
-     */
-    protected function getMockConnection($parameters = null)
-    {
-        $connection = $this->getMock('Predis\Connection\NodeConnectionInterface');
-
-        if ($parameters) {
-            $parameters = \Predis\Connection\Parameters::create($parameters);
-            $hash = "{$parameters->host}:{$parameters->port}";
-
-            $connection->expects($this->any())
-                       ->method('getParameters')
-                       ->will($this->returnValue($parameters));
-            $connection->expects($this->any())
-                       ->method('__toString')
-                       ->will($this->returnValue($hash));
-        }
-
-        return $connection;
-    }
 }

+ 0 - 30
tests/Predis/Connection/Aggregate/MasterSlaveReplicationTest.php

@@ -1170,34 +1170,4 @@ repl_backlog_histlen:12978
         $this->assertEquals($master, $unserialized->getConnectionById('master'));
         $this->assertEquals($slave1, $unserialized->getConnectionById('slave1'));
     }
-
-    // ******************************************************************** //
-    // ---- HELPER METHODS ------------------------------------------------ //
-    // ******************************************************************** //
-
-    /**
-     * Returns a base mocked connection from Predis\Connection\NodeConnectionInterface.
-     *
-     * @param mixed $parameters Optional parameters.
-     *
-     * @return mixed
-     */
-    protected function getMockConnection($parameters = null)
-    {
-        $connection = $this->getMock('Predis\Connection\NodeConnectionInterface');
-
-        if ($parameters) {
-            $parameters = Connection\Parameters::create($parameters);
-            $hash = "{$parameters->host}:{$parameters->port}";
-
-            $connection->expects($this->any())
-                       ->method('getParameters')
-                       ->will($this->returnValue($parameters));
-            $connection->expects($this->any())
-                       ->method('__toString')
-                       ->will($this->returnValue($hash));
-        }
-
-        return $connection;
-    }
 }

+ 0 - 30
tests/Predis/Connection/Aggregate/PredisClusterTest.php

@@ -397,34 +397,4 @@ class PredisClusterTest extends PredisTestCase
 
         $this->assertEquals($cluster, $unserialized);
     }
-
-    // ******************************************************************** //
-    // ---- HELPER METHODS ------------------------------------------------ //
-    // ******************************************************************** //
-
-    /**
-     * Returns a base mocked connection from Predis\Connection\NodeConnectionInterface.
-     *
-     * @param mixed $parameters Optional parameters.
-     *
-     * @return mixed
-     */
-    protected function getMockConnection($parameters = null)
-    {
-        $connection = $this->getMock('Predis\Connection\NodeConnectionInterface');
-
-        if ($parameters) {
-            $parameters = Connection\Parameters::create($parameters);
-            $hash = "{$parameters->host}:{$parameters->port}";
-
-            $connection->expects($this->any())
-                       ->method('getParameters')
-                       ->will($this->returnValue($parameters));
-            $connection->expects($this->any())
-                       ->method('__toString')
-                       ->will($this->returnValue($hash));
-        }
-
-        return $connection;
-    }
 }

+ 0 - 30
tests/Predis/Connection/Aggregate/RedisClusterTest.php

@@ -1157,34 +1157,4 @@ class RedisClusterTest extends PredisTestCase
 
         $this->assertEquals($cluster, $unserialized);
     }
-
-    // ******************************************************************** //
-    // ---- HELPER METHODS ------------------------------------------------ //
-    // ******************************************************************** //
-
-    /**
-     * Returns a base mocked connection from Predis\Connection\NodeConnectionInterface.
-     *
-     * @param mixed $parameters Optional parameters.
-     *
-     * @return mixed
-     */
-    protected function getMockConnection($parameters = null)
-    {
-        $connection = $this->getMock('Predis\Connection\NodeConnectionInterface');
-
-        if ($parameters) {
-            $parameters = Connection\Parameters::create($parameters);
-            $hash = "{$parameters->host}:{$parameters->port}";
-
-            $connection->expects($this->any())
-                       ->method('getParameters')
-                       ->will($this->returnValue($parameters));
-            $connection->expects($this->any())
-                       ->method('__toString')
-                       ->will($this->returnValue($hash));
-        }
-
-        return $connection;
-    }
 }

+ 0 - 26
tests/Predis/Connection/Aggregate/SentinelReplicationTest.php

@@ -1216,30 +1216,4 @@ class SentinelReplicationTest extends PredisTestCase
 
         return $connection;
     }
-
-    /**
-     * Returns a base mocked connection from Predis\Connection\NodeConnectionInterface.
-     *
-     * @param mixed $parameters Optional parameters.
-     *
-     * @return mixed
-     */
-    protected function getMockConnection($parameters = null)
-    {
-        $connection = $this->getMock('Predis\Connection\NodeConnectionInterface');
-
-        if ($parameters) {
-            $parameters = Connection\Parameters::create($parameters);
-            $hash = "{$parameters->host}:{$parameters->port}";
-
-            $connection->expects($this->any())
-                       ->method('getParameters')
-                       ->will($this->returnValue($parameters));
-            $connection->expects($this->any())
-                       ->method('__toString')
-                       ->will($this->returnValue($hash));
-        }
-
-        return $connection;
-    }
 }