Covers the five scenarios from convo thread research-cost-reaper seq 1: - test_reaps_orphan_with_matching_run_id_posts — meta lookup returns two post IDs; reaper delegates to amortize_research_costs which inserts two rows and deletes the orphan. - test_skips_orphan_within_grace_period — the SELECT's `created_at < now - 1h` clause filters fresh orphans at the DB; the reaper's stats stay zero and no side effects fire. - test_deletes_orphan_with_no_articles_after_7_days — orphan is 8 days old, zero siblings via meta or gen_log; reaper deletes outright. - test_falls_back_to_gen_log_when_post_meta_missing — meta returns empty (legacy pre-v0.8.1 post); gen_log has two distinct post_ids; amortize still runs. - test_idempotent_on_repeat_run — second pass on a cleaned state returns 0/0/0 with no inserts or deletes. All DB interaction mocked via $wpdb stub — no real DB round-trips. Fixtures are driven by property mutations in the test methods so PHPUnit's "one stub per method" restriction on mocks doesn't bite. Part of the v0.8.1 bundle. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
8.6 KiB
8.6 KiB