From 199883a05a477900d8993710d420fc51ef3caafc Mon Sep 17 00:00:00 2001 From: Vladimir Reznichenko Date: Mon, 9 Sep 2024 10:37:30 +0200 Subject: [PATCH] [dev] PSR-4 naming fixes in tests (part 1) (#51194) In this PR we address PSR-4 naming-related violations (class FQN vs path mismatches and co) in tests. --- .../changelog/dev-psr4-naming-fixes | 4 +++ .../tests/php/src/Blocks/Domain/Package.php | 6 ++--- .../Domain/Services/DeleteDraftOrders.php | 9 ++++--- .../src/Blocks/Domain/Services/Hydration.php | 3 ++- .../tests/php/src/Caching/OrderCacheTest.php | 3 +++ .../src/Database/BlockHooksVersionTests.php | 6 ++++- .../PostsToOrdersMigrationControllerTest.php | 12 ++++----- .../Internal/Admin/Orders/EditLockTest.php | 5 +++- .../Orders/DataSynchronizerTests.php | 10 +++++-- .../Orders/LegacyDataCleanupTests.php | 6 ++++- .../Orders/LegacyDataHandlerTests.php | 7 +++-- ...ableDataStoreRestOrdersControllerTests.php | 5 ++++ .../Orders/OrdersTableDataStoreTests.php | 27 +++++++++++++++---- .../Orders/OrdersTableQueryTests.php | 8 ++++-- .../OrdersTableRefundDataStoreTests.php | 10 ++++--- .../src/Internal/Orders/IppFunctionsTest.php | 2 -- .../Orders/MobileMessagingHandlerTest.php | 5 ++++ .../Traits/AccessiblePrivateMethodsTest.php | 5 ++-- .../TransientFilesEngineTest.php | 5 ++-- .../Utilities/COTMigrationUtilTest.php | 8 +++--- .../Internal/Utilities/DatabaseUtilTest.php | 8 +++--- .../Internal/Utilities/HtmlSanitizerTest.php | 8 +++--- 22 files changed, 112 insertions(+), 50 deletions(-) create mode 100644 plugins/woocommerce/changelog/dev-psr4-naming-fixes diff --git a/plugins/woocommerce/changelog/dev-psr4-naming-fixes b/plugins/woocommerce/changelog/dev-psr4-naming-fixes new file mode 100644 index 00000000000..4cecf347663 --- /dev/null +++ b/plugins/woocommerce/changelog/dev-psr4-naming-fixes @@ -0,0 +1,4 @@ +Significance: patch +Type: dev + +Coding standatds: fix PSR-4 naming violation in tests (part 1). diff --git a/plugins/woocommerce/tests/php/src/Blocks/Domain/Package.php b/plugins/woocommerce/tests/php/src/Blocks/Domain/Package.php index 0849bb289b6..5befc6c5729 100644 --- a/plugins/woocommerce/tests/php/src/Blocks/Domain/Package.php +++ b/plugins/woocommerce/tests/php/src/Blocks/Domain/Package.php @@ -1,8 +1,8 @@ assertInstanceOf( - WP_Post::class, + \WP_Post::class, get_post( $post_order->get_id() ), 'The order was initially created as a post.' ); diff --git a/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/LegacyDataCleanupTests.php b/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/LegacyDataCleanupTests.php index b8b4df5bef5..c8b730bf5b0 100644 --- a/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/LegacyDataCleanupTests.php +++ b/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/LegacyDataCleanupTests.php @@ -1,4 +1,8 @@ '25.00000000', 'customer_id' => $order->get_customer_id(), 'billing_email' => $order->get_billing_email(), - 'date_created' => gmdate( 'Y-m-d H:i:s', $order->get_date_created()->format( 'U' ) ), - 'date_modified' => gmdate( 'Y-m-d H:i:s', $order->get_date_modified()->format( 'U' ) ), + 'date_created' => gmdate( 'Y-m-d H:i:s', (int) $order->get_date_created()->format( 'U' ) ), + 'date_modified' => gmdate( 'Y-m-d H:i:s', (int) $order->get_date_modified()->format( 'U' ) ), 'parent_id' => $order->get_parent_id(), 'payment_method' => $order->get_payment_method(), 'payment_method_title' => $order->get_payment_method_title(), @@ -3000,8 +3017,8 @@ class OrdersTableDataStoreTests extends HposTestCase { 'new_order_email_sent' => $order->get_new_order_email_sent(), 'order_key' => $order->get_order_key(), 'order_stock_reduced' => $order->get_order_stock_reduced(), - 'date_paid' => gmdate( 'Y-m-d H:i:s', $order->get_date_paid()->format( 'U' ) ), - 'date_completed' => gmdate( 'Y-m-d H:i:s', $order->get_date_completed()->format( 'U' ) ), + 'date_paid' => gmdate( 'Y-m-d H:i:s', (int) $order->get_date_paid()->format( 'U' ) ), + 'date_completed' => gmdate( 'Y-m-d H:i:s', (int) $order->get_date_completed()->format( 'U' ) ), 'shipping_tax' => '12.34000000', 'shipping_total' => '123.45000000', 'discount_tax' => '2.11100000', diff --git a/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableQueryTests.php b/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableQueryTests.php index 083555da0b1..ec3f79607e8 100644 --- a/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableQueryTests.php +++ b/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableQueryTests.php @@ -1,15 +1,19 @@ created_files[ $file ] = $contents; return strlen( $contents ); } diff --git a/plugins/woocommerce/tests/php/src/Internal/Utilities/COTMigrationUtilTest.php b/plugins/woocommerce/tests/php/src/Internal/Utilities/COTMigrationUtilTest.php index 50b98ee8ada..e6efb0c3469 100644 --- a/plugins/woocommerce/tests/php/src/Internal/Utilities/COTMigrationUtilTest.php +++ b/plugins/woocommerce/tests/php/src/Internal/Utilities/COTMigrationUtilTest.php @@ -1,7 +1,7 @@