Skip to content

Commit efcbd08

Browse files
committed
Add assertions for view_site_health_checks cap check
1 parent e1ea23c commit efcbd08

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

plugins/performance-lab/tests/includes/site-health/audit-enqueued-assets/test-audit-enqueued-assets-helper.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ public function test_perflab_aea_enqueued_blocking_assets_test_but_one_style_is_
284284
*/
285285
public function test_perflab_aea_enqueued_ajax_blocking_assets_test_unauthenticated_without_nonce(): void {
286286
$this->add_filter_to_mock_front_page_loopback_request();
287+
$this->assertFalse( current_user_can( 'view_site_health_checks' ) );
287288
$exception = null;
288289
try {
289290
$this->_handleAjax( 'health-check-enqueued-blocking-assets-test' );
@@ -302,6 +303,7 @@ public function test_perflab_aea_enqueued_ajax_blocking_assets_test_unauthentica
302303
*/
303304
public function test_perflab_aea_enqueued_ajax_blocking_assets_test_unauthenticated_with_nonce(): void {
304305
$this->add_filter_to_mock_front_page_loopback_request();
306+
$this->assertFalse( current_user_can( 'view_site_health_checks' ) );
305307
$_GET['_wpnonce'] = wp_create_nonce( 'health-check-site-status' );
306308
$exception = null;
307309
try {
@@ -323,6 +325,7 @@ public function test_perflab_aea_enqueued_ajax_blocking_assets_test_unauthentica
323325
public function test_perflab_aea_enqueued_ajax_blocking_assets_test_unauthorized(): void {
324326
$this->add_filter_to_mock_front_page_loopback_request();
325327
wp_set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
328+
$this->assertFalse( current_user_can( 'view_site_health_checks' ) );
326329
$_GET['_wpnonce'] = wp_create_nonce( 'health-check-site-status' );
327330
$exception = null;
328331
try {
@@ -344,6 +347,7 @@ public function test_perflab_aea_enqueued_ajax_blocking_assets_test_unauthorized
344347
public function test_perflab_aea_enqueued_ajax_blocking_assets_test_authorized(): void {
345348
$this->add_filter_to_mock_front_page_loopback_request();
346349
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
350+
$this->assertTrue( current_user_can( 'view_site_health_checks' ) );
347351
$_GET['_wpnonce'] = wp_create_nonce( 'health-check-site-status' );
348352
$exception = null;
349353
try {

0 commit comments

Comments
 (0)