diff --git a/inc/class-external-permalinks-redux-block-editor.php b/inc/class-external-permalinks-redux-block-editor.php index c02f3bf4c37f2ca1351253eef97101e87c21efdd..db496dd4900daa15164c3017e0141ea5782bb067 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 51a091004dd54563200c6075aa48a2a088c3bd92..bfbc6b5eb282422f4fe77ec870129006fb987c74 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 2b37ed38b1be68e9e46fddea00cd11925778f071..1bf8d25c27d1b02b8393f21a1d4de1288e451e5d 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 c563510e15bce73faf30d60e815dacd030c83539..ed460ad828ad2636b9afa58ec7980be518ae4829 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 ea3f2e40c6a970b7f33b6a1b5603277c45911b07..35e70c591998f4fb87fe75a0118ffe67b4e4cb32 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 a09b89f30a69c04b9a16dd1b3afdd14dc0a8f602..5c14b09d83437228f4c5d8c77f890fe9c3967918 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'] ); }