WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/08/2015 03:11:59 AM (6 years ago)
Author:
johnbillion
Message:

Abstract the shortcode attribute parsing regex into its own function, update the JavaScript counterpart, and introduce a test to ensure they do not diverge again.

Fixes #34191
Props miqrogroove, johnbillion

File:
1 edited

Legend:

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

    r34774 r34933  
    633633        return data_whole_posts();
    634634    }
     635
     636    function test_php_and_js_shortcode_attribute_regexes_match() {
     637
     638        $file = file_get_contents( ABSPATH . WPINC . '/js/shortcode.js' );
     639        $matched = preg_match( '|\s+pattern = (\/.+\/)g;|', $file, $matches );
     640        $php = get_shortcode_atts_regex();
     641
     642        $this->assertSame( 1, $matched );
     643
     644        $js = str_replace( "\'", "'", $matches[1] );
     645        $this->assertSame( $php, $js );
     646
     647    }
     648
    635649}
Note: See TracChangeset for help on using the changeset viewer.