Skip to content

Commit

Permalink
Merge pull request #679 from lucatume/v4-update-core-phpunit-suite
Browse files Browse the repository at this point in the history
v4 update core phpunit suite
  • Loading branch information
lucatume authored Dec 7, 2023
2 parents 61556dc + 4f17043 commit 0d872e4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
25 changes: 13 additions & 12 deletions config/patches/core-phpunit/includes/abstract-testcase.php.patch
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
diff --git a/includes/core-phpunit/includes/abstract-testcase.php b/includes/core-phpunit/includes/abstract-testcase.php
index 38f846e5..8b627a4c 100644
index 3600722f..67c4d71c 100644
--- a/includes/core-phpunit/includes/abstract-testcase.php
+++ b/includes/core-phpunit/includes/abstract-testcase.php
@@ -19,6 +19,7 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase {
protected $caught_deprecated = array();
@@ -20,6 +20,8 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase {
protected $expected_doing_it_wrong = array();
protected $caught_doing_it_wrong = array();
+ private static ?string $calledClass = null;

+ private static ?string $calledClass = null;
+
protected static $hooks_saved = array();
protected static $ignore_files;
@@ -37,7 +38,7 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase {

@@ -37,7 +39,7 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase {
*
* @return WP_UnitTest_Factory The fixture factory.
*/
Expand All @@ -19,7 +20,7 @@ index 38f846e5..8b627a4c 100644
static $factory = null;
if ( ! $factory ) {
$factory = new WP_UnitTest_Factory();
@@ -53,7 +54,7 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase {
@@ -53,7 +55,7 @@ protected static function factory() {
* @return string The class name.
*/
public static function get_called_class() {
Expand All @@ -28,25 +29,25 @@ index 38f846e5..8b627a4c 100644
}

/**
@@ -69,7 +70,7 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase {
@@ -69,7 +71,7 @@ public static function set_up_before_class() {
$wpdb->db_connect();
ini_set( 'display_errors', 1 );

- $class = get_called_class();
+ $class = self::$calledClass ?? get_called_class();

if ( method_exists( $class, 'wpSetUpBeforeClass' ) ) {
call_user_func( array( $class, 'wpSetUpBeforeClass' ), self::factory() );
@@ -82,7 +83,7 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase {
call_user_func( array( $class, 'wpSetUpBeforeClass' ), static::factory() );
@@ -82,7 +84,7 @@ public static function set_up_before_class() {
* Runs the routine after all tests have been run.
*/
public static function tear_down_after_class() {
- $class = get_called_class();
+ $class = self::$calledClass ?? get_called_class();
+ $class = self::$calledClass ?? get_called_class();

if ( method_exists( $class, 'wpTearDownAfterClass' ) ) {
call_user_func( array( $class, 'wpTearDownAfterClass' ) );
@@ -623,7 +624,7 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase {
@@ -646,7 +648,7 @@ public function expectedDeprecated() {
*
* @since 4.2.0
*/
Expand All @@ -55,7 +56,7 @@ index 38f846e5..8b627a4c 100644
$this->expectedDeprecated();
}

@@ -1604,4 +1605,9 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase {
@@ -1655,4 +1657,9 @@ public static function touch( $file ) {

touch( $file );
}
Expand Down
9 changes: 5 additions & 4 deletions includes/core-phpunit/includes/abstract-testcase.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase {
protected $caught_deprecated = array();
protected $expected_doing_it_wrong = array();
protected $caught_doing_it_wrong = array();
private static ?string $calledClass = null;

private static ?string $calledClass = null;

protected static $hooks_saved = array();
protected static $ignore_files;
Expand Down Expand Up @@ -73,7 +74,7 @@ public static function set_up_before_class() {
$class = self::$calledClass ?? get_called_class();

if ( method_exists( $class, 'wpSetUpBeforeClass' ) ) {
call_user_func( array( $class, 'wpSetUpBeforeClass' ), self::factory() );
call_user_func( array( $class, 'wpSetUpBeforeClass' ), static::factory() );
}

self::commit_transaction();
Expand All @@ -83,7 +84,7 @@ public static function set_up_before_class() {
* Runs the routine after all tests have been run.
*/
public static function tear_down_after_class() {
$class = self::$calledClass ?? get_called_class();
$class = self::$calledClass ?? get_called_class();

if ( method_exists( $class, 'wpTearDownAfterClass' ) ) {
call_user_func( array( $class, 'wpTearDownAfterClass' ) );
Expand All @@ -103,7 +104,7 @@ public static function tear_down_after_class() {
public function set_up() {
set_time_limit( 0 );

$this->factory = self::factory();
$this->factory = static::factory();

if ( ! self::$ignore_files ) {
self::$ignore_files = $this->scan_user_uploads();
Expand Down

0 comments on commit 0d872e4

Please sign in to comment.