Przeglądaj źródła

[test] Use phpunit to specify the parameters of the server used by the suite.

This is especially handy because users can now easily override them without
modifying the source code of the test suite and just by creating a phpunit.xml
file that is automatically picked up by phpunit over the phpunit.xml.dist file
shipped within the repository.
Daniele Alessandri 13 lat temu
rodzic
commit
2c1f349925
2 zmienionych plików z 11 dodań i 4 usunięć
  1. 7 0
      phpunit.xml.dist
  2. 4 4
      test/PredisShared.php

+ 7 - 0
phpunit.xml.dist

@@ -12,4 +12,11 @@
             <directory suffix=".php">lib/Predis/</directory>
         </whitelist>
     </filter>
+
+    <php>
+        <const name="TEST_SERVER_VERSION" value="2.2" />
+        <const name="TEST_SERVER_HOST" value="127.0.0.1" />
+        <const name="TEST_SERVER_PORT" value="6379" />
+        <const name="TEST_SERVER_DBNUM" value="15" />
+    </php>
 </phpunit>

+ 4 - 4
test/PredisShared.php

@@ -26,10 +26,10 @@ if (!function_exists('array_union')) {
 
 class RC
 {
-    const SERVER_VERSION   = '2.2';
-    const SERVER_HOST      = '127.0.0.1';
-    const SERVER_PORT      = 6379;
-    const DEFAULT_DATABASE = 15;
+    const SERVER_VERSION   = TEST_SERVER_VERSION;
+    const SERVER_HOST      = TEST_SERVER_HOST;
+    const SERVER_PORT      = TEST_SERVER_PORT;
+    const DEFAULT_DATABASE = TEST_SERVER_DBNUM;
 
     const WIPE_OUT         = 1;
     const EXCEPTION_WRONG_TYPE     = 'ERR Operation against a key holding the wrong kind of value';