Make WordPress Core

Changeset 52424


Ignore:
Timestamp:
12/30/2021 04:27:48 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Tests: Add a unit test for the recommended MariaDB version in readme.html.

Per the MariaDB maintenance policy, MariaDB releases are supported for 5 years from the first stable (GA) release.

The test ensures that the recommended MariaDB version in readme.html is not older than 5 years.

Follow-up to [31291], [35759], [52319], [52358], [52418], [meta11407], [52420], [52421].

Fixes #41490.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/external-http/basic.php

    r52421 r52424  
    2020        $response_body = $this->get_response_body( 'https://www.php.net/supported-versions.php' );
    2121
    22         preg_match_all( '#<tr class="stable">\s*<td>\s*<a [^>]*>\s*([0-9.]*)#s', $response_body, $phpmatches );
     22        preg_match_all( '#<tr class="stable">\s*<td>\s*<a [^>]*>\s*([0-9.]*)#s', $response_body, $php_matches );
    2323
    2424        // TODO: Enable this check once PHP 8.0 compatibility is achieved.
    25         // $this->assertContains( $matches[1], $phpmatches[1], "readme.html's Recommended PHP version is too old. Remember to update the WordPress.org Requirements page, too." );
     25        // $this->assertContains( $matches[1], $php_matches[1], "readme.html's Recommended PHP version is too old. Remember to update the WordPress.org Requirements page, too." );
    2626    }
    2727
     
    4242
    4343        // Retrieve the date of the first GA release for the recommended branch.
    44         preg_match( '#.*(\d{4}-\d{2}-\d{2}), General Availability#s', $response_body, $mysqlmatches );
     44        preg_match( '#.*(\d{4}-\d{2}-\d{2}), General Availability#s', $response_body, $mysql_matches );
    4545
    4646        /*
     
    5353         * TODO: Reduce this back to 5 years once MySQL 8.0 compatibility is achieved.
    5454         */
    55         $mysql_eol = strtotime( $mysqlmatches[1] . ' +8 years' );
     55        $mysql_eol = strtotime( $mysql_matches[1] . ' +8 years' );
    5656
    5757        $this->assertLessThan( $mysql_eol, time(), "readme.html's Recommended MySQL version is too old. Remember to update the WordPress.org Requirements page, too." );
     58    }
     59
     60    /**
     61     * @covers ::wp_remote_get
     62     * @covers ::wp_remote_retrieve_response_code
     63     * @covers ::wp_remote_retrieve_body
     64     */
     65    public function test_readme_mariadb_version() {
     66        // This test is designed to only run on trunk/master.
     67        $this->skipOnAutomatedBranches();
     68
     69        $readme = file_get_contents( ABSPATH . 'readme.html' );
     70
     71        preg_match( '#Recommendations.*MariaDB</a> version <strong>([0-9.]*)#s', $readme, $matches );
     72        $matches[1] = str_replace( '.', '', $matches[1] );
     73
     74        $response_body = $this->get_response_body( "https://mariadb.com/kb/en/release-notes-mariadb-{$matches[1]}-series/" );
     75
     76        // Retrieve the date of the first stable release for the recommended branch.
     77        preg_match( '#.*Stable.*?(\d{2} [A-Za-z]{3} \d{4})#s', $response_body, $mariadb_matches );
     78
     79        // Per https://mariadb.org/about/#maintenance-policy, MariaDB releases are supported for 5 years.
     80        $mariadb_eol = strtotime( $mariadb_matches[1] . ' +5 years' );
     81
     82        $this->assertLessThan( $mariadb_eol, time(), "readme.html's Recommended MariaDB version is too old. Remember to update the WordPress.org Requirements page, too." );
    5883    }
    5984
Note: See TracChangeset for help on using the changeset viewer.