]> granicus.if.org Git - php/commitdiff
Fix intermittent error in pdo_mysql___construct_options.phpt
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 6 Dec 2019 06:38:56 +0000 (07:38 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 6 Dec 2019 06:39:54 +0000 (07:39 +0100)
For the love of god, don't write tests based on mt_rand!

ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt
ext/pdo_mysql/tests/pdo_mysql_get_attribute.phpt

index 9482a13bfacabf70c7439d531651fa2fc85372e9..b7a52127c52bb3435cd6d6804a3ffa4135e7ea58 100644 (file)
@@ -76,9 +76,7 @@ MySQLPDOTest::skip();
                if (!is_object($db = new PDO($dsn, $user, $pass, array())))
                        printf("[002] Expecting object got %s/%s¸\n", gettype($db), $db);
 
-               do {
-                       $invalid = mt_rand(-1000, 1000);
-               } while (isset($valid_options[$invalid]));
+        $invalid = 999;
                if (is_object($db = new PDO($dsn, $user, $pass, array($invalid => true))))
                        printf("[003] [TODO][CHANGEREQUEST] Please, lets not ignore invalid options and bail out!\n");
 
index 2eb34cd07627413a55d47f77b779007f43e063c4..51310faa9e2855b4fc19ddfffbb0911a419cade5 100644 (file)
@@ -15,13 +15,6 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
        $db = MySQLPDOTest::factory();
        MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db));
 
-       function find_invalid_int($valid_options) {
-               do {
-                       $invalid = mt_rand(-10000, 10000);
-               } while (in_array($invalid, $valid_options));
-               return $invalid;
-       }
-
        function set_and_get($offset, $db, $attribute, $value) {
 
                $value_type = gettype($value);