Skip to content

Commit 5af021d

Browse files
Simplify data provider for test_comment_lcp_element
Co-authored-by: Weston Ruter <[email protected]>
1 parent 952f04c commit 5af021d

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -749,10 +749,7 @@ public function data_provider_test_get_common_lcp_element(): array {
749749
$get_sample_url_metric( 600, $xpath1 ),
750750
$get_sample_url_metric( 1000, $xpath1 ),
751751
),
752-
'expected' => array(
753-
'type' => OD_Element::class,
754-
'xpath' => $xpath1,
755-
),
752+
'expected' => $xpath1,
756753
),
757754
'no_url_metrics' => array(
758755
'url_metrics' => array(),
@@ -777,10 +774,7 @@ public function data_provider_test_get_common_lcp_element(): array {
777774
$get_sample_url_metric( 400, $xpath1 ),
778775
$get_sample_url_metric( 1000, $xpath1 ),
779776
),
780-
'expected' => array(
781-
'type' => OD_Element::class,
782-
'xpath' => $xpath1,
783-
),
777+
'expected' => $xpath1,
784778
),
785779
'intermediate_groups_conflict' => array(
786780
'url_metrics' => array(
@@ -817,9 +811,9 @@ public function data_provider_test_get_common_lcp_element(): array {
817811
* @dataProvider data_provider_test_get_common_lcp_element
818812
*
819813
* @param OD_URL_Metric[] $url_metrics URL Metrics.
820-
* @param mixed $expected Expected.
814+
* @param string|null $expected Expected.
821815
*/
822-
public function test_get_common_lcp_element( array $url_metrics, $expected ): void {
816+
public function test_get_common_lcp_element( array $url_metrics, ?string $expected ): void {
823817
$breakpoints = array( 480, 800 );
824818
$sample_size = 3;
825819
$current_etag = md5( '' );
@@ -834,9 +828,9 @@ public function test_get_common_lcp_element( array $url_metrics, $expected ): vo
834828
$this->assertCount( 3, $group_collection );
835829

836830
$common_lcp_element = $group_collection->get_common_lcp_element();
837-
if ( is_array( $expected ) ) {
838-
$this->assertInstanceOf( $expected['type'], $common_lcp_element );
839-
$this->assertSame( $expected['xpath'], $common_lcp_element->get_xpath() );
831+
if ( is_string( $expected ) ) {
832+
$this->assertInstanceOf( OD_Element::class, $common_lcp_element );
833+
$this->assertSame( $expected, $common_lcp_element->get_xpath() );
840834
} else {
841835
$this->assertNull( $common_lcp_element );
842836
}

0 commit comments

Comments
 (0)