Make WordPress Core

Changeset 50501


Ignore:
Timestamp:
03/05/2021 03:26:22 PM (5 years ago)
Author:
johnbillion
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.

Props alexstine, desrosj

See #51734

File:
1 edited

Legend:

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

    r50441 r50501  
    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.