Skip to content

Instantly share code, notes, and snippets.

@allendav
Created March 16, 2018 17:08
Show Gist options
  • Save allendav/47658545cedfb8f05eb1effe918d5f08 to your computer and use it in GitHub Desktop.
Save allendav/47658545cedfb8f05eb1effe918d5f08 to your computer and use it in GitHub Desktop.
Jetpack WooCommerce Whitelist Unit Test
diff --git a/tests/php/sync/test_class.jetpack-sync-woocommerce.php b/tests/php/sync/test_class.jetpack-sync-woocommerce.php
index 161cbb62a..ecbc54c7e 100644
--- a/tests/php/sync/test_class.jetpack-sync-woocommerce.php
+++ b/tests/php/sync/test_class.jetpack-sync-woocommerce.php
@@ -171,6 +171,43 @@ class WP_Test_Jetpack_Sync_WooCommerce extends WP_Test_Jetpack_Sync_Base {
$this->assertTrue( !! $deleted_order_item_meta_event );
}
+ function test_updated_personal_data_item_meta_is_not_synched() {
+ $order = $this->createOrderWithItem();
+ $order_items = $order->get_items();
+ $order_item = reset( $order_items ); // first item
+
+ $personal_data_meta_keys = array(
+ '_billing_first_name',
+ '_billing_last_name',
+ '_billing_company',
+ '_billing_address_1',
+ '_billing_address_2',
+ '_billing_email',
+ '_billing_phone',
+ '_shipping_first_name',
+ '_shipping_last_name',
+ '_shipping_company',
+ '_shipping_address_1',
+ '_shipping_address_2',
+ '_transaction_id',
+ '_customer_ip_address',
+ '_customer_user_agent',
+ );
+
+ foreach ( (array) $personal_data_meta_keys as $personal_data_meta_key ) {
+ wc_add_order_item_meta( $order_item->get_id(), $personal_data_meta_key, 'bar', true );
+ wc_update_order_item_meta( $order_item->get_id(), $personal_data_meta_key, 'baz' );
+
+ $this->sender->do_sync();
+
+ $added_order_item_meta_event = $this->server_event_storage->get_most_recent_event( 'added_order_item_meta' );
+ $this->assertFalse( $added_order_item_meta_event );
+
+ $updated_order_item_meta_event = $this->server_event_storage->get_most_recent_event( 'updated_order_item_meta' );
+ $this->assertFalse( $updated_order_item_meta_event );
+ }
+ }
+
// Full Sync
function test_full_sync_order_items() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment