Skip to content

Commit bb44412

Browse files
committed
Update test cases
Signed-off-by: Shyamsundar Gadde <[email protected]>
1 parent fe8f282 commit bb44412

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

plugins/optimization-detective/tests/storage/test-data.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,19 @@ static function (): int {
4646
}
4747

4848
/**
49-
* Test bad od_get_url_metric_freshness_ttl().
49+
* Test negative od_get_url_metric_freshness_ttl().
5050
*
5151
* @covers ::od_get_url_metric_freshness_ttl
5252
*/
53-
public function test_bad_od_get_url_metric_freshness_ttl(): void {
54-
$this->setExpectedIncorrectUsage( 'Filter: &#039;od_url_metric_freshness_ttl&#039;' );
53+
public function test_negative_od_get_url_metric_freshness_ttl(): void {
5554
add_filter(
5655
'od_url_metric_freshness_ttl',
5756
static function (): int {
5857
return -1;
5958
}
6059
);
6160

62-
$this->assertSame( 0, od_get_url_metric_freshness_ttl() );
61+
$this->assertSame( -1, od_get_url_metric_freshness_ttl() );
6362
}
6463

6564
/**

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,79 +22,79 @@ public function data_provider_test_construction(): array {
2222
$current_etag = md5( '' );
2323

2424
return array(
25-
'no_breakpoints_ok' => array(
25+
'no_breakpoints_ok' => array(
2626
'url_metrics' => array(),
2727
'current_etag' => $current_etag,
2828
'breakpoints' => array(),
2929
'sample_size' => 3,
3030
'freshness_ttl' => HOUR_IN_SECONDS,
3131
'exception' => '',
3232
),
33-
'negative_breakpoint_bad' => array(
33+
'negative_breakpoint_bad' => array(
3434
'url_metrics' => array(),
3535
'current_etag' => $current_etag,
3636
'breakpoints' => array( -1 ),
3737
'sample_size' => 3,
3838
'freshness_ttl' => HOUR_IN_SECONDS,
3939
'exception' => InvalidArgumentException::class,
4040
),
41-
'zero_breakpoint_bad' => array(
41+
'zero_breakpoint_bad' => array(
4242
'url_metrics' => array(),
4343
'current_etag' => $current_etag,
4444
'breakpoints' => array( 0 ),
4545
'sample_size' => 3,
4646
'freshness_ttl' => HOUR_IN_SECONDS,
4747
'exception' => InvalidArgumentException::class,
4848
),
49-
'string_breakpoint_bad' => array(
49+
'string_breakpoint_bad' => array(
5050
'url_metrics' => array(),
5151
'current_etag' => $current_etag,
5252
'breakpoints' => array( 'narrow' ),
5353
'sample_size' => 3,
5454
'freshness_ttl' => HOUR_IN_SECONDS,
5555
'exception' => InvalidArgumentException::class,
5656
),
57-
'negative_sample_size_bad' => array(
57+
'negative_sample_size_bad' => array(
5858
'url_metrics' => array(),
5959
'current_etag' => $current_etag,
6060
'breakpoints' => array( 400 ),
6161
'sample_size' => -3,
6262
'freshness_ttl' => HOUR_IN_SECONDS,
6363
'exception' => InvalidArgumentException::class,
6464
),
65-
'negative_freshness_tll_bad' => array(
65+
'negative_freshness_ttl_ok' => array(
6666
'url_metrics' => array(),
6767
'current_etag' => $current_etag,
6868
'breakpoints' => array( 400 ),
6969
'sample_size' => 3,
7070
'freshness_ttl' => -HOUR_IN_SECONDS,
71-
'exception' => InvalidArgumentException::class,
71+
'exception' => '',
7272
),
73-
'invalid_current_etag_bad' => array(
73+
'invalid_current_etag_bad' => array(
7474
'url_metrics' => array(),
7575
'current_etag' => 'invalid_etag',
7676
'breakpoints' => array( 400 ),
7777
'sample_size' => 3,
7878
'freshness_ttl' => HOUR_IN_SECONDS,
7979
'exception' => InvalidArgumentException::class,
8080
),
81-
'invalid_current_etag_bad2' => array(
81+
'invalid_current_etag_bad2' => array(
8282
'url_metrics' => array(),
8383
'current_etag' => md5( '' ) . PHP_EOL, // Note that /^[a-f0-9]{32}$/ would erroneously validate this. So the \z is required instead in /^[a-f0-9]{32}\z/.
8484
'breakpoints' => array( 400 ),
8585
'sample_size' => 3,
8686
'freshness_ttl' => HOUR_IN_SECONDS,
8787
'exception' => InvalidArgumentException::class,
8888
),
89-
'invalid_url_metrics_bad' => array(
89+
'invalid_url_metrics_bad' => array(
9090
'url_metrics' => array( 'bad' ),
9191
'current_etag' => $current_etag,
9292
'breakpoints' => array( 400 ),
9393
'sample_size' => 3,
9494
'freshness_ttl' => HOUR_IN_SECONDS,
9595
'exception' => TypeError::class,
9696
),
97-
'all_arguments_good' => array(
97+
'all_arguments_good' => array(
9898
'url_metrics' => array(
9999
$this->get_sample_url_metric( array( 'viewport_width' => 200 ) ),
100100
$this->get_sample_url_metric( array( 'viewport_width' => 400 ) ),

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,55 +20,55 @@ class Test_OD_URL_Metric_Group extends WP_UnitTestCase {
2020
*/
2121
public function data_provider_test_construction(): array {
2222
return array(
23-
'bad_minimum_viewport_width' => array(
23+
'bad_minimum_viewport_width' => array(
2424
'url_metrics' => array(),
2525
'minimum_viewport_width' => -1,
2626
'maximum_viewport_width' => 100,
2727
'sample_size' => 3,
2828
'freshness_ttl' => HOUR_IN_SECONDS,
2929
'exception' => InvalidArgumentException::class,
3030
),
31-
'bad_maximum_viewport_width' => array(
31+
'bad_maximum_viewport_width' => array(
3232
'url_metrics' => array(),
3333
'minimum_viewport_width' => 0,
3434
'maximum_viewport_width' => -1,
3535
'sample_size' => 3,
3636
'freshness_ttl' => HOUR_IN_SECONDS,
3737
'exception' => InvalidArgumentException::class,
3838
),
39-
'bad_min_max_viewport_width' => array(
39+
'bad_min_max_viewport_width' => array(
4040
'url_metrics' => array(),
4141
'minimum_viewport_width' => 200,
4242
'maximum_viewport_width' => 100,
4343
'sample_size' => 3,
4444
'freshness_ttl' => HOUR_IN_SECONDS,
4545
'exception' => InvalidArgumentException::class,
4646
),
47-
'bad_sample_size_viewport_width' => array(
47+
'bad_sample_size_viewport_width' => array(
4848
'url_metrics' => array(),
4949
'minimum_viewport_width' => 0,
5050
'maximum_viewport_width' => 100,
5151
'sample_size' => -3,
5252
'freshness_ttl' => HOUR_IN_SECONDS,
5353
'exception' => InvalidArgumentException::class,
5454
),
55-
'bad_freshness_ttl_viewport_width' => array(
55+
'negative_freshness_ttl_ok' => array(
5656
'url_metrics' => array(),
5757
'minimum_viewport_width' => 0,
5858
'maximum_viewport_width' => 100,
5959
'sample_size' => 3,
6060
'freshness_ttl' => -HOUR_IN_SECONDS,
61-
'exception' => InvalidArgumentException::class,
61+
'exception' => '',
6262
),
63-
'good_empty_url_metrics' => array(
63+
'good_empty_url_metrics' => array(
6464
'url_metrics' => array(),
6565
'minimum_viewport_width' => 0,
6666
'maximum_viewport_width' => 100,
6767
'sample_size' => 3,
6868
'freshness_ttl' => HOUR_IN_SECONDS,
6969
'exception' => '',
7070
),
71-
'good_one_url_metric' => array(
71+
'good_one_url_metric' => array(
7272
'url_metrics' => array(
7373
new OD_URL_Metric(
7474
array(

0 commit comments

Comments
 (0)