07ed1703ba
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>
36 lines
981 B
PHP
36 lines
981 B
PHP
<?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);
|
|
}
|
|
}
|