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