-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1317 from WordPress/update/ob-handling
Ensure the entire template is passed to the output buffer callback for Optimization Detective to process
- Loading branch information
Showing
6 changed files
with
179 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...ins/optimization-detective/tests/test-cases/json-response-without-proper-content-type.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
return array( | ||
'set_up' => static function (): void { | ||
/* | ||
* This is intentionally not 'application/json'. This is to test whether od_optimize_template_output_buffer() | ||
* is checking whether the output starts with '<' (after whitespace is trimmed). | ||
*/ | ||
ini_set( 'default_mimetype', 'text/html' ); // phpcs:ignore WordPress.PHP.IniSet.Risky | ||
}, | ||
'buffer' => ' {"doc": "<html lang="en"><body><img src="https://www.example.com/logo.jpg" alt="Example Blog Logo" /></body></html>"}', | ||
'expected' => ' {"doc": "<html lang="en"><body><img src="https://www.example.com/logo.jpg" alt="Example Blog Logo" /></body></html>"}', | ||
); |
8 changes: 8 additions & 0 deletions
8
plugins/optimization-detective/tests/test-cases/json-response.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
return array( | ||
'set_up' => static function (): void { | ||
ini_set( 'default_mimetype', 'application/json' ); // phpcs:ignore WordPress.PHP.IniSet.Risky | ||
}, | ||
'buffer' => ' {"doc": "<html lang="en"><body><img src="https://www.example.com/logo.jpg" alt="Example Blog Logo" /></body></html>"}', | ||
'expected' => ' {"doc": "<html lang="en"><body><img src="https://www.example.com/logo.jpg" alt="Example Blog Logo" /></body></html>"}', | ||
); |
34 changes: 34 additions & 0 deletions
34
plugins/optimization-detective/tests/test-cases/rss-response-without-proper-content-type.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
return array( | ||
'set_up' => static function (): void { | ||
// This is intentionally not application/rss+xml as it is testing whether the first tag is HTML. | ||
ini_set( 'default_mimetype', 'text/html' ); // phpcs:ignore WordPress.PHP.IniSet.Risky | ||
}, | ||
// Also omitting the XML processing instruction. | ||
'buffer' => ' | ||
<rss version="2.0"> | ||
<channel> | ||
<title>Example Blog</title> | ||
<link>https://www.example.com</link> | ||
<description> | ||
<img src="https://www.example.com/logo.jpg" alt="Example Blog Logo" /> | ||
A blog about technology, design, and culture. | ||
</description> | ||
<language>en-us</language> | ||
</channel> | ||
</rss> | ||
', | ||
'expected' => ' | ||
<rss version="2.0"> | ||
<channel> | ||
<title>Example Blog</title> | ||
<link>https://www.example.com</link> | ||
<description> | ||
<img src="https://www.example.com/logo.jpg" alt="Example Blog Logo" /> | ||
A blog about technology, design, and culture. | ||
</description> | ||
<language>en-us</language> | ||
</channel> | ||
</rss> | ||
', | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters