Skip to content

Commit

Permalink
build(v3.5) auto-build updates
Browse files Browse the repository at this point in the history
  • Loading branch information
lucatume committed Feb 19, 2024
1 parent ab1e9a7 commit cba1793
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 21 deletions.
1 change: 1 addition & 0 deletions includes/core-phpunit/includes/abstract-testcase.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ public static function flush_cache() {
'site-options',
'site-queries',
'site-transient',
'theme_files',
'rss',
'users',
'user-queries',
Expand Down
49 changes: 36 additions & 13 deletions includes/core-phpunit/includes/phpunit6/compat.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,42 @@
<?php

if ( class_exists( 'PHPUnit\Runner\Version' ) && version_compare( PHPUnit\Runner\Version::id(), '6.0', '>=' ) ) {

class_alias( 'PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase' );
class_alias( 'PHPUnit\Framework\Exception', 'PHPUnit_Framework_Exception' );
class_alias( 'PHPUnit\Framework\ExpectationFailedException', 'PHPUnit_Framework_ExpectationFailedException' );
class_alias( 'PHPUnit\Framework\Error\Deprecated', 'PHPUnit_Framework_Error_Deprecated' );
class_alias( 'PHPUnit\Framework\Error\Notice', 'PHPUnit_Framework_Error_Notice' );
class_alias( 'PHPUnit\Framework\Error\Warning', 'PHPUnit_Framework_Error_Warning' );
class_alias( 'PHPUnit\Framework\Test', 'PHPUnit_Framework_Test' );
class_alias( 'PHPUnit\Framework\Warning', 'PHPUnit_Framework_Warning' );
class_alias( 'PHPUnit\Framework\AssertionFailedError', 'PHPUnit_Framework_AssertionFailedError' );
class_alias( 'PHPUnit\Framework\TestSuite', 'PHPUnit_Framework_TestSuite' );
class_alias( 'PHPUnit\Framework\TestListener', 'PHPUnit_Framework_TestListener' );
class_alias( 'PHPUnit\Util\GlobalState', 'PHPUnit_Util_GlobalState' );
if (!class_exists('PHPUnit_Framework_TestCase')) {
class_alias('PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase');
}
if (!class_exists('PHPUnit_Framework_Exception')) {
class_alias('PHPUnit\Framework\Exception', 'PHPUnit_Framework_Exception');
}
if (!class_exists('PHPUnit_Framework_ExpectationFailedException')) {
class_alias('PHPUnit\Framework\ExpectationFailedException', 'PHPUnit_Framework_ExpectationFailedException');
}
if (!class_exists('PHPUnit_Framework_Error_Deprecated')) {
class_alias('PHPUnit\Framework\Error\Deprecated', 'PHPUnit_Framework_Error_Deprecated');
}
if (!class_exists('PHPUnit_Framework_Error_Notice')) {
class_alias('PHPUnit\Framework\Error\Notice', 'PHPUnit_Framework_Error_Notice');
}
if (!class_exists('PHPUnit_Framework_Error_Warning')) {
class_alias('PHPUnit\Framework\Error\Warning', 'PHPUnit_Framework_Error_Warning');
}
if (!class_exists('PHPUnit_Framework_Test')) {
class_alias('PHPUnit\Framework\Test', 'PHPUnit_Framework_Test');
}
if (!class_exists('PHPUnit_Framework_Warning')) {
class_alias('PHPUnit\Framework\Warning', 'PHPUnit_Framework_Warning');
}
if (!class_exists('PHPUnit_Framework_AssertionFailedError')) {
class_alias('PHPUnit\Framework\AssertionFailedError', 'PHPUnit_Framework_AssertionFailedError');
}
if (!class_exists('PHPUnit_Framework_TestSuite')) {
class_alias('PHPUnit\Framework\TestSuite', 'PHPUnit_Framework_TestSuite');
}
if (!class_exists('PHPUnit_Framework_TestListener')) {
class_alias('PHPUnit\Framework\TestListener', 'PHPUnit_Framework_TestListener');
}
if (!class_exists('PHPUnit_Util_GlobalState')) {
class_alias('PHPUnit\Util\GlobalState', 'PHPUnit_Util_GlobalState');
}
if ( class_exists( 'PHPUnit\Util\Getopt' ) ) {
class_alias( 'PHPUnit\Util\Getopt', 'PHPUnit_Util_Getopt' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,16 @@ protected function check_post_data( $post, $data, $context, $links ) {
$this->assertSame( get_page_template_slug( $post->ID ), $data['template'] );
}

if ( post_type_supports( $post->post_type, 'thumbnail' ) ) {
if (
post_type_supports( $post->post_type, 'thumbnail' ) ||
(
'attachment' === $post->post_type &&
(
post_type_supports( 'attachment:audio', 'thumbnail' ) ||
post_type_supports( 'attachment:video', 'thumbnail' )
)
)
) {
$this->assertSame( (int) get_post_thumbnail_id( $post->ID ), $data['featured_media'] );
} else {
$this->assertArrayNotHasKey( 'featured_media', $data );
Expand Down
6 changes: 0 additions & 6 deletions includes/core-phpunit/includes/unregister-blocks-hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,3 @@
remove_action( 'init', 'register_block_core_tag_cloud' );
remove_action( 'init', 'register_block_core_template_part' );
remove_action( 'init', 'register_block_core_term_description' );

// Temporary hook removals to prevent impacting the phpunit tests timing.
remove_action( 'registered_post_type', 'block_core_navigation_link_register_post_type_variation' );
remove_action( 'registered_taxonomy', 'block_core_navigation_link_register_taxonomy_variation' );
remove_action( 'unregistered_post_type', 'block_core_navigation_link_unregister_post_type_variation' );
remove_action( 'unregistered_taxonomy', 'block_core_navigation_link_unregister_taxonomy_variation' );
2 changes: 1 addition & 1 deletion src/Extension/IsolationSupport.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class IsolationSupport extends Extension
'WPBROWSER_DATA_NAME' => \$dataName,
'WPBROWSER_DATA_SET' => \$encodedDataSet,
'WPBROWSER_TEST_FILE' => '{{file}}'
],
]
);
\$exitCode = \$process->run();
Expand Down
20 changes: 20 additions & 0 deletions src/TestCase/WPTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ class WPTestCase extends Unit
'Automattic\WooCommerce\RestApi\Server' => ['instance'],
'WC_Payment_Gateways' => ['_instance'],
];
/**
* @var float|null
*/
private $requestTimeFloat;
/**
* @var int|null
*/
private $requestTime;
/**
* @param array<mixed> $data
*/
Expand Down Expand Up @@ -240,13 +248,25 @@ protected function backupAdditionalGlobals(): void
if (isset($GLOBALS['_wp_registered_theme_features'])) {
$this->additionalGlobalsBackup = $GLOBALS['_wp_registered_theme_features'];
}
if (isset($_SERVER['REQUEST_TIME_FLOAT'])) {
$this->requestTimeFloat = $_SERVER['REQUEST_TIME_FLOAT'];
}
if (isset($_SERVER['REQUEST_TIME'])) {
$this->requestTime = $_SERVER['REQUEST_TIME'];
}
}
protected function restoreAdditionalGlobals(): void
{
foreach ($this->additionalGlobalsBackup as $key => $value) {
$GLOBALS[$key] = $value;
unset($this->additionalGlobalsBackup[$key]);
}
if (isset($this->requestTimeFloat)) {
$_SERVER['REQUEST_TIME_FLOAT'] = $this->requestTimeFloat;
}
if (isset($this->requestTime)) {
$_SERVER['REQUEST_TIME'] = $this->requestTime;
}
}
protected function assertPostConditions(): void
{
Expand Down
3 changes: 3 additions & 0 deletions tests/wploadersuite/RunInSeparateProcessAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
use Codeception\Attribute\DataProvider;
use lucatume\WPBrowser\TestCase\WPTestCase;

/**
* @requires PHP 8.0
*/
class RunInSeparateProcessAttributeTest extends WPTestCase
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

use lucatume\WPBrowser\TestCase\WPTestCase;

/**
* @requires PHP 8.0
*/
class RunTestsInSeparateProcessesAttributeTest extends WPTestCase
{
/**
Expand Down

0 comments on commit cba1793

Please sign in to comment.