Skip to content

Commit 2c4df9e

Browse files
authored
Merge pull request #7614 from ampproject/fix/deprecation-warning
Fix deprecation warnings
2 parents 828f229 + e8f73c5 commit 2c4df9e

7 files changed

Lines changed: 45 additions & 17 deletions

File tree

includes/validation/class-amp-validation-error-taxonomy.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2923,10 +2923,19 @@ public static function handle_validation_error_update( $redirect_to, $action, $t
29232923
}
29242924
}
29252925

2926+
if ( $updated_count ) {
2927+
delete_transient( AMP_Validated_URL_Post_Type::NEW_VALIDATION_ERROR_URLS_COUNT_TRANSIENT );
2928+
}
2929+
29262930
if ( false !== $has_pre_term_description_filter ) {
29272931
add_filter( 'pre_term_description', 'wp_filter_kses', $has_pre_term_description_filter );
29282932
}
29292933

2934+
// Bail if `$redirect_to` is passed as null.
2935+
if ( null === $redirect_to ) {
2936+
return $redirect_to;
2937+
}
2938+
29302939
$term_ids_count = count( $term_ids );
29312940
if ( 'edit.php' === $pagenow && 1 === $updated_count ) {
29322941
// Redirect to error index screen if deleting an validation error with no associated validated URLs.
@@ -2947,10 +2956,6 @@ public static function handle_validation_error_update( $redirect_to, $action, $t
29472956
);
29482957
}
29492958

2950-
if ( $updated_count ) {
2951-
delete_transient( AMP_Validated_URL_Post_Type::NEW_VALIDATION_ERROR_URLS_COUNT_TRANSIENT );
2952-
}
2953-
29542959
return $redirect_to;
29552960
}
29562961

phpunit.xml.dist

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
bootstrap="tests/php/bootstrap.php"
33
backupGlobals="false"
44
colors="true"
5-
convertDeprecationsToExceptions="false"
6-
convertErrorsToExceptions="false"
7-
convertNoticesToExceptions="false"
8-
convertWarningsToExceptions="false"
5+
convertDeprecationsToExceptions="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
99
defaultTestSuite="default"
1010
>
1111
<php>

