Code Duplication    Length = 17-18 lines in 2 locations

tests/test-ao.php 2 locations

@@ 2522-2538 (lines=17) @@
2519
     *
2520
     * Exception case: image served by .php, should not be proxied.
2521
     */
2522
    public function test_imgopt_php()
2523
    {
2524
        $opts                                        = autoptimizeImages::fetch_options();
2525
        $opts['autoptimize_imgopt_checkbox_field_1'] = '1';
2526
        $opts['autoptimize_imgopt_checkbox_field_3'] = '0';
2527
2528
        $markup = <<<MARKUP
2529
<img src='/wp-content/plugins/imageplugin/image.php?id=16' width='400' height='200'>
2530
MARKUP;
2531
2532
        $instance = autoptimizeImages::instance();
2533
        $instance->set_options( $opts );
2534
        $actual = $instance->filter_optimize_images( $markup );
2535
2536
        // Expecting $markup since replacement should not happen.
2537
        $this->assertEquals( $markup, $actual );
2538
    }
2539
2540
    /**
2541
     * Test image optimization in autoptimizeImages.php.
@@ 2733-2750 (lines=18) @@
2730
    /**
2731
     * Test preloading of resources (e.g. fonts).
2732
     */
2733
    public function test_preload()
2734
    {
2735
        $opts                                   = autoptimizeExtra::fetch_options();
2736
        $opts['autoptimize_extra_text_field_7'] = 'https://whatever.com/fonts/openfuttta.woff2, https://whatever.com/css/openfuttta.css';
2737
2738
        $markup = <<<MARKUP
2739
<html><link rel="stylesheet" href="xyz.css">
2740
MARKUP;
2741
2742
        $expected = <<<MARKUP
2743
<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">
2744
MARKUP;
2745
2746
        $instance = autoptimizeExtra::instance();
2747
        $instance->set_options( $opts );
2748
        $actual = $instance->filter_preload( $markup );
2749
        $this->assertEquals( $expected, $actual );
2750
    }
2751
2752
    /**
2753
     * Test network vs site settings: network only.