Skip to content
Snippets Groups Projects
Commit a772546c authored by Erick Hitter's avatar Erick Hitter
Browse files

PHPCS

parent b7aa7f4e
No related branches found
No related tags found
1 merge request!14Add native block-editor support
Pipeline #4809 failed
This commit is part of merge request !14. Comments created here will be created in the context of that merge request.
...@@ -108,8 +108,8 @@ class External_Permalinks_Redux_Block_Editor { ...@@ -108,8 +108,8 @@ class External_Permalinks_Redux_Block_Editor {
} }
if ( if (
$meta_key === external_permalinks_redux::get_instance()->meta_key_target external_permalinks_redux::get_instance()->meta_key_target === $meta_key
|| $meta_key === external_permalinks_redux::get_instance()->meta_key_type || external_permalinks_redux::get_instance()->meta_key_type === $meta_key
) { ) {
return false; return false;
} }
...@@ -161,18 +161,18 @@ class External_Permalinks_Redux_Block_Editor { ...@@ -161,18 +161,18 @@ class External_Permalinks_Redux_Block_Editor {
*/ */
protected function _get_status_codes() { protected function _get_status_codes() {
$codes = external_permalinks_redux::get_instance()->status_codes; $codes = external_permalinks_redux::get_instance()->status_codes;
$formatted = [ $formatted = array(
[ array(
'label' => __( '-- Select --', 'external-permalinks-redux' ), 'label' => __( '-- Select --', 'external-permalinks-redux' ),
'value' => 0, 'value' => 0,
], ),
]; );
foreach ( $codes as $code => $label ) { foreach ( $codes as $code => $label ) {
$formatted[] = [ $formatted[] = array(
'label' => $label, 'label' => $label,
'value' => $code, 'value' => $code,
]; );
} }
return $formatted; return $formatted;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* @package External_Permalinks_Redux * @package External_Permalinks_Redux
*/ */
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
$_tests_dir = getenv( 'WP_TESTS_DIR' ); $_tests_dir = getenv( 'WP_TESTS_DIR' );
if ( ! $_tests_dir ) { if ( ! $_tests_dir ) {
...@@ -22,10 +23,10 @@ require_once $_tests_dir . '/includes/functions.php'; ...@@ -22,10 +23,10 @@ require_once $_tests_dir . '/includes/functions.php';
/** /**
* Manually load the plugin being tested. * Manually load the plugin being tested.
*/ */
function _manually_load_plugin() { function epr__manually_load_plugin() {
require dirname( dirname( __FILE__ ) ) . '/external-permalinks-redux.php'; 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. // Start up the WP testing environment.
require $_tests_dir . '/includes/bootstrap.php'; require $_tests_dir . '/includes/bootstrap.php';
...@@ -79,12 +79,12 @@ class AdminCallbacks extends WP_UnitTestCase { ...@@ -79,12 +79,12 @@ class AdminCallbacks extends WP_UnitTestCase {
add_filter( 'use_block_editor_for_post', '__return_false' ); add_filter( 'use_block_editor_for_post', '__return_false' );
$_POST[ $this->plugin->meta_key_target . '_nonce' ] = $this->nonce; $_POST[ $this->plugin->meta_key_target . '_nonce' ] = $this->nonce;
$_POST[ $this->plugin->meta_key_target . '_url' ] = static::DESTINATION; $_POST[ $this->plugin->meta_key_target . '_url' ] = self::DESTINATION;
$_POST[ $this->plugin->meta_key_target . '_type' ] = static::TYPE; $_POST[ $this->plugin->meta_key_target . '_type' ] = self::TYPE;
$this->plugin->action_save_post( $this->post_id ); $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( self::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( (string) self::TYPE, get_post_meta( $this->post_id, $this->plugin->meta_key_type, true ) );
} }
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* Test block-editor integration. * Test block-editor integration.
* *
* @pacakge External_Permalinks_Redux * @package External_Permalinks_Redux
*/ */
/** /**
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
*/ */
class TestClassExternalPermalinksReduxBlockEditor extends WP_UnitTestCase { class TestClassExternalPermalinksReduxBlockEditor extends WP_UnitTestCase {
/** /**
* Test meta registration.
*
* @covers ::register_meta() * @covers ::register_meta()
*/ */
public function test_register_meta() { public function test_register_meta() {
...@@ -19,6 +21,8 @@ class TestClassExternalPermalinksReduxBlockEditor extends WP_UnitTestCase { ...@@ -19,6 +21,8 @@ class TestClassExternalPermalinksReduxBlockEditor extends WP_UnitTestCase {
} }
/** /**
* Test overridding private meta editing.
*
* @covers ::allow_meta_updates() * @covers ::allow_meta_updates()
*/ */
public function test_allow_meta_updates() { public function test_allow_meta_updates() {
...@@ -26,6 +30,8 @@ class TestClassExternalPermalinksReduxBlockEditor extends WP_UnitTestCase { ...@@ -26,6 +30,8 @@ class TestClassExternalPermalinksReduxBlockEditor extends WP_UnitTestCase {
} }
/** /**
* Test script enqueueing.
*
* @covers ::enqueue() * @covers ::enqueue()
*/ */
public function test_enqueue() { public function test_enqueue() {
......
...@@ -42,7 +42,7 @@ class PermalinkFilters extends WP_UnitTestCase { ...@@ -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( $this->page_id = $this->factory->post->create(
array( array(
...@@ -50,20 +50,20 @@ class PermalinkFilters extends WP_UnitTestCase { ...@@ -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. * Test post permalink filter.
*/ */
public function test_post() { 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. * Test page link filter.
*/ */
public function test_page() { public function test_page() {
$this->assertEquals( static::DESTINATION, get_page_link( $this->page_id ) ); $this->assertEquals( self::DESTINATION, get_page_link( $this->page_id ) );
} }
} }
...@@ -48,11 +48,11 @@ class RedirectCallbacks extends WP_UnitTestCase { ...@@ -48,11 +48,11 @@ class RedirectCallbacks extends WP_UnitTestCase {
*/ */
public function test_post_redirect_default_status() { public function test_post_redirect_default_status() {
$post_id = $this->get_new_post(); $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 ); $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'] ); $this->assertEquals( 302, $redirect['type'] );
} }
...@@ -61,12 +61,12 @@ class RedirectCallbacks extends WP_UnitTestCase { ...@@ -61,12 +61,12 @@ class RedirectCallbacks extends WP_UnitTestCase {
*/ */
public function test_post_redirect_custom_status() { public function test_post_redirect_custom_status() {
$post_id = $this->get_new_post(); $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 ); update_post_meta( $post_id, $this->plugin->meta_key_type, 307 );
$redirect = $this->plugin->get_redirect_data( $post_id ); $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'] ); $this->assertEquals( 307, $redirect['type'] );
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment