Make WordPress Core

Ticket #35873: 35873.patch

File 35873.patch, 1.3 KB (added by ocean90, 9 years ago)
  • tests/phpunit/tests/dependencies/scripts.php

     
    199199                $this->assertContains( home_url( 'bar.js' ), $footer );
    200200                $this->assertContains( home_url( 'baz.js' ), $footer );
    201201        }
     202
     203        /**
     204         * @ticket 35873
     205         */
     206        function test_wp_register_script_with_dependencies_in_head_and_footer() {
     207                wp_register_script( 'parent', home_url( 'parent.js' ), array( 'child' ), '1', true ); // in footer
     208                wp_register_script( 'child', home_url( 'child.js' ), array( 'grandchild' ), '1', false ); // in head
     209                wp_register_script( 'grandchild', home_url( 'grandchild.js' ), array(), '1', true ); // in footer
     210
     211                wp_enqueue_script( 'parent' );
     212
     213                $header = get_echo( 'wp_print_head_scripts' );
     214                $footer = get_echo( 'wp_print_footer_scripts' );
     215
     216                $expected  = "<script type='text/javascript' src='http://example.org/grandchild.js?ver=1'></script>\n";
     217                $expected .= "<script type='text/javascript' src='http://example.org/child.js?ver=1'></script>\n";
     218                $expected .= "<script type='text/javascript' src='http://example.org/parent.js?ver=1'></script>\n";
     219
     220                $this->assertEquals( $expected, $header );
     221                $this->assertEmpty( $footer );
     222        }
    202223}