Make WordPress Core

Ticket #22229: 22229-unittests.diff

File 22229-unittests.diff, 1.4 KB (added by MikeHansenMe, 10 years ago)

see #30284

  • tests/phpunit/tests/dependencies/scripts.php

    diff --git a/tests/phpunit/tests/dependencies/scripts.php b/tests/phpunit/tests/dependencies/scripts.php
    index 3f4e724..b1287e9 100644
    a b class Tests_Dependencies_Scripts extends WP_UnitTestCase { 
    8484                // Cleanup
    8585                $wp_scripts->base_url = $base_url_backup;
    8686        }
     87
     88        /**
     89         * @ticket 22229
     90         */
     91        function test_inline_should_not_output_script_tag_with_src() {
     92                wp_enqueue_script( 'baba-inline-0', 'inline' );
     93                $this->assertEquals( '', get_echo( 'wp_print_scripts' ) );
     94        }
     95
     96        /**
     97         * @ticket 22229
     98         */
     99        function test_json_encode_should_not_encode_special_literal_values() {
     100                if ( ! class_exists( 'WP_JS_Literal' ) ) {
     101                        $this->markTestSkipped( "WP_JS_Literal class doesn't exist" );
     102                }
     103
     104                $literal = new WP_JS_Literal( 'baba()' );
     105                $this->assertEquals( '{"x":baba()}', WP_JS_Literal::json_encode( array( 'x' => $literal ), array( $literal ) ) );
     106        }
     107
     108        /**
     109         * @ticket 22229
     110         */
     111        function test_json_encode_should_not_encode_special_literal_values_with_dependencies() {
     112                if ( ! class_exists( 'WP_JS_Literal' ) ) {
     113                        $this->markTestSkipped( "WP_JS_Literal class doesn't exist" );
     114                }
     115               
     116                $literal = new WP_JS_Literal( 'baba()', array( 'dep0', 'dep1' ) );
     117                $this->assertEquals( '{"x":baba()}', WP_JS_Literal::json_encode( array( 'x' => $literal ), array( $literal ) ) );
     118        }
    87119}