diff --git a/tests/Integration/wp-basis-smoke.sh b/tests/Integration/wp-basis-smoke.sh index 4da025e..959c285 100644 --- a/tests/Integration/wp-basis-smoke.sh +++ b/tests/Integration/wp-basis-smoke.sh @@ -14,6 +14,7 @@ ADMIN_LOGIN=$(wp user list --role=administrator --field=user_login | head -1) PODS_WAS_ACTIVE=no wp plugin is-active pods && PODS_WAS_ACTIVE=yes ORIGINAL_DESCRIPTION=$(wp option get blogdescription) +ORIGINAL_BLOGNAME=$(wp eval 'echo get_option("blogname");') ORIGINAL_LOCATIONS=$(wp eval 'echo wp_json_encode(get_nav_menu_locations());') CREATED_POSTS=() MENU_ID="" @@ -24,6 +25,10 @@ cleanup() { done [ -n "$MENU_ID" ] && wp menu delete "$MENU_ID" >/dev/null 2>&1 || true wp option update blogdescription "$ORIGINAL_DESCRIPTION" >/dev/null 2>&1 || true + # Restore the stored (already escaped) form byte-exact, bypassing sanitize_option(). + LIT_BLOGNAME="$ORIGINAL_BLOGNAME" wp eval \ + 'global $wpdb; $wpdb->update($wpdb->options, ["option_value" => getenv("LIT_BLOGNAME")], ["option_name" => "blogname"]); wp_cache_delete("alloptions", "options"); wp_cache_delete("blogname", "options");' \ + >/dev/null 2>&1 || true LIT_LOCATIONS="$ORIGINAL_LOCATIONS" wp eval \ 'set_theme_mod("nav_menu_locations", (array) json_decode(getenv("LIT_LOCATIONS"), true));' >/dev/null 2>&1 || true wp eval-file "$PLUGIN/tests/Integration/pods-fixture.php" delete >/dev/null 2>&1 || true @@ -129,7 +134,24 @@ pass "revisions list and restore" ability lit/post-trash "{\"post_id\":$PERSON_ID,\"confirm\":true}" | jq -e '.changed[0].action == "trashed"' >/dev/null \ || fail "post-trash" [ "$(wp post get "$PERSON_ID" --field=post_status)" = "trash" ] || fail "entry not in trash" -pass "post-trash moves to trash" +PERSON_REV=$(tool lit-content-get "{\"post_id\":$PERSON_ID}" | jq -r '.rev') +TRASHED=$(tool lit-content-update "{\"post_id\":$PERSON_ID,\"rev\":\"$PERSON_REV\",\"title\":\"x\"}") +[ "$(error_code "$TRASHED")" = "validation_failed" ] || fail "update of a trashed entry accepted: $TRASHED" +pass "post-trash moves to trash; trashed entries are not updated" + +# 8b. A missed schedule is never published as a side effect of a write +MISSED=$(tool lit-content-create '{"post_type":"page","title":"LIT Smoke verpasst"}') +MISSED_ID=$(echo "$MISSED" | jq -r '.changed[0].id // empty') +[ -n "$MISSED_ID" ] || fail "content-create: $MISSED" +CREATED_POSTS+=("$MISSED_ID") +LIT_ID="$MISSED_ID" wp eval \ + 'global $wpdb; $wpdb->update($wpdb->posts, ["post_status" => "future", "post_date" => "2020-01-01 10:00:00", "post_date_gmt" => "2020-01-01 09:00:00"], ["ID" => (int) getenv("LIT_ID")]); clean_post_cache((int) getenv("LIT_ID"));' \ + >/dev/null +MISSED_REV=$(tool lit-content-get "{\"post_id\":$MISSED_ID}" | jq -r '.rev') +REFUSED=$(tool lit-content-update "{\"post_id\":$MISSED_ID,\"rev\":\"$MISSED_REV\",\"title\":\"x\"}") +[ "$(error_code "$REFUSED")" = "validation_failed" ] || fail "missed schedule updated: $REFUSED" +[ "$(wp post get "$MISSED_ID" --field=post_status)" = "future" ] || fail "missed schedule got published" +pass "content-update refuses a missed schedule instead of publishing it" # 9. Menus MENU=$(ability lit/menu-create '{"name":"LIT Smoke Menü"}') @@ -163,7 +185,14 @@ BLOCKED=$(ability lit/wp-settings-update '{"settings":{"admin_email":"x@example. ability lit/wp-settings-update '{"settings":{"blogdescription":"LIT Smoke Test"}}' \ | jq -e '.previous.blogdescription != null' >/dev/null || fail "wp-settings-update" [ "$(wp option get blogdescription)" = "LIT Smoke Test" ] || fail "blogdescription not updated" -pass "WordPress settings whitelist" +AMP='{"settings":{"blogname":"LIT Müller & Söhne","blogdescription":"LIT Smoke & Test"}}' +ability lit/wp-settings-update "$AMP" | jq -e '.ok == true' >/dev/null || fail "settings with & (first call)" +AGAIN=$(ability lit/wp-settings-update "$AMP") +echo "$AGAIN" | jq -e '.ok == true and (.changed | length) == 0 and .previous.blogname == "LIT Müller & Söhne"' >/dev/null \ + || fail "settings with & (second call): $AGAIN" +ability lit/wp-settings-get '{"group":"general"}' | jq -e '.settings[] | select(.key == "blogname") | .value == "LIT Müller & Söhne"' >/dev/null \ + || fail "wp-settings-get does not return blogname as typed" +pass "WordPress settings whitelist; text with & can be set twice and reads back as typed" # 11. Change log with client name PREFIX=$(wp db prefix)