google-listings-and-ads icon indicating copy to clipboard operation
google-listings-and-ads copied to clipboard

Add wp_print_inline_script_tag within the WP Proxy class to facilitate testing the inline scripts

Open jorgemd24 opened this issue 1 year ago • 0 comments

Describe the bug:

This a follow-up of https://github.com/woocommerce/google-listings-and-ads/pull/2184

Currently, it is not possible to mock wp_print_inline_script_tag making it challenging to test various scenarios, like the scripts inserted for the gtag events. See this case:

https://github.com/woocommerce/google-listings-and-ads/blob/d65b577bda057b81b2a3b62ed1824e0aac611d77/src/Google/GlobalSiteTag.php#L285-L297

If we add wp_print_inline_script_tag within the WP Proxy class we will be able to mock the method and therefore to test different scenarios easily, similar what is done here:

https://github.com/woocommerce/google-listings-and-ads/blob/d65b577bda057b81b2a3b62ed1824e0aac611d77/tests/Unit/API/Google/AdsAssetTest.php#L132-L143

Expected behavior:

To be able to mock wp_print_inline_script_tag easily

Actual behavior:

Difficult to mock wp_print_inline_script_tag

Additional details:

jorgemd24 avatar Dec 15 '23 18:12 jorgemd24