#!/usr/bin/env bash
set -euo pipefail

site_url="${WP_URL:-http://utopiqueplugins.local/}"
wp_bin="${WP_BIN:-/usr/local/bin/wp}"
local_socket="${LOCAL_MYSQL_SOCKET:-}"

if [[ -z "$local_socket" ]]; then
    printf '%s\n' 'Set LOCAL_MYSQL_SOCKET to the Local MySQL socket before running the smoke test.' >&2
    exit 2
fi

php -d "mysqli.default_socket=$local_socket" \
    -d "pdo_mysql.default_socket=$local_socket" \
    "$wp_bin" --url="$site_url" eval-file tests/smoke.php
