WordPress.org

Make WordPress Core

Changeset 50509


Ignore:
Timestamp:
03/08/2021 03:14:30 PM (7 months ago)
Author:
desrosj
Message:

Build/Test Tools: Ensure the test_php_and_js_shortcode_attribute_regexes_match() test can run when testing using either the src or build directory.

Reviewed by desrosj, johnbillion.
Props alexstine, desrosj.
Merges [50501] to the 5.7 branch.
Fixes #51734.

Location:
branches/5.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.7

  • branches/5.7/tests/phpunit/tests/shortcode.php

    r50464 r50509  
    745745    }
    746746
     747    /**
     748     * Ensure the shortcode attribute regex is the same in both the PHP and JS implementations.
     749     *
     750     * @ticket 34191
     751     * @ticket 51734
     752     */
    747753    function test_php_and_js_shortcode_attribute_regexes_match() {
    748 
    749         $file    = file_get_contents( ABSPATH . 'js/_enqueues/wp/shortcode.js' );
     754        // This test uses the source file by default but will use the built file if it exists.
     755        // This allows the test to run using either the src or build directory.
     756        $file_src   = ABSPATH . 'js/_enqueues/wp/shortcode.js';
     757        $file_build = ABSPATH . 'wp-includes/js/shortcode.js';
     758
     759        $this->assertTrue( file_exists( $file_src ) || file_exists( $file_build ) );
     760
     761        $path = $file_src;
     762
     763        if ( file_exists( $file_build ) ) {
     764            $path = $file_build;
     765        }
     766
     767        $file    = file_get_contents( $path );
    750768        $matched = preg_match( '|\s+pattern = (\/.+\/)g;|', $file, $matches );
    751769        $php     = get_shortcode_atts_regex();
Note: See TracChangeset for help on using the changeset viewer.