Changeset 53686 for trunk/tests/phpunit/tests/utils.php
- Timestamp:
- 07/07/2022 11:55:13 PM (2 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/utils.php
r53684 r53686 2 2 3 3 /** 4 * just make sure the test framework is working 5 * 6 * No Covers as this checks for content in files 4 * Test some helper utility functions of the test framework. 7 5 * 8 6 * @group testsuite 9 7 */ 10 class Tests_ Basicextends WP_UnitTestCase {8 class Tests_Utils extends WP_UnitTestCase { 11 9 12 10 /** 13 * @coversNothing 14 */ 15 public function test_license() { 16 // This test is designed to only run on trunk. 17 $this->skipOnAutomatedBranches(); 18 19 $license = file_get_contents( ABSPATH . 'license.txt' ); 20 preg_match( '#Copyright 2011-(\d+) by the contributors#', $license, $matches ); 21 $license_year = trim( $matches[1] ); 22 $this_year = gmdate( 'Y' ); 23 24 $this->assertSame( $this_year, $license_year, "license.txt's year needs to be updated to $this_year." ); 25 } 26 27 /** 28 * @coversNothing 29 */ 30 public function test_security_md() { 31 // This test is designed to only run on trunk. 32 $this->skipOnAutomatedBranches(); 33 34 $security = file_get_contents( dirname( ABSPATH ) . '/SECURITY.md' ); 35 preg_match_all( '#\d.\d.x#', $security, $matches ); 36 $supported_versions = $matches[0]; 37 $current_version = substr( $GLOBALS['wp_version'], 0, 3 ); 38 $latest_stable = number_format( (float) $current_version - 0.1, 1 ) . '.x'; 39 40 $this->assertContains( $latest_stable, $supported_versions, "SECURITY.md's version needs to be updated to $latest_stable." ); 41 } 42 43 /** 44 * @coversNothing 45 */ 46 public function test_package_json() { 47 $package_json = file_get_contents( dirname( ABSPATH ) . '/package.json' ); 48 $package_json = json_decode( $package_json, true ); 49 list( $version ) = explode( '-', $GLOBALS['wp_version'] ); 50 51 // package.json uses x.y.z, so fill cleaned $wp_version for .0 releases. 52 if ( 1 === substr_count( $version, '.' ) ) { 53 $version .= '.0'; 54 } 55 56 $this->assertSame( $version, $package_json['version'], "package.json's version needs to be updated to $version." ); 57 58 return $package_json; 59 } 60 61 /** 62 * @depends test_package_json 63 * 64 * @coversNothing 65 */ 66 public function test_package_json_node_engine( $package_json ) { 67 $this->assertArrayHasKey( 'engines', $package_json ); 68 $this->assertArrayHasKey( 'node', $package_json['engines'] ); 69 } 70 71 /** 72 * Test some helper utility functions. 73 * 74 * @coversNothing 11 * @covers ::test_strip_ws 75 12 */ 76 13 public function test_strip_ws() { … … 102 39 103 40 /** 104 * @covers Nothing41 * @covers ::mask_input_value 105 42 */ 106 43 public function test_mask_input_value() {
Note: See TracChangeset
for help on using the changeset viewer.