From 16fc14da1a97901f4f6683278a9f351933a62a51 Mon Sep 17 00:00:00 2001 From: mikkamp Date: Thu, 22 Aug 2024 13:39:39 +0100 Subject: [PATCH 1/2] Use a fixed SKU number when creating an adapted product --- tests/Tools/HelperTrait/ProductTrait.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/Tools/HelperTrait/ProductTrait.php b/tests/Tools/HelperTrait/ProductTrait.php index c51755fe6c..4f67d19fbd 100644 --- a/tests/Tools/HelperTrait/ProductTrait.php +++ b/tests/Tools/HelperTrait/ProductTrait.php @@ -487,7 +487,12 @@ protected function generate_mock_image_attachment( int $product_id, string $imag * @return WCProductAdapter The adapted products with the rules applied. */ protected function generate_attribute_mapping_adapted_product( $rules, $categories = [] ) { - $product = WC_Helper_Product::create_simple_product( false ); + $product = WC_Helper_Product::create_simple_product( + false, + [ + 'sku' => 'Mapped Product SKU', + ] + ); $attributes = [ WC_Helper_Product::create_product_attribute_object( 'size', [ 's', 'xs' ] ), From 4c9d6db0973ea2ae7d6846ab5cece32fe52811ec Mon Sep 17 00:00:00 2001 From: mikkamp Date: Thu, 22 Aug 2024 13:39:49 +0100 Subject: [PATCH 2/2] Test for fixed SKU number --- .../AttributeMapping/AttributeMappingWCProductAdapterTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Unit/Product/AttributeMapping/AttributeMappingWCProductAdapterTest.php b/tests/Unit/Product/AttributeMapping/AttributeMappingWCProductAdapterTest.php index 528660be0d..51945d88bc 100644 --- a/tests/Unit/Product/AttributeMapping/AttributeMappingWCProductAdapterTest.php +++ b/tests/Unit/Product/AttributeMapping/AttributeMappingWCProductAdapterTest.php @@ -112,7 +112,7 @@ public function test_maps_rules_product_fields_sku() { $adapted_product = $this->generate_attribute_mapping_adapted_product( $rules ); $adapted_variation = $this->generate_attribute_mapping_adapted_product_variant( $rules ); - $this->assertEquals( 'DUMMY SKU', $adapted_product->getGtin() ); + $this->assertEquals( 'Mapped Product SKU', $adapted_product->getGtin() ); $this->assertEquals( 'DUMMY SKU VARIABLE HUGE BLUE ANY NUMBER', $adapted_variation->getGtin() ); }