Skip to content

Commit e1afd9b

Browse files
Fabien Villepintenikic
authored andcommitted
Modernize some connectors in tests to remove env key duplication
1 parent a12ebc2 commit e1afd9b

File tree

3 files changed

+31
-31
lines changed

3 files changed

+31
-31
lines changed

ext/ldap/tests/connect.inc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ Default values are "localhost", "cn=Manager,dc=my-domain,dc=com", and password "
55
Change the LDAP_TEST_* environment values if you want to use another configuration.
66
*/
77

8-
$host = getenv("LDAP_TEST_HOST") ? getenv("LDAP_TEST_HOST") : "localhost";
9-
$port = getenv("LDAP_TEST_PORT") ? getenv("LDAP_TEST_PORT") : 389;
10-
$base = getenv("LDAP_TEST_BASE") ? getenv("LDAP_TEST_BASE") : "dc=my-domain,dc=com";
11-
$user = getenv("LDAP_TEST_USER") ? getenv("LDAP_TEST_USER") : "cn=Manager,$base";
12-
$sasl_user = getenv("LDAP_TEST_SASL_USER") ? getenv("LDAP_TEST_SASL_USER") : "Manager";
13-
$passwd = getenv("LDAP_TEST_PASSWD") ? getenv("LDAP_TEST_PASSWD") : "secret";
14-
$protocol_version = getenv("LDAP_TEST_OPT_PROTOCOL_VERSION") ? getenv("LDAP_TEST_OPT_PROTOCOL_VERSION") : 3;
15-
$skip_on_bind_failure = getenv("LDAP_TEST_SKIP_BIND_FAILURE") ? getenv("LDAP_TEST_SKIP_BIND_FAILURE") : true;
8+
$host = getenv("LDAP_TEST_HOST") ?: "localhost";
9+
$port = getenv("LDAP_TEST_PORT") ?: 389;
10+
$base = getenv("LDAP_TEST_BASE") ?: "dc=my-domain,dc=com";
11+
$user = getenv("LDAP_TEST_USER") ?: "cn=Manager,$base";
12+
$sasl_user = getenv("LDAP_TEST_SASL_USER") ?: "Manager";
13+
$passwd = getenv("LDAP_TEST_PASSWD") ?: "secret";
14+
$protocol_version = getenv("LDAP_TEST_OPT_PROTOCOL_VERSION") ?: 3;
15+
$skip_on_bind_failure = getenv("LDAP_TEST_SKIP_BIND_FAILURE") ?: true;
1616

1717
function ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version) {
1818
$link = ldap_connect($host, $port);

ext/mysqli/tests/connect.inc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88

99
$driver = new mysqli_driver;
1010

11-
$host = getenv("MYSQL_TEST_HOST") ? getenv("MYSQL_TEST_HOST") : "localhost";
12-
$port = getenv("MYSQL_TEST_PORT") ? getenv("MYSQL_TEST_PORT") : 3306;
13-
$user = getenv("MYSQL_TEST_USER") ? getenv("MYSQL_TEST_USER") : "root";
14-
$passwd = getenv("MYSQL_TEST_PASSWD") ? getenv("MYSQL_TEST_PASSWD") : "";
15-
$db = getenv("MYSQL_TEST_DB") ? getenv("MYSQL_TEST_DB") : "test";
16-
$engine = getenv("MYSQL_TEST_ENGINE") ? getenv("MYSQL_TEST_ENGINE") : "MyISAM";
17-
$socket = getenv("MYSQL_TEST_SOCKET") ? getenv("MYSQL_TEST_SOCKET") : null;
18-
$skip_on_connect_failure = getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") ? getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") : true;
19-
$connect_flags = getenv("MYSQL_TEST_CONNECT_FLAGS") ? (int)getenv("MYSQL_TEST_CONNECT_FLAGS") : 0;
11+
$host = getenv("MYSQL_TEST_HOST") ?: "localhost";
12+
$port = getenv("MYSQL_TEST_PORT") ?: 3306;
13+
$user = getenv("MYSQL_TEST_USER") ?: "root";
14+
$passwd = getenv("MYSQL_TEST_PASSWD") ?: "";
15+
$db = getenv("MYSQL_TEST_DB") ?: "test";
16+
$engine = getenv("MYSQL_TEST_ENGINE") ?: "MyISAM";
17+
$socket = getenv("MYSQL_TEST_SOCKET") ?: null;
18+
$skip_on_connect_failure = getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") ?: true;
19+
$connect_flags = (int)getenv("MYSQL_TEST_CONNECT_FLAGS") ?: 0;
2020
if ($socket) {
2121
ini_set('mysqli.default_socket', $socket);
2222
}

