From 9e9d5c062c0cdf7959ab6b2c03c70c2826cefba0 Mon Sep 17 00:00:00 2001
From: Erick Hitter <git-contrib@ethitter.com>
Date: Sun, 26 May 2019 15:36:23 -0700
Subject: [PATCH] PHPCS

---
 .phpcs.xml.dist       |  1 -
 tests/bootstrap.php   | 21 +++++++++++++--------
 tests/test-purges.php |  4 ++--
 tests/test-ui.php     |  4 ++--
 4 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist
index 0717712..121c174 100644
--- a/.phpcs.xml.dist
+++ b/.phpcs.xml.dist
@@ -6,7 +6,6 @@
 	<file>.</file>
 	<exclude-pattern>/vendor/</exclude-pattern>
 	<exclude-pattern>/node_modules/</exclude-pattern>
-	<exclude-pattern>/tests/*</exclude-pattern>
 
 	<!-- How to scan -->
 	<!-- Usage instructions: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage -->
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 1ed0283..a539aad 100755
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -5,34 +5,39 @@
  * @package WP_Revisions_Control
  */
 
-$_tests_dir = getenv( 'WP_TESTS_DIR' );
+$wp_revisions_control_tests_tests_dir = getenv( 'WP_TESTS_DIR' );
 
-if ( ! $_tests_dir ) {
-	$_tests_dir = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib';
+if ( ! $wp_revisions_control_tests_tests_dir ) {
+	$wp_revisions_control_tests_tests_dir = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib';
 }
 
-if ( ! file_exists( $_tests_dir . '/includes/functions.php' ) ) {
-	echo "Could not find $_tests_dir/includes/functions.php, have you run bin/install-wp-tests.sh ?" . PHP_EOL; // WPCS: XSS ok.
+if ( ! file_exists( $wp_revisions_control_tests_tests_dir . '/includes/functions.php' ) ) {
+	echo "Could not find $wp_revisions_control_tests_tests_dir/includes/functions.php, have you run bin/install-wp-tests.sh ?" . PHP_EOL; // WPCS: XSS ok.
 	exit( 1 );
 }
 
 // Give access to tests_add_filter() function.
-require_once $_tests_dir . '/includes/functions.php';
+require_once $wp_revisions_control_tests_tests_dir . '/includes/functions.php';
 
 /**
  * Stub admin-only function not needed for testing.
  */
+// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
 if ( ! function_exists( 'post_revisions_meta_box' ) ) {
+	/**
+	 * Stub for Core's revisions meta box.
+	 */
 	function post_revisions_meta_box() {}
 }
+// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
 
 /**
  * Manually load the plugin being tested.
  */
-function _manually_load_plugin() {
+function wp_revisions_control_tests_manually_load_plugin() {
 	require dirname( dirname( __FILE__ ) ) . '/wp-revisions-control.php';
 }
 tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
 
 // Start up the WP testing environment.
-require $_tests_dir . '/includes/bootstrap.php';
+require $wp_revisions_control_tests_tests_dir . '/includes/bootstrap.php';
diff --git a/tests/test-purges.php b/tests/test-purges.php
index 3bfd4e8..305b3e1 100755
--- a/tests/test-purges.php
+++ b/tests/test-purges.php
@@ -39,7 +39,7 @@ class TestPurges extends WP_UnitTestCase {
 			'Failed to assert that there are revisions to purge.'
 		);
 
-		$purge = WP_Revisions_Control::get_instance()->do_purge_all( $post_id );
+		$purge               = WP_Revisions_Control::get_instance()->do_purge_all( $post_id );
 		$revisions_remaining = count( wp_get_post_revisions( $post_id ) );
 
 		$this->assertEquals(
@@ -93,7 +93,7 @@ class TestPurges extends WP_UnitTestCase {
 			'Failed to assert that post is limited to a given number of revisions.'
 		);
 
-		$purge = WP_Revisions_Control::get_instance()->do_purge_excess( $post_id );
+		$purge               = WP_Revisions_Control::get_instance()->do_purge_excess( $post_id );
 		$revisions_remaining = count( wp_get_post_revisions( $post_id ) );
 
 		$this->assertEquals(
diff --git a/tests/test-ui.php b/tests/test-ui.php
index 3cc9305..f634f05 100755
--- a/tests/test-ui.php
+++ b/tests/test-ui.php
@@ -27,7 +27,7 @@ class TestUI extends WP_UnitTestCase {
 	 * Test meta box with no meta set.
 	 */
 	public function test_no_meta() {
-		$post_id    = $this->factory->post->create();
+		$post_id = $this->factory->post->create();
 
 		ob_start();
 		WP_Revisions_Control::get_instance()->revisions_meta_box( get_post( $post_id ) );
@@ -44,7 +44,7 @@ class TestUI extends WP_UnitTestCase {
 	 * Test meta box with no limit set.
 	 */
 	public function test_no_limit() {
-		$post_id    = $this->factory->post->create();
+		$post_id = $this->factory->post->create();
 		update_post_meta( $post_id, static::$meta_key, -1 );
 
 		ob_start();
-- 
GitLab