Make WordPress Core

Changeset 53357


Ignore:
Timestamp:
05/06/2022 11:09:54 AM (4 years ago)
Author:
SergeyBiryukov
Message:

Tests: Improve the logic of the SECURITY.md test to check all supported versions.

This avoids a test failure if the list of supported WordPress versions is updated before the trunk version is bumped for a new major release.

Follow-up to [47403], [53347].

Fixes #55667.

Location:
trunk/tests/phpunit/tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/basic.php

    r53349 r53357  
    1414                $license = file_get_contents( ABSPATH . 'license.txt' );
    1515                preg_match( '#Copyright 2011-(\d+) by the contributors#', $license, $matches );
    16                 $this_year = gmdate( 'Y' );
    17                 $this->assertSame( $this_year, trim( $matches[1] ), "license.txt's year needs to be updated to $this_year." );
     16                $license_year = trim( $matches[1] );
     17                $this_year    = gmdate( 'Y' );
     18
     19                $this->assertSame( $this_year, $license_year, "license.txt's year needs to be updated to $this_year." );
    1820        }
    1921
    … …  
    2325
    2426                $security = file_get_contents( dirname( ABSPATH ) . '/SECURITY.md' );
    25                 preg_match( '#\d.\d.x#', $security, $matches );
    26                 $current_version = substr( $GLOBALS['wp_version'], 0, 3 );
    27                 $latest_stable   = number_format( (float) $current_version - 0.1, 1 ) . '.x';
    28                 $this->assertSame( $latest_stable, trim( $matches[0] ), "SECURITY.md's version needs to be updated to $latest_stable." );
     27                preg_match_all( '#\d.\d.x#', $security, $matches );
     28                $supported_versions = $matches[0];
     29                $current_version    = substr( $GLOBALS['wp_version'], 0, 3 );
     30                $latest_stable      = number_format( (float) $current_version - 0.1, 1 ) . '.x';
     31
     32                $this->assertContains( $latest_stable, $supported_versions, "SECURITY.md's version needs to be updated to $latest_stable." );
    2933        }
    3034
    … …  
    3337                $package_json    = json_decode( $package_json, true );
    3438                list( $version ) = explode( '-', $GLOBALS['wp_version'] );
     39
    3540                // package.json uses x.y.z, so fill cleaned $wp_version for .0 releases.
    3641                if ( 1 === substr_count( $version, '.' ) ) {
    3742                        $version .= '.0';
    3843                }
     44
    3945                $this->assertSame( $version, $package_json['version'], "package.json's version needs to be updated to $version." );
     46
    4047                return $package_json;
    4148        }
  • trunk/tests/phpunit/tests/theme.php

    r53349 r53357  
    222222                        $path_to_readme_txt = $wp_theme->get_theme_root() . '/' . $wp_theme->get_stylesheet() . '/readme.txt';
    223223                        $this->assertFileExists( $path_to_readme_txt );
     224
    224225                        $readme    = file_get_contents( $path_to_readme_txt );
    225226                        $this_year = gmdate( 'Y' );
    … …  
    227228                        preg_match( '#Copyright (\d+) WordPress.org#', $readme, $matches );
    228229                        if ( $matches ) {
    229                                 $this->assertSame( $this_year, trim( $matches[1] ), "Bundled themes readme.txt's year needs to be updated to $this_year." );
     230                                $readme_year = trim( $matches[1] );
     231
     232                                $this->assertSame( $this_year, $readme_year, "Bundled themes readme.txt's year needs to be updated to $this_year." );
    230233                        }
    231234
    232235                        preg_match( '#Copyright 20\d\d-(\d+) WordPress.org#', $readme, $matches );
    233236                        if ( $matches ) {
    234                                 $this->assertSame( $this_year, trim( $matches[1] ), "Bundled themes readme.txt's year needs to be updated to $this_year." );
     237                                $readme_year = trim( $matches[1] );
     238
     239                                $this->assertSame( $this_year, $readme_year, "Bundled themes readme.txt's year needs to be updated to $this_year." );
    235240                        }
    236241                }
Note: See TracChangeset for help on using the changeset viewer.