src/Admin/OnboardingWizardSubmenu.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static function get_registration_action() {
4040
*/
4141
public function register() {
4242
add_submenu_page(
43-
'',
43+
'options.php',
4444
__( 'AMP Onboarding Wizard', 'amp' ),
4545
__( 'AMP Onboarding Wizard', 'amp' ),
4646
'manage_options',

tests/e2e/config/bootstrap.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,8 @@ beforeAll(async () => {
298298
await cleanUpSettings();
299299

300300
// Keep navigation timeout high since CI resources can be slow.
301-
await page.setDefaultNavigationTimeout(30000);
302-
await page.setDefaultTimeout(30000);
301+
await page.setDefaultNavigationTimeout(60000);
302+
await page.setDefaultTimeout(60000);
303303
});
304304

305305
// eslint-disable-next-line jest/require-top-level-describe

tests/php/src/Admin/OnboardingWizardSubmenuTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ public function test_register() {
6161

6262
$this->instance->register();
6363

64-
$this->assertEquals( end( $submenu[''] )[2], 'amp-onboarding-wizard' );
64+
$this->assertEquals( end( $submenu['options.php'] )[2], 'amp-onboarding-wizard' );
6565
}
6666
}

tests/php/src/Admin/OptionsMenuTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,13 @@ public function test_render_screen_for_admin_user() {
290290
)
291291
);
292292

293+
// Set current screen to be the options menu.
294+
set_current_screen( $this->instance->screen_handle() );
295+
296+
// Set title to be used in the screen.
297+
global $title;
298+
$title = 'Test Title';
299+
293300
ob_start();
294301
$this->instance->render_screen();
295302
$this->assertStringContainsString( '<div class="wrap">', ob_get_clean() );

tests/php/validation/test-class-amp-validation-error-taxonomy.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use AmpProject\AmpWP\Services;
1212
use AmpProject\AmpWP\Tests\Helpers\HandleValidation;
1313
use AmpProject\AmpWP\Tests\TestCase;
14+
use AmpProject\AmpWP\Tests\Helpers\MockAdminUser;
1415

1516
/**
1617
* Tests for AMP_Validation_Error_Taxonomy class.
@@ -20,6 +21,7 @@
2021
class Test_AMP_Validation_Error_Taxonomy extends TestCase {
2122

2223
use HandleValidation;
24+
use MockAdminUser;
2325

2426
/**
2527
* The tested class.
@@ -1429,27 +1431,41 @@ static function ( $redirect_url ) use ( &$redirected_url ) {
14291431
AMP_Validation_Error_Taxonomy::handle_single_url_page_bulk_and_inline_actions( $incorrect_post_type );
14301432
$this->assertEquals( get_term( $error_term->term_id )->term_group, $initial_accepted_status );
14311433

1434+
// Setup admin user which have edit_posts capability.
1435+
$this->mock_admin_user();
1436+
1437+
// Build the expected URL for the redirect.
1438+
$admin_post_url = admin_url( 'post.php' );
1439+
$redirect_query_args = [
1440+
'post' => $correct_post_type,
1441+
'action' => 'edit',
1442+
'amp_actioned' => AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_ACCEPT_ACTION,
1443+
'amp_actioned_count' => 1,
1444+
];
1445+
14321446
/*
14331447
* Although the post type is correct, this should not update the post accepted status to be 'accepted'.
14341448
* There should be a warning because wp_safe_redirect() should be called at the end of the tested method.
14351449
*/
14361450
AMP_Validation_Error_Taxonomy::handle_single_url_page_bulk_and_inline_actions( $correct_post_type );
14371451

1438-
$this->assertSame( '?action=edit&amp_actioned=amp_validation_error_accept&amp_actioned_count=1', $redirected_url );
1452+
$this->assertSame( add_query_arg( $redirect_query_args, $admin_post_url ), $redirected_url );
14391453
$this->assertEquals( get_term( $error_term->term_id )->term_group, AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_NEW_ACCEPTED_STATUS );
14401454

14411455
// When the action is to 'reject' the error, this should not update the status of the error to 'rejected'.
1442-
$_REQUEST['action'] = AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_REJECT_ACTION;
1456+
$_REQUEST['action'] = AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_REJECT_ACTION;
1457+
$redirect_query_args['amp_actioned'] = AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_REJECT_ACTION;
14431458
AMP_Validation_Error_Taxonomy::handle_single_url_page_bulk_and_inline_actions( $correct_post_type );
14441459

1445-
$this->assertSame( '?action=edit&amp_actioned=amp_validation_error_reject&amp_actioned_count=1', $redirected_url );
1460+
$this->assertSame( add_query_arg( $redirect_query_args, $admin_post_url ), $redirected_url );
14461461
$this->assertEquals( get_term( $error_term->term_id )->term_group, AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_NEW_ACCEPTED_STATUS );
14471462

14481463
// When the action is to 'delete' the error, this should delete the error.
1449-
$_REQUEST['action'] = 'delete';
1464+
$_REQUEST['action'] = 'delete';
1465+
$redirect_query_args['amp_actioned'] = 'delete';
14501466
AMP_Validation_Error_Taxonomy::handle_single_url_page_bulk_and_inline_actions( $correct_post_type );
14511467

1452-
$this->assertSame( '?action=edit&amp_actioned=delete&amp_actioned_count=1', $redirected_url );
1468+
$this->assertSame( add_query_arg( $redirect_query_args, $admin_post_url ), $redirected_url );
14531469
$this->assertEquals( null, get_term( $error_term->term_id ) );
14541470
}
14551471

0 commit comments

Comments
 (0)