From 5f9d1fa7998b7f850d949aec1049641b8c3df6a5 Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Sat, 20 Feb 2016 16:16:35 +0000 Subject: [PATCH] Tests: Test that jQuery can be moved into footer after [36550]. Props gitlost. See #25247. git-svn-id: https://develop.svn.wordpress.org/trunk@36596 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/dependencies/jquery.php | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/phpunit/tests/dependencies/jquery.php b/tests/phpunit/tests/dependencies/jquery.php index 6df4d64ae3..ed2f4d2fa2 100644 --- a/tests/phpunit/tests/dependencies/jquery.php +++ b/tests/phpunit/tests/dependencies/jquery.php @@ -81,4 +81,36 @@ class Tests_Dependencies_jQuery extends WP_UnitTestCase { unset( $GLOBALS['wp_scripts'] ); } + + /** + * Test placing of jQuery in footer. + * + * @ticket 25247 + */ + function test_jquery_in_footer() { + $scripts = new WP_Scripts; + $scripts->add( 'jquery', false, array( 'jquery-core', 'jquery-migrate' ) ); + $scripts->add( 'jquery-core', '/jquery.js', array() ); + $scripts->add( 'jquery-migrate', '/jquery-migrate.js', array() ); + + $scripts->enqueue( 'jquery' ); + + $jquery = $scripts->query( 'jquery' ); + $jquery->add_data( 'group', 1 ); + foreach( $jquery->deps as $dep ) { + $scripts->add_data( $dep, 'group', 1 ); + } + + $this->expectOutputRegex( '/^(?:]+><\/script>\\n){2}$/' ); + + $scripts->do_items( false, 0 ); + $this->assertNotContains( 'jquery', $scripts->done ); + $this->assertNotContains( 'jquery-core', $scripts->done, 'jquery-core should be in footer but is in head' ); + $this->assertNotContains( 'jquery-migrate', $scripts->done, 'jquery-migrate should be in footer but is in head' ); + + $scripts->do_items( false, 1 ); + $this->assertContains( 'jquery', $scripts->done ); + $this->assertContains( 'jquery-core', $scripts->done, 'jquery-core in footer' ); + $this->assertContains( 'jquery-migrate', $scripts->done, 'jquery-migrate in footer' ); + } }