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

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
```
parent c51f65c9
Branches
Tags
1 merge request!18Fix fatal in test run under PHP 8
Pipeline #4782 passed with warnings
This commit is part of merge request !18. Comments created here will be created in the context of that merge request.
...@@ -36,10 +36,11 @@ class PostFilters extends WP_UnitTestCase { ...@@ -36,10 +36,11 @@ class PostFilters extends WP_UnitTestCase {
/** /**
* Prepare data for tests. * Prepare data for tests.
*
* Not using `setUp` because Yoast polyfills add a return type for PHP 8
* that isn't supported before PHP 7.1.
*/ */
protected function setUp() { protected function _create_post() {
parent::setUp();
static::$post_id = $this->factory->post->create( static::$post_id = $this->factory->post->create(
array( array(
'post_title' => 'Pagination Test', 'post_title' => 'Pagination Test',
...@@ -54,6 +55,8 @@ class PostFilters extends WP_UnitTestCase { ...@@ -54,6 +55,8 @@ class PostFilters extends WP_UnitTestCase {
* Test retrieving page 1 content. * Test retrieving page 1 content.
*/ */
public function test_view_page_1() { public function test_view_page_1() {
$this->_create_post();
query_posts( query_posts(
array( array(
'p' => static::$post_id, 'p' => static::$post_id,
...@@ -73,6 +76,8 @@ class PostFilters extends WP_UnitTestCase { ...@@ -73,6 +76,8 @@ class PostFilters extends WP_UnitTestCase {
* Test retrieving page 2 content. * Test retrieving page 2 content.
*/ */
public function test_view_page_2() { public function test_view_page_2() {
$this->_create_post();
query_posts( query_posts(
array( array(
'p' => static::$post_id, 'p' => static::$post_id,
...@@ -93,6 +98,8 @@ class PostFilters extends WP_UnitTestCase { ...@@ -93,6 +98,8 @@ class PostFilters extends WP_UnitTestCase {
* Test retrieving page 3 content. * Test retrieving page 3 content.
*/ */
public function test_view_page_3() { public function test_view_page_3() {
$this->_create_post();
query_posts( query_posts(
array( array(
'p' => static::$post_id, 'p' => static::$post_id,
...@@ -113,6 +120,8 @@ class PostFilters extends WP_UnitTestCase { ...@@ -113,6 +120,8 @@ class PostFilters extends WP_UnitTestCase {
* Test retrieving "view all" contents. * Test retrieving "view all" contents.
*/ */
public function test_view_all() { public function test_view_all() {
$this->_create_post();
query_posts( query_posts(
array( array(
'p' => static::$post_id, 'p' => static::$post_id,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment