fix(wpmc 1.1.0): review polish — continue on bad permalink, ACF guard, drop suppress_filters, process-isolated AJAX test
tests / phpunit (push) Has been cancelled

- Redirect::handle: continue instead of return when get_permalink fails on a row (allow trying next row)
- Helpers::acf_ready() now public so Redirect can guard get_field('page_unic', ...) consistently
- Drop suppress_filters=false from get_posts (was risky on sites with query-altering plugins)
- @runInSeparateProcess for DOING_AJAX test (replaces Z-prefix ordering hack)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Vladimir Bryzgalov
2026-05-19 02:30:26 +05:00
parent 9b1689dc2f
commit 07ed1703ba
3 changed files with 17 additions and 13 deletions
+35
View File
@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace WPMultiCity\Tests;
use WPMultiCity\Redirect;
/**
* Isolated test for the DOING_AJAX bail-out in Redirect::handle().
*
* Isolation is achieved via @runInSeparateProcess on the test method, which
* forks a fresh PHP process so that defining the DOING_AJAX constant cannot
* contaminate other tests (e.g. RouterTest). The previous Z-prefix ordering
* hack is no longer needed.
*/
final class RedirectDoingAjaxTest extends TestCase
{
/**
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
public function test_bail_when_doing_ajax(): void
{
if (!\defined('DOING_AJAX')) {
\define('DOING_AJAX', true);
}
\Brain\Monkey\Functions\stubs(['did_action' => 1]);
\Brain\Monkey\Functions\when('is_admin')->justReturn(false);
\Brain\Monkey\Functions\expect('wp_safe_redirect')->never();
Redirect::handle();
self::assertTrue(true);
}
}