43e3efc5a2
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>
31 lines
847 B
PHP
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);
|
|
}
|
|
}
|