WordPress.org

Make WordPress Core

Ticket #26629: 26629-unit-test.patch

File 26629-unit-test.patch, 974 bytes (added by TobiasBg, 8 years ago)

Unit test to keep package.json's version up-to-date

  • tests/phpunit/tests/basic.php

     
    2929                $this->assertEquals( $version, trim( $matches[1] ), "readme.html's version needs to be updated to $version." );
    3030        }
    3131
     32        function test_package_json() {
     33                $package_json = file_get_contents( dirname( ABSPATH ) . '/package.json' );
     34                $package_json = json_decode( $package_json , true );
     35                list( $version ) = explode( '-', $GLOBALS['wp_version'] );
     36                // package.json uses x.y.z, so fill cleaned $wp_version for .0 releases
     37                if ( 1 == substr_count( $version, '.' ) ) {
     38                        $version .= '.0';
     39                }
     40                $this->assertEquals( $version, $package_json['version'], "package.json's version needs to be updated to $version." );
     41        }
     42
    3243        // two tests for a lame bug in PHPUnit that broke the $GLOBALS reference
    3344        function test_globals() {
    3445                global $test_foo;