Commit 0386b22efd6 for woocommerce

commit 0386b22efd69ae2283386495b9418544b83138db
Author: Vlad Olaru <vlad.olaru@automattic.com>
Date:   Sun Nov 15 21:34:11 2026 +0200

    [tests] Stop FiltererTest unregistering attribute taxonomies it did not register (#70995)

    test: Stop FiltererTest unregistering attribute taxonomies it did not register

    FiltererTest::tearDown() unregistered the taxonomy of every attribute
    in the database, not only the ones its test created. A test's own
    attributes are rolled back, but an attribute committed by a class
    fixture elsewhere keeps its row. Its taxonomy stayed unregistered while
    the row remained.

    UcpCart's class fixtures commit a "size" attribute and never delete it.
    After the first FiltererTest test, pa_size stayed unregistered. Every
    later fixture asking for "Size" found the existing attribute, skipped
    registering its taxonomy, and wp_insert_term() failed with
    invalid_taxonomy: 29 errors on WordPress 7.2-beta5. The full suite only
    passed because a process-isolated test that runs in between reinstalls
    the test database in its child process, which wipes the leaked row.

    Drop the loop. WC_Unit_Test_Case already unregisters, at each setup,
    every pa_* taxonomy that has no attribute row, which covers the
    taxonomies a FiltererTest test registers for its rolled-back attributes.

    Reproduction on trunk with WordPress 7.2-beta5: running UcpCart, then
    FiltererTest, POSProductVisibilitySyncTest and UcpProductMapperTest
    gives 29 errors before this change and none after.

    Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

diff --git a/plugins/woocommerce/changelog/test-filterer-keep-attribute-taxonomies b/plugins/woocommerce/changelog/test-filterer-keep-attribute-taxonomies
new file mode 100644
index 00000000000..c864e693a9a
--- /dev/null
+++ b/plugins/woocommerce/changelog/test-filterer-keep-attribute-taxonomies
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+Comment: Stop a product attribute filter test from unregistering attribute taxonomies that later tests use; no production change.
+
diff --git a/plugins/woocommerce/tests/php/src/Internal/ProductAttributesLookup/FiltererTest.php b/plugins/woocommerce/tests/php/src/Internal/ProductAttributesLookup/FiltererTest.php
index cb140e524f5..e452a692e46 100644
--- a/plugins/woocommerce/tests/php/src/Internal/ProductAttributesLookup/FiltererTest.php
+++ b/plugins/woocommerce/tests/php/src/Internal/ProductAttributesLookup/FiltererTest.php
@@ -84,13 +84,6 @@ class FiltererTest extends \WC_Unit_Test_Case {
 	 * Runs after each test.
 	 */
 	public function tearDown(): void {
-		$attribute_ids_by_name = wc_get_attribute_taxonomy_ids();
-		foreach ( array_keys( $attribute_ids_by_name ) as $attribute_name ) {
-			$attribute_name = wc_sanitize_taxonomy_name( $attribute_name );
-			$taxonomy_name  = wc_attribute_taxonomy_name( $attribute_name );
-			unregister_taxonomy( $taxonomy_name );
-		}
-
 		\WC_Cache_Helper::invalidate_cache_group( 'woocommerce-attributes' );
 		\WC_Query::reset_chosen_attributes();
 		parent::tearDown();