Code Duplication    Length = 43-44 lines in 2 locations

tests/test-ao.php 2 locations

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