Commit e590943d4b4 for woocommerce
commit e590943d4b4f66c6a0e88cdfcc676ceb367065ad
Author: iris-woocommerce[bot] <282076412+iris-woocommerce[bot]@users.noreply.github.com>
Date: Fri Nov 27 12:34:36 2026 +0000
Fix stock notifications last attempt limit test intermittent failures (#71520)
diff --git a/plugins/woocommerce/changelog/fix-flaky-stock-notifications-last-attempt-test b/plugins/woocommerce/changelog/fix-flaky-stock-notifications-last-attempt-test
new file mode 100644
index 00000000000..be8d047d347
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-flaky-stock-notifications-last-attempt-test
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+Comment: Fix a flaky stock notifications data store test; no production change.
+
diff --git a/plugins/woocommerce/tests/php/src/Internal/DataStores/StockNotifications/StockNotificationsDataStoreTests.php b/plugins/woocommerce/tests/php/src/Internal/DataStores/StockNotifications/StockNotificationsDataStoreTests.php
index 385249625c3..dc29cb7c32c 100644
--- a/plugins/woocommerce/tests/php/src/Internal/DataStores/StockNotifications/StockNotificationsDataStoreTests.php
+++ b/plugins/woocommerce/tests/php/src/Internal/DataStores/StockNotifications/StockNotificationsDataStoreTests.php
@@ -787,6 +787,7 @@ class StockNotificationsDataStoreTests extends \WC_Unit_Test_Case {
* Test querying notifications with a last attempt limit.
*/
public function test_query_notifications_with_last_attempt_limit() {
+ $now = time();
$notification = new Notification();
$notification->set_product_id( 1 );
$notification->set_user_id( 1 );
@@ -794,29 +795,29 @@ class StockNotificationsDataStoreTests extends \WC_Unit_Test_Case {
$notifications = $this->data_store->query(
array(
- 'last_attempt_limit' => time(),
+ 'last_attempt_limit' => $now,
)
);
// First notification is returned because it has no last attempt date.
$this->assertCount( 1, $notifications );
- $notification->set_date_last_attempt( time() );
+ $notification->set_date_last_attempt( $now );
$notification->save();
$notifications = $this->data_store->query(
array(
- 'last_attempt_limit' => time(),
+ 'last_attempt_limit' => $now,
)
);
// Second notification is returned because we need to older than now.
$this->assertCount( 0, $notifications );
- $notification->set_date_last_attempt( time() - 1000 );
+ $notification->set_date_last_attempt( $now - 1000 );
$notification->save();
$notifications = $this->data_store->query(
array(
- 'last_attempt_limit' => time(),
+ 'last_attempt_limit' => $now,
)
);
$this->assertCount( 1, $notifications );