Code Duplication    Length = 43-44 lines in 2 locations

tests/test-ao.php 2 locations

@@ 1941-1984 (lines=44) @@
1938
        $this->assertTrue( $partners instanceof autoptimizePartners );
1939
    }
1940
1941
    public function test_html_minify_keep_html_comments_inside_script_blocks()
1942
    {
1943
        $markup   = <<<MARKUP
1944
<script>
1945
<!-- End Support AJAX add to cart -->
1946
var a = "b";
1947
</script>
1948
MARKUP;
1949
        $expected = <<<MARKUP
1950
<script><!-- End Support AJAX add to cart -->
1951
var a = "b";</script>
1952
MARKUP;
1953
1954
        $markup2 = <<<MARKUP
1955
<script>
1956
var a = "b";
1957
<!-- End Support AJAX add to cart -->
1958
</script>
1959
MARKUP;
1960
1961
        $expected2 = <<<MARKUP
1962
<script>var a = "b";
1963
<!-- End Support AJAX add to cart --></script>
1964
MARKUP;
1965
1966
        // When keepcomments is true.
1967
        $options = [
1968
            'autoptimizeHTML' => [
1969
                'keepcomments' => true,
1970
            ],
1971
        ];
1972
1973
        $instance = new autoptimizeHTML( $markup );
1974
        $instance->read( $options['autoptimizeHTML'] );
1975
        $instance->minify();
1976
        $actual = $instance->getcontent();
1977
        $this->assertEquals( $expected, $actual );
1978
1979
        $instance = new autoptimizeHTML( $markup2 );
1980
        $instance->read( $options['autoptimizeHTML'] );
1981
        $instance->minify();
1982
        $actual2 = $instance->getcontent();
1983
        $this->assertEquals( $expected2, $actual2 );
1984
    }
1985
1986
    public function test_html_minify_remove_html_comments_inside_script_blocks()
1987
    {
@@ 1986-2028 (lines=43) @@
1983
        $this->assertEquals( $expected2, $actual2 );
1984
    }
1985
1986
    public function test_html_minify_remove_html_comments_inside_script_blocks()
1987
    {
1988
        // Default case, html comments removed (keepcomments = false).
1989
        $markup1   = <<<MARKUP
1990
<script>
1991
var a = "b";
1992
<!-- End Support AJAX add to cart -->
1993
</script>
1994
MARKUP;
1995
        $expected1 = <<<MARKUP
1996
<script>var a = "b";
1997
<!-- End Support AJAX add to cart</script>
1998
MARKUP;
1999
2000
        $markup2   = <<<MARKUP
2001
<script>
2002
<!-- End Support AJAX add to cart -->
2003
var a = "b";
2004
</script>
2005
MARKUP;
2006
        $expected2 = <<<MARKUP
2007
<script>End Support AJAX add to cart -->
2008
var a = "b";</script>
2009
MARKUP;
2010
2011
        $options = [
2012
            'autoptimizeHTML' => [
2013
                'keepcomments' => false,
2014
            ],
2015
        ];
2016
2017
        $instance = new autoptimizeHTML( $markup1 );
2018
        $instance->read( $options['autoptimizeHTML'] );
2019
        $instance->minify();
2020
        $actual = $instance->getcontent();
2021
        $this->assertEquals( $expected1, $actual );
2022
2023
        $instance = new autoptimizeHTML( $markup2 );
2024
        $instance->read( $options['autoptimizeHTML'] );
2025
        $instance->minify();
2026
        $actual2 = $instance->getcontent();
2027
        $this->assertEquals( $expected2, $actual2 );
2028
    }
2029
2030
    public function test_html_minify_html_comments_inside_script_blocks_old_school_pattern()
2031
    {