WordPress.org

Make WordPress Core

Changeset 36596


Ignore:
Timestamp:
02/20/16 16:16:35 (19 months ago)
Author:
ocean90
Message:

Tests: Test that jQuery can be moved into footer after [36550].

Props gitlost.
See #25247.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/dependencies/jquery.php

    r29252 r36596  
    8282        unset( $GLOBALS['wp_scripts'] ); 
    8383    } 
     84 
     85    /** 
     86     * Test placing of jQuery in footer. 
     87     * 
     88     * @ticket 25247 
     89     */ 
     90    function test_jquery_in_footer() { 
     91        $scripts = new WP_Scripts; 
     92        $scripts->add( 'jquery', false, array( 'jquery-core', 'jquery-migrate' ) ); 
     93        $scripts->add( 'jquery-core', '/jquery.js', array() ); 
     94        $scripts->add( 'jquery-migrate', '/jquery-migrate.js', array() ); 
     95 
     96        $scripts->enqueue( 'jquery' ); 
     97 
     98        $jquery = $scripts->query( 'jquery' ); 
     99        $jquery->add_data( 'group', 1 ); 
     100        foreach( $jquery->deps as $dep ) { 
     101            $scripts->add_data( $dep, 'group', 1 ); 
     102        } 
     103 
     104        $this->expectOutputRegex( '/^(?:<script[^>]+><\/script>\\n){2}$/' ); 
     105 
     106        $scripts->do_items( false, 0 ); 
     107        $this->assertNotContains( 'jquery', $scripts->done ); 
     108        $this->assertNotContains( 'jquery-core', $scripts->done, 'jquery-core should be in footer but is in head' ); 
     109        $this->assertNotContains( 'jquery-migrate', $scripts->done, 'jquery-migrate should be in footer but is in head' ); 
     110 
     111        $scripts->do_items( false, 1 ); 
     112        $this->assertContains( 'jquery', $scripts->done ); 
     113        $this->assertContains( 'jquery-core', $scripts->done, 'jquery-core in footer' ); 
     114        $this->assertContains( 'jquery-migrate', $scripts->done, 'jquery-migrate in footer' ); 
     115    } 
    84116} 
Note: See TracChangeset for help on using the changeset viewer.