ext/snmp/tests/snmp_include.inc

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@ requests and 'private' community for write requests.
66
Default timeout is 1000ms and there will be one request performed.
77
*/
88

9-
$hostname4 = getenv('SNMP_HOSTNAME') ? getenv('SNMP_HOSTNAME') : '127.0.0.1';
10-
$hostname6 = getenv('SNMP_HOSTNAME6') ? getenv('SNMP_HOSTNAME6') : '::1';
11-
$port = getenv('SNMP_PORT') ? getenv('SNMP_PORT') : '161';
9+
$hostname4 = getenv('SNMP_HOSTNAME') ?: '127.0.0.1';
10+
$hostname6 = getenv('SNMP_HOSTNAME6') ?: '::1';
11+
$port = getenv('SNMP_PORT') ?: '161';
1212
$hostname = "$hostname4:$port";
1313
$hostname6_port = "[$hostname6]:$port";
14-
$community = getenv('SNMP_COMMUNITY') ? getenv('SNMP_COMMUNITY') : 'public';
15-
$communityWrite = getenv('SNMP_COMMUNITY_WRITE')? getenv('SNMP_COMMUNITY_WRITE'):'private';
14+
$community = getenv('SNMP_COMMUNITY') ?: 'public';
15+
$communityWrite = getenv('SNMP_COMMUNITY_WRITE')?:'private';
1616

17-
$timeout = getenv('SNMP_TIMEOUT') ? getenv('SNMP_TIMEOUT') : -1;
18-
$retries = getenv('SNMP_RETRIES') ? getenv('SNMP_RETRIES') : 1;
17+
$timeout = getenv('SNMP_TIMEOUT') ?: -1;
18+
$retries = getenv('SNMP_RETRIES') ?: 1;
1919

2020
if (stristr(PHP_OS, "FreeBSD")) {
21-
$mibdir = getenv('SNMP_MIBDIR') ? getenv('SNMP_MIBDIR') : "/usr/local/share/snmp/mibs";
21+
$mibdir = getenv('SNMP_MIBDIR') ?: "/usr/local/share/snmp/mibs";
2222
} else {
23-
$mibdir = getenv('SNMP_MIBDIR') ? getenv('SNMP_MIBDIR') : "/usr/share/snmp/mibs";
23+
$mibdir = getenv('SNMP_MIBDIR') ?: "/usr/share/snmp/mibs";
2424
}
2525

2626

27-
$user_noauth = getenv('SNMP_USER_NOAUTH') ? getenv('SNMP_USER_NOAUTH') : 'noAuthUser';
28-
$user_auth_prefix = getenv('SNMP_USER_PREFIX') ? getenv('SNMP_USER_PREFIX') : 'admin';
29-
$rwuser = getenv('SNMP_RWUSER') ? getenv('SNMP_RWUSER') : ($user_auth_prefix . 'MD5AES');
30-
$auth_pass = getenv('SNMP_AUTH_PASS') ? getenv('SNMP_AUTH_PASS') : 'test1234';
31-
$priv_pass = getenv('SNMP_PRIV_PASS') ? getenv('SNMP_PRIV_PASS') : 'test1234';
27+
$user_noauth = getenv('SNMP_USER_NOAUTH') ?: 'noAuthUser';
28+
$user_auth_prefix = getenv('SNMP_USER_PREFIX') ?: 'admin';
29+
$rwuser = getenv('SNMP_RWUSER') ?: ($user_auth_prefix . 'MD5AES');
30+
$auth_pass = getenv('SNMP_AUTH_PASS') ?: 'test1234';
31+
$priv_pass = getenv('SNMP_PRIV_PASS') ?: 'test1234';

0 commit comments

Comments
 (0)