Files
wp-multi-city/tests/TestCase.php
T
Vladimir Bryzgalov 494061e39f feat(wpmc S4): TermMeta registers ACF main_page_alt on taxonomy town
Add acf-stubs.php + TestCase::setUp() require-after-Patchwork pattern so
acf_add_local_field_group is Patchwork-instrumented and re-interceptable
across FieldGroupTest and TermMetaTest in the same PHP process.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 19:33:39 +05:00

40 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
namespace WPMultiCity\Tests;
use Brain\Monkey;
use PHPUnit\Framework\TestCase as BaseTestCase;
use WPMultiCity\Helpers;
use WPMultiCity\ShortcodeDmr;
abstract class TestCase extends BaseTestCase
{
protected function setUp(): void
{
parent::setUp();
Monkey\setUp();
// Load ACF stubs through Patchwork's stream wrapper (AFTER setUp activates it)
// so the functions can be redefined across test classes in the same process.
require_once __DIR__ . '/acf-stubs.php';
Monkey\Functions\stubTranslationFunctions();
Monkey\Functions\when('shortcode_atts')->alias(function (array $defaults, array $atts): array {
return array_merge($defaults, array_intersect_key($atts, $defaults));
});
Helpers::reset_cache();
ShortcodeDmr::reset_cache();
}
protected function tearDown(): void
{
unset(
$_SERVER['REQUEST_URI'],
$GLOBALS['wp_query'],
$GLOBALS['wp_the_query'],
$GLOBALS['post']
);
Monkey\tearDown();
parent::tearDown();
}
}