| @@ 1964-2007 (lines=44) @@ | ||
| 1961 | $this->assertTrue( $partners instanceof autoptimizePartners ); |
|
| 1962 | } |
|
| 1963 | ||
| 1964 | public function test_html_minify_keep_html_comments_inside_script_blocks() |
|
| 1965 | { |
|
| 1966 | $markup = <<<MARKUP |
|
| 1967 | <script> |
|
| 1968 | <!-- End Support AJAX add to cart --> |
|
| 1969 | var a = "b"; |
|
| 1970 | </script> |
|
| 1971 | MARKUP; |
|
| 1972 | $expected = <<<MARKUP |
|
| 1973 | <script><!-- End Support AJAX add to cart --> |
|
| 1974 | var a = "b";</script> |
|
| 1975 | MARKUP; |
|
| 1976 | ||
| 1977 | $markup2 = <<<MARKUP |
|
| 1978 | <script> |
|
| 1979 | var a = "b"; |
|
| 1980 | <!-- End Support AJAX add to cart --> |
|
| 1981 | </script> |
|
| 1982 | MARKUP; |
|
| 1983 | ||
| 1984 | $expected2 = <<<MARKUP |
|
| 1985 | <script>var a = "b"; |
|
| 1986 | <!-- End Support AJAX add to cart --></script> |
|
| 1987 | MARKUP; |
|
| 1988 | ||
| 1989 | // When keepcomments is true. |
|
| 1990 | $options = [ |
|
| 1991 | 'autoptimizeHTML' => [ |
|
| 1992 | 'keepcomments' => true, |
|
| 1993 | ], |
|
| 1994 | ]; |
|
| 1995 | ||
| 1996 | $instance = new autoptimizeHTML( $markup ); |
|
| 1997 | $instance->read( $options['autoptimizeHTML'] ); |
|
| 1998 | $instance->minify(); |
|
| 1999 | $actual = $instance->getcontent(); |
|
| 2000 | $this->assertEquals( $expected, $actual ); |
|
| 2001 | ||
| 2002 | $instance = new autoptimizeHTML( $markup2 ); |
|
| 2003 | $instance->read( $options['autoptimizeHTML'] ); |
|
| 2004 | $instance->minify(); |
|
| 2005 | $actual2 = $instance->getcontent(); |
|
| 2006 | $this->assertEquals( $expected2, $actual2 ); |
|
| 2007 | } |
|
| 2008 | ||
| 2009 | public function test_html_minify_remove_html_comments_inside_script_blocks() |
|
| 2010 | { |
|
| @@ 2009-2051 (lines=43) @@ | ||
| 2006 | $this->assertEquals( $expected2, $actual2 ); |
|
| 2007 | } |
|
| 2008 | ||
| 2009 | public function test_html_minify_remove_html_comments_inside_script_blocks() |
|
| 2010 | { |
|
| 2011 | // Default case, html comments removed (keepcomments = false). |
|
| 2012 | $markup1 = <<<MARKUP |
|
| 2013 | <script> |
|
| 2014 | var a = "b"; |
|
| 2015 | <!-- End Support AJAX add to cart --> |
|
| 2016 | </script> |
|
| 2017 | MARKUP; |
|
| 2018 | $expected1 = <<<MARKUP |
|
| 2019 | <script>var a = "b"; |
|
| 2020 | <!-- End Support AJAX add to cart</script> |
|
| 2021 | MARKUP; |
|
| 2022 | ||
| 2023 | $markup2 = <<<MARKUP |
|
| 2024 | <script> |
|
| 2025 | <!-- End Support AJAX add to cart --> |
|
| 2026 | var a = "b"; |
|
| 2027 | </script> |
|
| 2028 | MARKUP; |
|
| 2029 | $expected2 = <<<MARKUP |
|
| 2030 | <script>End Support AJAX add to cart --> |
|
| 2031 | var a = "b";</script> |
|
| 2032 | MARKUP; |
|
| 2033 | ||
| 2034 | $options = [ |
|
| 2035 | 'autoptimizeHTML' => [ |
|
| 2036 | 'keepcomments' => false, |
|
| 2037 | ], |
|
| 2038 | ]; |
|
| 2039 | ||
| 2040 | $instance = new autoptimizeHTML( $markup1 ); |
|
| 2041 | $instance->read( $options['autoptimizeHTML'] ); |
|
| 2042 | $instance->minify(); |
|
| 2043 | $actual = $instance->getcontent(); |
|
| 2044 | $this->assertEquals( $expected1, $actual ); |
|
| 2045 | ||
| 2046 | $instance = new autoptimizeHTML( $markup2 ); |
|
| 2047 | $instance->read( $options['autoptimizeHTML'] ); |
|
| 2048 | $instance->minify(); |
|
| 2049 | $actual2 = $instance->getcontent(); |
|
| 2050 | $this->assertEquals( $expected2, $actual2 ); |
|
| 2051 | } |
|
| 2052 | ||
| 2053 | public function test_html_minify_html_comments_inside_script_blocks_old_school_pattern() |
|
| 2054 | { |
|