From 8e386725412b775e265c8fffa681f87113acb030 Mon Sep 17 00:00:00 2001
From: Erick Hitter <git-contrib@ethitter.com>
Date: Sat, 11 Jun 2022 13:44:09 -0700
Subject: [PATCH] Fix fatal in test run under PHP 8

```
Fatal error: Declaration of PostFilters::setUp() must be compatible with Yoast\PHPUnitPolyfills\TestCases\TestCase::setUp(): void in /builds/wp-plugins/view-all-posts-pages/tests/test-post-filters.php on line 40
```
---
 tests/bootstrap.php         |  3 --
 tests/class-test-case.php   | 57 -------------------------------------
 tests/test-post-filters.php |  6 ++--
 3 files changed, 2 insertions(+), 64 deletions(-)
 delete mode 100644 tests/class-test-case.php

diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 194b1c0..7dc0c88 100755
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -27,8 +27,5 @@ function _manually_load_plugin() {
 }
 tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
 
-// Load base class for compatibility.
-require __DIR__ . '/class-test-case.php';
-
 // Start up the WP testing environment.
 require $_tests_dir . '/includes/bootstrap.php';
diff --git a/tests/class-test-case.php b/tests/class-test-case.php
deleted file mode 100644
index fbd4b1d..0000000
--- a/tests/class-test-case.php
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-/**
- * Compatibility shim for PHP 8 tests.
- *
- * Yoast polyfills add return type declaration to `setUp` that isn't supported
- * before PHP 7.1, hence this workaround.
- */
-
-namespace View_All_Posts_Pages\Tests;
-
-use WP_UnitTestCase;
-
-if ( version_compare( phpversion(), '8.0.0', '<' ) ) {
-	/**
-	 * Class TestCase.
-	 */
-	abstract class TestCase extends WP_UnitTestCase {
-		/**
-		 * Set up the test.
-		 *
-		 * @return void
-		 */
-		protected function setUp() {
-			parent::setUp();
-			$this->_do_set_up();
-		}
-
-		/**
-		 * Set up the test.
-		 *
-		 * @return void
-		 */
-		abstract function _do_set_up();
-	}
-} else {
-	abstract class TestCase extends WP_UnitTestCase {
-		/**
-		 * Set up the test.
-		 *
-		 * @return void
-		 */
-		protected function setUp(): void {
-			parent::setUp();
-			$this->_do_set_up();
-		}
-
-		/**
-		 * Set up the test.
-		 *
-		 * Not setting a return type as implementing methods cannot always do
-		 * so.
-		 *
-		 * @return void
-		 */
-		abstract protected function _do_set_up();
-	}
-}
diff --git a/tests/test-post-filters.php b/tests/test-post-filters.php
index 0749a7a..cdcfd35 100755
--- a/tests/test-post-filters.php
+++ b/tests/test-post-filters.php
@@ -5,12 +5,10 @@
  * @package View_All_Posts_Pages
  */
 
-use View_All_Posts_Pages\Tests\TestCase;
-
 /**
  * Content-filter test case.
  */
-class PostFilters extends TestCase {
+class PostFilters extends WP_UnitTestCase {
 	/**
 	 * Text for each page of multipage post.
 	 *
@@ -42,7 +40,7 @@ class PostFilters extends TestCase {
 	 * Not using `setUp` because Yoast polyfills add a return type for PHP 8
 	 * that isn't supported before PHP 7.1.
 	 */
-	protected function _do_set_up() {
+	protected function set_up() {
 		static::$post_id = $this->factory->post->create(
 			array(
 				'post_title'   => 'Pagination Test',
-- 
GitLab