Make WordPress Core

Ticket #35873: 35873.3.patch

File 35873.3.patch, 1.8 KB (added by ocean90, 9 years ago)
  • src/wp-includes/class.wp-dependencies.php

     
    385385                $group = (int) $group;
    386386
    387387                if ( $recursion )
    388                         $group = min($this->group, $group);
     388                        $this->group = $group = min($this->group, $group);
    389389                else
    390390                        $this->group = $group;
    391391
  • 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_header  = "<script type='text/javascript' src='http://example.org/grandchild.js?ver=1'></script>\n";
     217                $expected_header .= "<script type='text/javascript' src='http://example.org/child.js?ver=1'></script>\n";
     218                $expected_footer  = "<script type='text/javascript' src='http://example.org/parent.js?ver=1'></script>\n";
     219
     220                $this->assertEquals( $expected_header, $header );
     221                $this->assertEquals( $expected_footer, $footer );
     222        }
    202223}