From cc58f9f1aad328e12a48a3d756d50b51aa61709c Mon Sep 17 00:00:00 2001 From: Thomas Roberts Date: Thu, 19 Sep 2024 17:33:18 +0100 Subject: [PATCH] Render a new checkout block to test data is added to registry correctly --- .../tests/php/src/Blocks/BlockTypes/Checkout.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/woocommerce/tests/php/src/Blocks/BlockTypes/Checkout.php b/plugins/woocommerce/tests/php/src/Blocks/BlockTypes/Checkout.php index e35635db506..f2b077e0f72 100644 --- a/plugins/woocommerce/tests/php/src/Blocks/BlockTypes/Checkout.php +++ b/plugins/woocommerce/tests/php/src/Blocks/BlockTypes/Checkout.php @@ -59,6 +59,13 @@ class Checkout extends \WP_UnitTestCase { // Now the post was saved with an updated localPickupText attribute, the title on Local Pickup settings should be updated. $pickup_location_settings = LocalPickupUtils::get_local_pickup_settings( 'edit' ); $this->assertEquals( 'Changed pickup', $pickup_location_settings['title'] ); + + // Create a new Checkout block class with the mocked AssetDataRegistry. This is so we can inspect it after the change. + $checkout = new \Automattic\WooCommerce\Blocks\BlockTypes\Checkout( $this->asset_api, $this->registry, $this->integration_registry, 'checkout-under-test' ); + $checkout->render_callback( [], $page_id ); + + $data_from_registry = $this->registry->get(); + $this->assertEquals( $data_from_registry['localPickupText'], 'Changed pickup' ); wp_delete_post( $page_id ); } }