@@ 2568-2584 (lines=17) @@ | ||
2565 | * |
|
2566 | * Exception case: image served by .php, should not be proxied. |
|
2567 | */ |
|
2568 | public function test_imgopt_php() |
|
2569 | { |
|
2570 | $opts = autoptimizeImages::fetch_options(); |
|
2571 | $opts['autoptimize_imgopt_checkbox_field_1'] = '1'; |
|
2572 | $opts['autoptimize_imgopt_checkbox_field_3'] = '0'; |
|
2573 | ||
2574 | $markup = <<<MARKUP |
|
2575 | <img src='/wp-content/plugins/imageplugin/image.php?id=16' width='400' height='200'> |
|
2576 | MARKUP; |
|
2577 | ||
2578 | $instance = autoptimizeImages::instance(); |
|
2579 | $instance->set_options( $opts ); |
|
2580 | $actual = $instance->filter_optimize_images( $markup ); |
|
2581 | ||
2582 | // Expecting $markup since replacement should not happen. |
|
2583 | $this->assertEquals( $markup, $actual ); |
|
2584 | } |
|
2585 | ||
2586 | /** |
|
2587 | * Test image optimization in autoptimizeImages.php. |
|
@@ 2779-2796 (lines=18) @@ | ||
2776 | /** |
|
2777 | * Test preloading of resources (e.g. fonts). |
|
2778 | */ |
|
2779 | public function test_preload() |
|
2780 | { |
|
2781 | $opts = autoptimizeExtra::fetch_options(); |
|
2782 | $opts['autoptimize_extra_text_field_7'] = 'https://whatever.com/fonts/openfuttta.woff2, https://whatever.com/css/openfuttta.css'; |
|
2783 | ||
2784 | $markup = <<<MARKUP |
|
2785 | <html><link rel="stylesheet" href="xyz.css"> |
|
2786 | MARKUP; |
|
2787 | ||
2788 | $expected = <<<MARKUP |
|
2789 | <html><link rel="preload" href="https://whatever.com/fonts/openfuttta.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="https://whatever.com/css/openfuttta.css" as="style"><link rel="stylesheet" href="xyz.css"> |
|
2790 | MARKUP; |
|
2791 | ||
2792 | $instance = autoptimizeExtra::instance(); |
|
2793 | $instance->set_options( $opts ); |
|
2794 | $actual = $instance->filter_preload( $markup ); |
|
2795 | $this->assertEquals( $expected, $actual ); |
|
2796 | } |
|
2797 | ||
2798 | /** |
|
2799 | * Test preloading of resources (e.g. fonts). |
|
@@ 2801-2818 (lines=18) @@ | ||
2798 | /** |
|
2799 | * Test preloading of resources (e.g. fonts). |
|
2800 | */ |
|
2801 | public function test_preload_withqs() |
|
2802 | { |
|
2803 | $opts = autoptimizeExtra::fetch_options(); |
|
2804 | $opts['autoptimize_extra_text_field_7'] = 'https://whatever.com/fonts/openfuttta.woff2?123#abc, https://whatever.com/css/openfuttta.css?v=124'; |
|
2805 | ||
2806 | $markup = <<<MARKUP |
|
2807 | <html><link rel="stylesheet" href="xyz.css"> |
|
2808 | MARKUP; |
|
2809 | ||
2810 | $expected = <<<MARKUP |
|
2811 | <html><link rel="preload" href="https://whatever.com/fonts/openfuttta.woff2?123#abc" as="font" type="font/woff2" crossorigin><link rel="preload" href="https://whatever.com/css/openfuttta.css?v=124" as="style"><link rel="stylesheet" href="xyz.css"> |
|
2812 | MARKUP; |
|
2813 | ||
2814 | $instance = autoptimizeExtra::instance(); |
|
2815 | $instance->set_options( $opts ); |
|
2816 | $actual = $instance->filter_preload( $markup ); |
|
2817 | $this->assertEquals( $expected, $actual ); |
|
2818 | } |
|
2819 | ||
2820 | /** |
|
2821 | * Test aggregating Google Fonts. |