]> granicus.if.org Git - php/commitdiff
Modernize some connectors in tests to remove env key duplication
authorFabien Villepinte <fabien.villepinte@displayce.com>
Tue, 27 Aug 2019 10:50:26 +0000 (12:50 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 30 Aug 2019 08:33:01 +0000 (10:33 +0200)
ext/ldap/tests/connect.inc
ext/mysqli/tests/connect.inc
ext/snmp/tests/snmp_include.inc

index b6366c02ac78801d9e0261591fea3bea2993b3fe..de41cca63c3886ff871fe55377492d446ffa59ea 100644 (file)
@@ -5,14 +5,14 @@ Default values are "localhost", "cn=Manager,dc=my-domain,dc=com", and password "
 Change the LDAP_TEST_* environment values if you want to use another configuration.
 */
 
-$host                  = getenv("LDAP_TEST_HOST")      ? getenv("LDAP_TEST_HOST")      : "localhost";
-$port                  = getenv("LDAP_TEST_PORT")      ? getenv("LDAP_TEST_PORT")      : 389;
-$base                  = getenv("LDAP_TEST_BASE")      ? getenv("LDAP_TEST_BASE")      : "dc=my-domain,dc=com";
-$user                  = getenv("LDAP_TEST_USER")      ? getenv("LDAP_TEST_USER")      : "cn=Manager,$base";
-$sasl_user             = getenv("LDAP_TEST_SASL_USER") ? getenv("LDAP_TEST_SASL_USER") : "Manager";
-$passwd                        = getenv("LDAP_TEST_PASSWD")    ? getenv("LDAP_TEST_PASSWD")    : "secret";
-$protocol_version      = getenv("LDAP_TEST_OPT_PROTOCOL_VERSION")      ? getenv("LDAP_TEST_OPT_PROTOCOL_VERSION")      : 3;
-$skip_on_bind_failure  = getenv("LDAP_TEST_SKIP_BIND_FAILURE") ? getenv("LDAP_TEST_SKIP_BIND_FAILURE") : true;
+$host                  = getenv("LDAP_TEST_HOST")      ?: "localhost";
+$port                  = getenv("LDAP_TEST_PORT")      ?: 389;
+$base                  = getenv("LDAP_TEST_BASE")      ?: "dc=my-domain,dc=com";
+$user                  = getenv("LDAP_TEST_USER")      ?: "cn=Manager,$base";
+$sasl_user             = getenv("LDAP_TEST_SASL_USER") ?: "Manager";
+$passwd                        = getenv("LDAP_TEST_PASSWD")    ?: "secret";
+$protocol_version      = getenv("LDAP_TEST_OPT_PROTOCOL_VERSION")      ?: 3;
+$skip_on_bind_failure  = getenv("LDAP_TEST_SKIP_BIND_FAILURE") ?: true;
 
 function ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version) {
        $link = ldap_connect($host, $port);
index 91167fa8044bf76c7120f058f633eed046e45d4a..c190e6f61fa856fa032c4b0eb402dd03b28b377d 100644 (file)
@@ -8,15 +8,15 @@
 
        $driver    = new mysqli_driver;
 
-       $host      = getenv("MYSQL_TEST_HOST")     ? getenv("MYSQL_TEST_HOST") : "localhost";
-       $port      = getenv("MYSQL_TEST_PORT")     ? getenv("MYSQL_TEST_PORT") : 3306;
-       $user      = getenv("MYSQL_TEST_USER")     ? getenv("MYSQL_TEST_USER") : "root";
-       $passwd    = getenv("MYSQL_TEST_PASSWD")   ? getenv("MYSQL_TEST_PASSWD") : "";
-       $db        = getenv("MYSQL_TEST_DB")       ? getenv("MYSQL_TEST_DB") : "test";
-       $engine    = getenv("MYSQL_TEST_ENGINE")   ? getenv("MYSQL_TEST_ENGINE") : "MyISAM";
-       $socket    = getenv("MYSQL_TEST_SOCKET")   ? getenv("MYSQL_TEST_SOCKET") : null;
-       $skip_on_connect_failure  = getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") ? getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") : true;
-       $connect_flags = getenv("MYSQL_TEST_CONNECT_FLAGS") ? (int)getenv("MYSQL_TEST_CONNECT_FLAGS") : 0;
+       $host      = getenv("MYSQL_TEST_HOST")     ?: "localhost";
+       $port      = getenv("MYSQL_TEST_PORT")     ?: 3306;
+       $user      = getenv("MYSQL_TEST_USER")     ?: "root";
+       $passwd    = getenv("MYSQL_TEST_PASSWD")   ?: "";
+       $db        = getenv("MYSQL_TEST_DB")       ?: "test";
+       $engine    = getenv("MYSQL_TEST_ENGINE")   ?: "MyISAM";
+       $socket    = getenv("MYSQL_TEST_SOCKET")   ?: null;
+       $skip_on_connect_failure  = getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") ?: true;
+       $connect_flags = (int)getenv("MYSQL_TEST_CONNECT_FLAGS") ?: 0;
        if ($socket) {
                ini_set('mysqli.default_socket', $socket);
        }
