This commit removes unnecessary clean up code form some unit tests. All database changes done during a test are automatically reverted after the test finishes, so it is not necessary to write code to manually remove them. This change simplifies the test code and make it run a bit faster.
This commit removes a bunch of unnecessary cleanup code from cart tests. All database changes are automatically reverted after each test, so it is not necessary to write code inside the test to manually revert the changes that were made. One test method was split into three different methods for clarity and to avoid having to revert database changes manually between each part of the test.
This change makes the tests easier to read but also reduced the execution time of the cart tests in about 15%.
I noticed that the structured data generated by WooCommerce doesn't pass Google Structured Data validation (https://search.google.com/structured-data/testing-tool) due to the following error in the last element of the BreadcrumbList:
"The value provided for item.id must be a valid URL."
This happens because the code was explicitly omitting the URL for the last element. This commit simply removes this check and now an URL is included for every element (unless there is no URL set).
This commit removes an unneeded call to wc_clean() before outputting product structured data to the browser. wp_json_encode() is called before the data is sent to the browser and it should be enough to escape it. wc_clean(), which calls sanitize_text_field() internally, was causing issues with the product URL when its name contained some non-ASCII characters (see #21057 for examples of characters).
Use the refund currency when wc_price() is called to display the refund amount in the "Edit order" admin screen. Without this change, wc_price would use the store default currency which is a problem for stores that at some point changed their currency or stores using extensions which support multiple currencies.