Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions rtc-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,19 @@ setup_wpcli() {
printf ' cp "%s/rtc-test.php" "%s/"\n' "${SCRIPT_DIR}" "${mu_plugins_dir}"
fi

# Ensure pretty permalinks are enabled because these tests use /wp-json/ endpoints
# and therefore require /wp-json/ routing to be available.
local perm_struct
perm_struct="$(wp "${WP_FLAGS[@]}" option get permalink_structure 2>/dev/null)" || perm_struct=""
if [ -z "${perm_struct}" ]; then
printf 'Permalinks: default (query-string) -- setting to /%%postname%%/\n'
wp "${WP_FLAGS[@]}" rewrite structure '/%postname%/' --hard >/dev/null 2>&1 \
|| die "Could not set permalink structure. Set it manually: Settings > Permalinks."
printf 'Permalinks: set to /%%postname%%/\n'
Comment on lines +824 to +830
Comment on lines +826 to +830
else
printf 'Permalinks: %s\n' "${perm_struct}"
fi

# Always use the dedicated rtctest user so setup controls the password.
# We generate the password here and either create or reset the account.
local rtctest_wp_pass
Expand Down Expand Up @@ -880,7 +893,7 @@ setup_wpcli() {
fi

# Check if SAVEQUERIES is already defined and enabled in wp-config.php.
savequeries_value=$(wp "${WP_FLAGS[@]}" config get SAVEQUERIES 2>/dev/null)
savequeries_value=$(wp "${WP_FLAGS[@]}" config get SAVEQUERIES 2>/dev/null || true)
if [ "$savequeries_value" = "true" ] || [ "$savequeries_value" = "1" ]; then
printf 'SAVEQUERIES: already enabled in wp-config.php\n'
# Enable SAVEQUERIES so the plugin can record per-request DB time.
Expand Down Expand Up @@ -943,18 +956,20 @@ setup_manual() {
printf 'WP-CLI not available. Manual setup steps:\n\n'
printf '1. Copy rtc-test.php to the site'"'"'s mu-plugins directory:\n'
printf ' cp rtc-test.php /path/to/wp-content/mu-plugins/\n\n'
printf '2. Enable RTC: WP Admin > Settings > Writing > "Enable early access to\n'
printf '2. Enable pretty permalinks: WP Admin > Settings > Permalinks\n'
printf ' (any structure other than "Plain" works; e.g. Post name)\n\n'
printf '3. Enable RTC: WP Admin > Settings > Writing > "Enable early access to\n'
printf ' real-time collaboration"\n\n'
printf '3. Note a post ID for an existing editor-role user you want to test with.\n\n'
printf '4. Copy .env.example to .env and fill in the required values:\n\n'
printf '4. Note a post ID for an existing editor-role user you want to test with.\n\n'
printf '5. Copy .env.example to .env and fill in the required values:\n\n'
printf ' cp .env.example .env\n\n'
printf ' Required values:\n'
printf ' WP_URL="%s"\n' "${WP_URL}"
printf ' WP_USER="<login>"\n'
printf ' WP_PASS="<password>"\n'
printf ' WP_PATH="<absolute path to WordPress root>"\n'
printf ' POST_ID=<post_id>\n\n'
printf '5. Then run:\n'
printf '6. Then run:\n'
printf ' bash rtc-test.sh refresh-auth # logs in and writes cookie jar + nonce\n\n'
printf 'After that, all test commands are available.\n'
}
Expand Down