/** * @see HTTPS_Resource_Proxy::filter_loader_src() * @see HTTPS_Resource_Proxy::filter_script_loader_src() * @see HTTPS_Resource_Proxy::filter_style_loader_src() */ function test_filter_loader_src() { $instance = new HTTPS_Resource_Proxy($this->plugin); add_filter('https_resource_proxy_filtering_enabled', '__return_true'); $instance->add_proxy_filtering(); $src = 'https://example.org/main.css?ver=1'; $this->assertEquals($src, $instance->filter_loader_src($src)); $src = 'http://example.org/main.css?ver=2'; $parsed_src = parse_url($src); $filtered_src = $instance->filter_loader_src($src); $this->assertNotEquals($src, $filtered_src); $this->assertNotEmpty(preg_match('#' . $instance->rewrite_regex . '#', $filtered_src, $matches)); $this->assertNotEmpty($matches['nonce']); $this->assertNotEmpty($matches['host']); $this->assertNotEmpty($matches['path']); $this->assertEquals(wp_create_nonce(HTTPS_Resource_Proxy::MODULE_SLUG), $matches['nonce']); $this->assertEquals($parsed_src['host'], $matches['host']); $this->assertEquals('/main.css', $parsed_src['path']); $this->assertStringEndsWith('?ver=2', $filtered_src); $src = 'http://example.org/main.css?ver=2'; $this->assertEquals($instance->filter_loader_src($src), $instance->filter_style_loader_src($src)); $src = 'http://example.org/main.js?ver=2'; $this->assertEquals($instance->filter_loader_src($src), $instance->filter_script_loader_src($src)); }