Make WordPress Core

Ticket #44571: 44571.tests.diff

File 44571.tests.diff, 1.1 KB (added by soulseekah, 6 years ago)

Tests for force_balance_tags

  • new file tests/phpunit/tests/formatting/ForceBalanceTags.php

    diff --git tests/phpunit/tests/formatting/ForceBalanceTags.php tests/phpunit/tests/formatting/ForceBalanceTags.php
    new file mode 100644
    index 0000000..e63efb5
    - +  
     1<?php
     2
     3/**
     4 * @group formatting
     5 */
     6class Tests_Formatting_ForceBalanceTags extends WP_UnitTestCase {
     7        function test_balance_simple() {
     8                $this->assertEquals( '<p>hello</p>', force_balance_tags( '<p>hello' ) );
     9                $this->assertEquals( '<script>console.log("hello");</script>', force_balance_tags( '<script>console.log("hello");' ) );
     10        }
     11
     12        function test_balance_simple_balanced() {
     13                $this->assertEquals( '<p>hello</p>', force_balance_tags( '<p>hello</p>' ) );
     14                $this->assertEquals( '<script>console.log("hello");</script>', force_balance_tags( '<script>console.log("hello");</script>' ) );
     15        }
     16
     17        /**
     18         * @ticket 44571
     19         */
     20        function test_balance_script_tag_with_brackets() {
     21                $script = '<script>console.log("extest:", 0<=1);</script>';
     22                $this->assertEquals( $script, force_balance_tags( $script ) );
     23        }
     24}