Make WordPress Core


Ignore:
Timestamp:
05/06/2022 11:09:54 AM (2 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.

File:
1 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    }
Note: See TracChangeset for help on using the changeset viewer.