Files
wp-multi-city/tests/ZRedirectDoingAjaxTest.php
T
Vladimir Bryzgalov 43e3efc5a2 feat(wpmc 1.1.0): Redirect::handle reverse-slug lookup on is_404
Replace old triggering-on-page_new semantics with washanyanya-style:
- template_redirect@1 + is_404() trigger
- get_posts(name=$slug, post_type=page, status=[private,publish])
- match candidate.ID against page_unic[i].page_new
- 301 to /<town>/<orig-canonical-path>/

Closes Gitea issue #1.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-19 02:22:24 +05:00

31 lines
847 B
PHP

<?php
declare(strict_types=1);
namespace WPMultiCity\Tests;
use WPMultiCity\Redirect;
/**
* Isolated test for the DOING_AJAX bail-out in Redirect::handle().
*
* Must be in a separate file sorted AFTER RouterTest so that defining the
* DOING_AJAX constant does not contaminate Router::route() tests in RouterTest,
* which also bails early when DOING_AJAX is true.
*/
final class ZRedirectDoingAjaxTest extends TestCase
{
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);
}
}