mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
Code Modernization: Remove all code using a version_compare() with a PHP version older than PHP 5.6.
Props jrf. Fixes #48074. git-svn-id: https://develop.svn.wordpress.org/trunk@46214 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -465,12 +465,8 @@ class WpdbExposedMethodsForTesting extends wpdb {
|
||||
function benchmark_pcre_backtracking( $pattern, $subject, $strategy ) {
|
||||
$saved_config = ini_get( 'pcre.backtrack_limit' );
|
||||
|
||||
// Attempt to prevent PHP crashes. Adjust these lower when needed.
|
||||
if ( version_compare( phpversion(), '5.4.8', '>' ) ) {
|
||||
$limit = 1000000;
|
||||
} else {
|
||||
$limit = 20000; // 20,000 is a reasonable upper limit, but see also https://core.trac.wordpress.org/ticket/29557#comment:10
|
||||
}
|
||||
// Attempt to prevent PHP crashes. Adjust these lower when needed.
|
||||
$limit = 1000000;
|
||||
|
||||
// Start with small numbers, so if a crash is encountered at higher numbers we can still debug the problem.
|
||||
for ( $i = 4; $i <= $limit; $i *= 2 ) {
|
||||
|
||||
@@ -12,14 +12,6 @@
|
||||
<!-- Default test suite to run all tests -->
|
||||
<testsuite name="default">
|
||||
<directory suffix=".php">tests</directory>
|
||||
<file phpVersion="5.3.0">tests/phpunit/tests/actions/closures.php</file>
|
||||
<file phpVersion="5.3.0">tests/phpunit/tests/image/editor.php</file>
|
||||
<file phpVersion="5.3.0">tests/phpunit/tests/image/editorGd.php</file>
|
||||
<file phpVersion="5.3.0">tests/phpunit/tests/image/editorImagick.php</file>
|
||||
<exclude>tests/phpunit/tests/actions/closures.php</exclude>
|
||||
<exclude>tests/phpunit/tests/image/editor.php</exclude>
|
||||
<exclude>tests/phpunit/tests/image/editorGd.php</exclude>
|
||||
<exclude>tests/phpunit/tests/image/editorImagick.php</exclude>
|
||||
<!-- Path relative to the checkout root, for PHPUnit 3.6.x -->
|
||||
<exclude>tests/phpunit/tests/rest-api/rest-autosaves-controller.php</exclude>
|
||||
<!-- Same path relative to the configuration file, for PHPUnit 4.0.0+ -->
|
||||
|
||||
@@ -24,10 +24,6 @@ class Tests_Admin_WpPrivacyRequestsTable extends WP_UnitTestCase {
|
||||
* @return PHPUnit_Framework_MockObject_MockObject|WP_Privacy_Requests_Table $instance Mocked class instance.
|
||||
*/
|
||||
public function get_mocked_class_instance() {
|
||||
if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
|
||||
$this->markTestSkipped( 'ReflectionMethod::setAccessible is only available in PHP 5.3+' );
|
||||
}
|
||||
|
||||
$args = array(
|
||||
'plural' => 'privacy_requests',
|
||||
'singular' => 'privacy_request',
|
||||
|
||||
@@ -249,11 +249,6 @@ EOT;
|
||||
$this->markTestSkipped( 'The intl extension is not loaded. ResourceBundle not tested for is_countable().' );
|
||||
}
|
||||
|
||||
if ( version_compare( PHP_VERSION, '5.4', '<' ) ) {
|
||||
$this->markTestSkipped( 'ResourceBundle is only countable in PHP 5.4+' );
|
||||
return;
|
||||
}
|
||||
|
||||
$this->assertTrue( is_countable( new ResourceBundle( 'en', null ) ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -1083,9 +1083,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
);
|
||||
|
||||
// Add global namespace prefix to check #41488.
|
||||
if ( version_compare( PHP_VERSION, '5.3', '>=' ) ) {
|
||||
$original_args['fallback_cb'] = '\\' . $original_args['fallback_cb'];
|
||||
}
|
||||
$original_args['fallback_cb'] = '\\' . $original_args['fallback_cb'];
|
||||
|
||||
$args = $menus->filter_wp_nav_menu_args( $original_args );
|
||||
|
||||
|
||||
@@ -482,10 +482,6 @@ class Tests_DB_Charset extends WP_UnitTestCase {
|
||||
* @ticket 21212
|
||||
*/
|
||||
function test_strip_invalid_text( $data, $expected, $message ) {
|
||||
if ( version_compare( PHP_VERSION, '5.3', '<' ) && stristr( php_uname( 's' ), 'win' ) ) {
|
||||
$this->markTestSkipped( 'This test fails in PHP 5.2 on Windows. See https://core.trac.wordpress.org/ticket/31262' );
|
||||
}
|
||||
|
||||
$charset = self::$_wpdb->charset;
|
||||
if ( isset( $data[0]['connection_charset'] ) ) {
|
||||
$new_charset = $data[0]['connection_charset'];
|
||||
|
||||
@@ -918,10 +918,6 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
* @ticket 28786
|
||||
*/
|
||||
function test_wp_json_encode_depth() {
|
||||
if ( version_compare( PHP_VERSION, '5.5', '<' ) ) {
|
||||
$this->markTestSkipped( 'json_encode() supports the $depth parameter in PHP 5.5+' );
|
||||
};
|
||||
|
||||
$data = array( array( array( 1, 2, 3 ) ) );
|
||||
$json = wp_json_encode( $data, 0, 1 );
|
||||
$this->assertFalse( $json );
|
||||
|
||||
@@ -705,11 +705,6 @@ class Tests_Post_Query extends WP_UnitTestCase {
|
||||
* @dataProvider set_found_posts_provider
|
||||
*/
|
||||
public function test_set_found_posts_not_posts_as_an_array( $posts, $expected ) {
|
||||
if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
|
||||
$this->markTestSkipped( 'ReflectionMethod::setAccessible is only available in PHP 5.3+' );
|
||||
return;
|
||||
}
|
||||
|
||||
$q = new WP_Query(
|
||||
array(
|
||||
'post_type' => 'wptests_pt',
|
||||
|
||||
@@ -491,10 +491,6 @@ class Tests_REST_Request extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_has_valid_params_json_error() {
|
||||
if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
|
||||
return $this->markTestSkipped( 'JSON validation is only available for PHP 5.3+' );
|
||||
}
|
||||
|
||||
$this->request->set_header( 'Content-Type', 'application/json' );
|
||||
$this->request->set_body( '{"invalid": JSON}' );
|
||||
|
||||
@@ -507,10 +503,6 @@ class Tests_REST_Request extends WP_UnitTestCase {
|
||||
|
||||
|
||||
public function test_has_valid_params_empty_json_no_error() {
|
||||
if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
|
||||
return $this->markTestSkipped( 'JSON validation is only available for PHP 5.3+' );
|
||||
}
|
||||
|
||||
$this->request->set_header( 'Content-Type', 'application/json' );
|
||||
$this->request->set_body( '' );
|
||||
|
||||
|
||||
@@ -126,10 +126,6 @@ class Tests_Theme_Custom_Header extends WP_UnitTestCase {
|
||||
$this->assertFalse( has_custom_header() );
|
||||
$this->assertEmpty( $html );
|
||||
|
||||
// ReflectionMethod::setAccessible is only available in PHP 5.3+
|
||||
if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
|
||||
return;
|
||||
}
|
||||
// The container should always be returned in the Customizer preview.
|
||||
$this->_set_customize_previewing( true );
|
||||
$html = get_custom_header_markup();
|
||||
@@ -226,11 +222,6 @@ class Tests_Theme_Custom_Header extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
function test_header_script_is_enqueued_by_the_custom_header_markup_without_video_when_previewing_in_customizer() {
|
||||
if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
|
||||
$this->markTestSkipped( 'ReflectionMethod::setAccessible is only available in PHP 5.3+' );
|
||||
return;
|
||||
}
|
||||
|
||||
$this->_add_theme_support(
|
||||
array(
|
||||
'video' => true,
|
||||
|
||||
@@ -479,11 +479,6 @@ class Test_WP_Widget_Media extends WP_UnitTestCase {
|
||||
* @covers WP_Widget_Media::has_content()
|
||||
*/
|
||||
function test_has_content() {
|
||||
if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
|
||||
$this->markTestSkipped( 'ReflectionMethod::setAccessible is only available for PHP 5.3+' );
|
||||
return;
|
||||
}
|
||||
|
||||
$attachment_id = self::factory()->attachment->create_object(
|
||||
array(
|
||||
'file' => DIR_TESTDATA . '/images/canola.jpg',
|
||||
|
||||
Reference in New Issue
Block a user