From a772546c2c1771e6a61c166ee294613950395c4d Mon Sep 17 00:00:00 2001 From: Erick Hitter <git-contrib@ethitter.com> Date: Sat, 11 Jun 2022 21:18:26 -0700 Subject: [PATCH] PHPCS --- ...ss-external-permalinks-redux-block-editor.php | 16 ++++++++-------- tests/bootstrap.php | 5 +++-- tests/test-admin-callbacks.php | 8 ++++---- ...ss-external-permalinks-redux-block-editor.php | 8 +++++++- tests/test-permalink-filters.php | 8 ++++---- tests/test-redirect-callbacks.php | 8 ++++---- 6 files changed, 30 insertions(+), 23 deletions(-) diff --git a/inc/class-external-permalinks-redux-block-editor.php b/inc/class-external-permalinks-redux-block-editor.php index c02f3bf..db496dd 100644 --- a/inc/class-external-permalinks-redux-block-editor.php +++ b/inc/class-external-permalinks-redux-block-editor.php @@ -108,8 +108,8 @@ class External_Permalinks_Redux_Block_Editor { } if ( - $meta_key === external_permalinks_redux::get_instance()->meta_key_target - || $meta_key === external_permalinks_redux::get_instance()->meta_key_type + external_permalinks_redux::get_instance()->meta_key_target === $meta_key + || external_permalinks_redux::get_instance()->meta_key_type === $meta_key ) { return false; } @@ -161,18 +161,18 @@ class External_Permalinks_Redux_Block_Editor { */ protected function _get_status_codes() { $codes = external_permalinks_redux::get_instance()->status_codes; - $formatted = [ - [ + $formatted = array( + array( 'label' => __( '-- Select --', 'external-permalinks-redux' ), 'value' => 0, - ], - ]; + ), + ); foreach ( $codes as $code => $label ) { - $formatted[] = [ + $formatted[] = array( 'label' => $label, 'value' => $code, - ]; + ); } return $formatted; diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 51a0910..bfbc6b5 100755 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -5,6 +5,7 @@ * @package External_Permalinks_Redux */ +// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound $_tests_dir = getenv( 'WP_TESTS_DIR' ); if ( ! $_tests_dir ) { @@ -22,10 +23,10 @@ require_once $_tests_dir . '/includes/functions.php'; /** * Manually load the plugin being tested. */ -function _manually_load_plugin() { +function epr__manually_load_plugin() { require dirname( dirname( __FILE__ ) ) . '/external-permalinks-redux.php'; } -tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); +tests_add_filter( 'muplugins_loaded', 'epr__manually_load_plugin' ); // Start up the WP testing environment. require $_tests_dir . '/includes/bootstrap.php'; diff --git a/tests/test-admin-callbacks.php b/tests/test-admin-callbacks.php index 2b37ed3..1bf8d25 100755 --- a/tests/test-admin-callbacks.php +++ b/tests/test-admin-callbacks.php @@ -79,12 +79,12 @@ class AdminCallbacks extends WP_UnitTestCase { add_filter( 'use_block_editor_for_post', '__return_false' ); $_POST[ $this->plugin->meta_key_target . '_nonce' ] = $this->nonce; - $_POST[ $this->plugin->meta_key_target . '_url' ] = static::DESTINATION; - $_POST[ $this->plugin->meta_key_target . '_type' ] = static::TYPE; + $_POST[ $this->plugin->meta_key_target . '_url' ] = self::DESTINATION; + $_POST[ $this->plugin->meta_key_target . '_type' ] = self::TYPE; $this->plugin->action_save_post( $this->post_id ); - $this->assertStringContainsString( static::DESTINATION, get_post_meta( $this->post_id, $this->plugin->meta_key_target, true ) ); - $this->assertStringContainsString( (string) static::TYPE, get_post_meta( $this->post_id, $this->plugin->meta_key_type, true ) ); + $this->assertStringContainsString( self::DESTINATION, get_post_meta( $this->post_id, $this->plugin->meta_key_target, true ) ); + $this->assertStringContainsString( (string) self::TYPE, get_post_meta( $this->post_id, $this->plugin->meta_key_type, true ) ); } } diff --git a/tests/test-class-external-permalinks-redux-block-editor.php b/tests/test-class-external-permalinks-redux-block-editor.php index c563510..ed460ad 100644 --- a/tests/test-class-external-permalinks-redux-block-editor.php +++ b/tests/test-class-external-permalinks-redux-block-editor.php @@ -2,7 +2,7 @@ /** * Test block-editor integration. * - * @pacakge External_Permalinks_Redux + * @package External_Permalinks_Redux */ /** @@ -12,6 +12,8 @@ */ class TestClassExternalPermalinksReduxBlockEditor extends WP_UnitTestCase { /** + * Test meta registration. + * * @covers ::register_meta() */ public function test_register_meta() { @@ -19,6 +21,8 @@ class TestClassExternalPermalinksReduxBlockEditor extends WP_UnitTestCase { } /** + * Test overridding private meta editing. + * * @covers ::allow_meta_updates() */ public function test_allow_meta_updates() { @@ -26,6 +30,8 @@ class TestClassExternalPermalinksReduxBlockEditor extends WP_UnitTestCase { } /** + * Test script enqueueing. + * * @covers ::enqueue() */ public function test_enqueue() { diff --git a/tests/test-permalink-filters.php b/tests/test-permalink-filters.php index ea3f2e4..35e70c5 100755 --- a/tests/test-permalink-filters.php +++ b/tests/test-permalink-filters.php @@ -42,7 +42,7 @@ class PermalinkFilters extends WP_UnitTestCase { ) ); - update_post_meta( $this->post_id, $plugin->meta_key_target, static::DESTINATION ); + update_post_meta( $this->post_id, $plugin->meta_key_target, self::DESTINATION ); $this->page_id = $this->factory->post->create( array( @@ -50,20 +50,20 @@ class PermalinkFilters extends WP_UnitTestCase { ) ); - update_post_meta( $this->page_id, $plugin->meta_key_target, static::DESTINATION ); + update_post_meta( $this->page_id, $plugin->meta_key_target, self::DESTINATION ); } /** * Test post permalink filter. */ public function test_post() { - $this->assertEquals( static::DESTINATION, get_permalink( $this->post_id ) ); + $this->assertEquals( self::DESTINATION, get_permalink( $this->post_id ) ); } /** * Test page link filter. */ public function test_page() { - $this->assertEquals( static::DESTINATION, get_page_link( $this->page_id ) ); + $this->assertEquals( self::DESTINATION, get_page_link( $this->page_id ) ); } } diff --git a/tests/test-redirect-callbacks.php b/tests/test-redirect-callbacks.php index a09b89f..5c14b09 100755 --- a/tests/test-redirect-callbacks.php +++ b/tests/test-redirect-callbacks.php @@ -48,11 +48,11 @@ class RedirectCallbacks extends WP_UnitTestCase { */ public function test_post_redirect_default_status() { $post_id = $this->get_new_post(); - update_post_meta( $post_id, $this->plugin->meta_key_target, static::DESTINATION ); + update_post_meta( $post_id, $this->plugin->meta_key_target, self::DESTINATION ); $redirect = $this->plugin->get_redirect_data( $post_id ); - $this->assertEquals( static::DESTINATION, $redirect['link'] ); + $this->assertEquals( self::DESTINATION, $redirect['link'] ); $this->assertEquals( 302, $redirect['type'] ); } @@ -61,12 +61,12 @@ class RedirectCallbacks extends WP_UnitTestCase { */ public function test_post_redirect_custom_status() { $post_id = $this->get_new_post(); - update_post_meta( $post_id, $this->plugin->meta_key_target, static::DESTINATION ); + update_post_meta( $post_id, $this->plugin->meta_key_target, self::DESTINATION ); update_post_meta( $post_id, $this->plugin->meta_key_type, 307 ); $redirect = $this->plugin->get_redirect_data( $post_id ); - $this->assertEquals( static::DESTINATION, $redirect['link'] ); + $this->assertEquals( self::DESTINATION, $redirect['link'] ); $this->assertEquals( 307, $redirect['type'] ); } -- GitLab