index caa0721890f7f4036bbae2b62d15c8ecfee7f961..d14de3effe8ce92d4ca707622d8cf1ccc8b29a3a 100644 (file)
@@ -6,26 +6,26 @@ requests and 'private' community for write requests.
 Default timeout is 1000ms and there will be one request performed.
 */
 
-$hostname4 =   getenv('SNMP_HOSTNAME')         ? getenv('SNMP_HOSTNAME') :     '127.0.0.1';
-$hostname6 =   getenv('SNMP_HOSTNAME6')        ? getenv('SNMP_HOSTNAME6') :    '::1';
-$port =                getenv('SNMP_PORT')             ? getenv('SNMP_PORT') :         '161';
+$hostname4 =   getenv('SNMP_HOSTNAME')         ?     '127.0.0.1';
+$hostname6 =   getenv('SNMP_HOSTNAME6')        ?:      '::1';
+$port =                getenv('SNMP_PORT')             ?:              '161';
 $hostname      = "$hostname4:$port";
 $hostname6_port = "[$hostname6]:$port";
-$community =   getenv('SNMP_COMMUNITY')        ? getenv('SNMP_COMMUNITY') :    'public';
-$communityWrite = getenv('SNMP_COMMUNITY_WRITE')? getenv('SNMP_COMMUNITY_WRITE'):'private';
+$community =   getenv('SNMP_COMMUNITY')        ?:      'public';
+$communityWrite = getenv('SNMP_COMMUNITY_WRITE')?:'private';
 
-$timeout =     getenv('SNMP_TIMEOUT') ?        getenv('SNMP_TIMEOUT') :        -1;
-$retries =     getenv('SNMP_RETRIES') ?        getenv('SNMP_RETRIES') :        1;
+$timeout =     getenv('SNMP_TIMEOUT') ?:       -1;
+$retries =     getenv('SNMP_RETRIES') ?:       1;
 
 if (stristr(PHP_OS, "FreeBSD")) {
-       $mibdir =       getenv('SNMP_MIBDIR')   ?       getenv('SNMP_MIBDIR') :         "/usr/local/share/snmp/mibs";
+       $mibdir =       getenv('SNMP_MIBDIR')   ?:              "/usr/local/share/snmp/mibs";
 } else {
-       $mibdir =       getenv('SNMP_MIBDIR')   ?       getenv('SNMP_MIBDIR') :         "/usr/share/snmp/mibs";
+       $mibdir =       getenv('SNMP_MIBDIR')   ?:              "/usr/share/snmp/mibs";
 }
 
 
-$user_noauth = getenv('SNMP_USER_NOAUTH') ?    getenv('SNMP_USER_NOAUTH') :    'noAuthUser';
-$user_auth_prefix = getenv('SNMP_USER_PREFIX') ? getenv('SNMP_USER_PREFIX') :  'admin';
-$rwuser =      getenv('SNMP_RWUSER') ?         getenv('SNMP_RWUSER') :         ($user_auth_prefix . 'MD5AES');
-$auth_pass =   getenv('SNMP_AUTH_PASS') ?      getenv('SNMP_AUTH_PASS') :      'test1234';
-$priv_pass =   getenv('SNMP_PRIV_PASS') ?      getenv('SNMP_PRIV_PASS') :      'test1234';
+$user_noauth = getenv('SNMP_USER_NOAUTH') ?:   'noAuthUser';
+$user_auth_prefix = getenv('SNMP_USER_PREFIX') ?:      'admin';
+$rwuser =      getenv('SNMP_RWUSER') ?:                ($user_auth_prefix . 'MD5AES');
+$auth_pass =   getenv('SNMP_AUTH_PASS') ?:     'test1234';
+$priv_pass =   getenv('SNMP_PRIV_PASS') ?:     'test1234';