Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit test for SKU failing #2556

Closed
mikkamp opened this issue Aug 22, 2024 · 1 comment · Fixed by #2559
Closed

Unit test for SKU failing #2556

mikkamp opened this issue Aug 22, 2024 · 1 comment · Fixed by #2559
Labels
type: technical debt This issue/PR represents/solves the technical debt of the project.

Comments

@mikkamp
Copy link
Contributor

mikkamp commented Aug 22, 2024

Describe the bug:

When running the unit tests with WooCommerce 9.2.1 the test for the SKU fails:

1) Automattic\WooCommerce\GoogleListingsAndAds\Tests\Unit\Product\AttributeMapping\AttributeMappingWCProductAdapterTest::test_maps_rules_product_fields_sku
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'DUMMY SKU'
+'DUMMY SKU56'

wp-content/plugins/google-listings-and-ads/tests/Unit/Product/AttributeMapping/AttributeMappingWCProductAdapterTest.php:115

FAILURES!
Tests: 1276, Assertions: 4031, Failures: 1.

Re-running the tests with 9.1.0 works again. I haven't checked what could be causing the error, but 9.2 introduced a global unique identifier field next to the SKU, so possibly there could be something conflicting there.

Steps to reproduce:

  1. Install latest versions for unit testing bin/install-wp-tests.sh <db_name> <db_user> <db_pass>
  2. Run unit tests `vendor/bin/phpunit
  3. Confirm that the test test_maps_rules_product_fields_sku fails

Expected behavior:

All unit tests to pass on the latest version of WooCommerce

@mikkamp mikkamp added the type: technical debt This issue/PR represents/solves the technical debt of the project. label Aug 22, 2024
@mikkamp
Copy link
Contributor Author

mikkamp commented Aug 22, 2024

Seems this is directly related to the change here where each generated SKU is made unique.

We should either compare the SKU directly from the created helper product, or compare only the SKU prefix without the number as a suffix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: technical debt This issue/PR represents/solves the technical debt of the project.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant