|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Copyright (c) 2026 BELNEM s.r.o. html2wp Source-Available Licence — see LICENSE. |
| 3 | +# |
| 4 | +# The test WordPress holds still: a fresh `test-env.sh up` runs the pinned |
| 5 | +# WordPress, and WordPress's own update checks (the wp-cron events that |
| 6 | +# installed 7.1.2 over an idle 7.0.2 preview, maintenance mode included) |
| 7 | +# change nothing: same version afterwards, no .maintenance file, and the |
| 8 | +# updater reports itself disabled. |
| 9 | +# Needs Docker. Uses its own throwaway env and removes it. |
| 10 | +set -uo pipefail |
| 11 | +HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 12 | +command -v docker >/dev/null || { echo "SKIP: docker not available"; exit 0; } |
| 13 | +TMP="$(mktemp -d)"; SLUG="p-pinned-$$" |
| 14 | +cleanup() { (cd "$TMP" && bash "$HERE/test-env.sh" down "$SLUG" >/dev/null 2>&1); rm -rf "$TMP"; } |
| 15 | +trap cleanup EXIT |
| 16 | +fail=0; check() { if [ "$2" = "$3" ]; then echo " ok $1"; else echo " FAIL $1: got '$2', want '$3'"; fail=1; fi; } |
| 17 | + |
| 18 | +cd "$TMP" |
| 19 | +bash "$HERE/test-env.sh" up "$SLUG" > up.log 2>&1 || { echo "up failed:"; tail -20 up.log; exit 1; } |
| 20 | +WP="$(python3 -c "import json;print(json.load(open('.test-env-$SLUG.json'))['wpCli'])")" |
| 21 | +# The version the image ships, read from the image's own copy: the pin is the |
| 22 | +# digest, so the test never hardcodes a WordPress release. |
| 23 | +IMG="$($WP eval 'include "/usr/src/wordpress/wp-includes/version.php"; echo $wp_version;' 2>/dev/null)" |
| 24 | +before="$($WP core version)" |
| 25 | +check "a fresh up runs the image's WordPress" "$before" "$IMG" |
| 26 | +check "the updater is off" "$($WP eval 'require_once ABSPATH."wp-admin/includes/class-wp-automatic-updater.php"; echo (new WP_Automatic_Updater())->is_disabled() ? "off" : "on";')" "off" |
| 27 | +$WP cron event run wp_version_check >/dev/null 2>&1 |
| 28 | +$WP cron event run wp_maybe_auto_update >/dev/null 2>&1 |
| 29 | +check "after WordPress's own update run: same version" "$($WP core version)" "$before" |
| 30 | +check "no maintenance mode left behind" "$($WP eval 'echo file_exists(ABSPATH.".maintenance") ? "present" : "absent";')" "absent" |
| 31 | + |
| 32 | +[ "$fail" = 0 ] && echo "ALL OK" || { echo "FAILED"; exit 1; } |
0 commit comments