Skip to content

Commit 64444cd

Browse files
committed
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. git-svn-id: https://develop.svn.wordpress.org/branches/5.7@50509 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 739323f commit 64444cd

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

tests/phpunit/tests/shortcode.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,9 +744,27 @@ function data_whole_posts() {
744744
return data_whole_posts();
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() {
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+
}
748766

749-
$file = file_get_contents( ABSPATH . 'js/_enqueues/wp/shortcode.js' );
767+
$file = file_get_contents( $path );
750768
$matched = preg_match( '|\s+pattern = (\/.+\/)g;|', $file, $matches );
751769
$php = get_shortcode_atts_regex();
752770

0 commit comments

Comments
 (0)