Skip to content

Commit 90d0465

Browse files
committed
Adapt socket test
1 parent a55018c commit 90d0465

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

features/config-create.feature

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,22 @@ Feature: Create a wp-config file
167167
And a find-socket.php file:
168168
"""
169169
<?php
170-
if ( file_exists( '/tmp/mysqld.sock' ) ) {
171-
echo '/tmp/mysqld.sock';
172-
} else if ( file_exists( '/var/run/mysqld/mysqld.sock' ) ) {
173-
echo '/var/run/mysqld/mysqld.sock';
174-
} else if ( file_exists( '/tmp/mysql.sock' ) ) {
175-
echo '/tmp/mysql.sock';
176-
} else {
177-
echo 'No socket found';
178-
exit(1);
170+
$environment_socket = getenv( 'WP_CLI_TEST_DBSOCKET' );
171+
$vendor_dir = \WP_CLI\Tests\Context\FeatureContext::get_vendor_dir();
172+
$locations = [
173+
$environment_socket,
174+
"{$vendor_dir}/wp-cli/wp-cli-tests/utils/mapped_socket_folder/mysqld.sock",
175+
'/var/run/mysqld/mysqld.sock',
176+
'/tmp/mysql.sock',
177+
];
178+
foreach ( $locations as $location ) {
179+
if ( ! empty( $location ) && file_exists( $location ) ) {
180+
echo $location;
181+
exit(0);
182+
}
179183
}
184+
echo 'No socket found';
185+
exit(1);
180186
"""
181187
182188
When I run `php find-socket.php`

0 commit comments

Comments
 (0)