Skip to content

Commit 6960a28

Browse files
committed
Fix checked logic in old_url_metric test case
1 parent 54183af commit 6960a28

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

plugins/optimization-detective/tests/test-class-od-url-metrics-group.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,12 @@ public function data_provider_test_is_complete(): array {
251251
// Note: Test cases for empty URL Metrics and for exact sample size are already covered in the test_add_url_metric() method.
252252
return array(
253253
'old_url_metric' => array(
254-
'url_metric' => $this->get_sample_url_metric( array( 'timestamp' => microtime( true ) - ( HOUR_IN_SECONDS + 1 ) ) ),
254+
'url_metric' => $this->get_sample_url_metric(
255+
array(
256+
'timestamp' => microtime( true ) - ( HOUR_IN_SECONDS + 1 ),
257+
'etag' => md5( '' ),
258+
)
259+
),
255260
'expected_is_group_complete' => false,
256261
),
257262
// Note: The following test case will not be required once the ETag is mandatory in a future release.

tests/class-optimization-detective-test-helpers.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public function get_sample_dom_rect(): array {
6767
* Gets a sample URL metric.
6868
*
6969
* @phpstan-param array{
70+
* timestamp?: float,
7071
* etag?: non-empty-string,
7172
* url?: string,
7273
* viewport_width?: int,
@@ -84,6 +85,7 @@ public function get_sample_url_metric( array $params ): OD_URL_Metric {
8485
'url' => home_url( '/' ),
8586
'viewport_width' => 480,
8687
'elements' => array(),
88+
'timestamp' => microtime( true ),
8789
),
8890
$params
8991
);
@@ -100,7 +102,7 @@ public function get_sample_url_metric( array $params ): OD_URL_Metric {
100102
'width' => $params['viewport_width'],
101103
'height' => $params['viewport_height'] ?? ceil( $params['viewport_width'] / 2 ),
102104
),
103-
'timestamp' => microtime( true ),
105+
'timestamp' => $params['timestamp'],
104106
'elements' => array_map(
105107
function ( array $element ): array {
106108
return array_merge(

0 commit comments

Comments
 (0)