Skip to content

Commit

Permalink
Fix checked logic in old_url_metric test case
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Dec 2, 2024
1 parent 54183af commit 6960a28
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,12 @@ public function data_provider_test_is_complete(): array {
// Note: Test cases for empty URL Metrics and for exact sample size are already covered in the test_add_url_metric() method.
return array(
'old_url_metric' => array(
'url_metric' => $this->get_sample_url_metric( array( 'timestamp' => microtime( true ) - ( HOUR_IN_SECONDS + 1 ) ) ),
'url_metric' => $this->get_sample_url_metric(
array(
'timestamp' => microtime( true ) - ( HOUR_IN_SECONDS + 1 ),
'etag' => md5( '' ),
)
),
'expected_is_group_complete' => false,
),
// Note: The following test case will not be required once the ETag is mandatory in a future release.
Expand Down
4 changes: 3 additions & 1 deletion tests/class-optimization-detective-test-helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public function get_sample_dom_rect(): array {
* Gets a sample URL metric.
*
* @phpstan-param array{
* timestamp?: float,
* etag?: non-empty-string,
* url?: string,
* viewport_width?: int,
Expand All @@ -84,6 +85,7 @@ public function get_sample_url_metric( array $params ): OD_URL_Metric {
'url' => home_url( '/' ),
'viewport_width' => 480,
'elements' => array(),
'timestamp' => microtime( true ),
),
$params
);
Expand All @@ -100,7 +102,7 @@ public function get_sample_url_metric( array $params ): OD_URL_Metric {
'width' => $params['viewport_width'],
'height' => $params['viewport_height'] ?? ceil( $params['viewport_width'] / 2 ),
),
'timestamp' => microtime( true ),
'timestamp' => $params['timestamp'],
'elements' => array_map(
function ( array $element ): array {
return array_merge(
Expand Down

0 comments on commit 6960a28

Please sign in to comment.