-
Notifications
You must be signed in to change notification settings - Fork 110
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 #1817 from WordPress/update/od-test-coverage
Improve test coverage for Optimization Detective
- Loading branch information
Showing
22 changed files
with
453 additions
and
38 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
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
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
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
11 changes: 11 additions & 0 deletions
11
plugins/optimization-detective/tests/test-cases/preload-link/buffer.html
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,11 @@ | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>...</title> | ||
</head> | ||
<body> | ||
<div id="page"> | ||
<img src="https://example.com/image.jpg" alt="" width="100" height="100"> | ||
</div> | ||
</body> | ||
</html> |
13 changes: 13 additions & 0 deletions
13
plugins/optimization-detective/tests/test-cases/preload-link/expected.html
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
plugins/optimization-detective/tests/test-cases/preload-link/set-up.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,24 @@ | ||
<?php | ||
return static function (): void { | ||
|
||
add_action( | ||
'od_register_tag_visitors', | ||
static function ( OD_Tag_Visitor_Registry $registry ): void { | ||
$registry->register( | ||
'img-preload', | ||
static function ( OD_Tag_Visitor_Context $context ): bool { | ||
if ( 'IMG' === $context->processor->get_tag() ) { | ||
$context->link_collection->add_link( | ||
array( | ||
'rel' => 'preload', | ||
'as' => 'image', | ||
'href' => $context->processor->get_attribute( 'src' ), | ||
) | ||
); | ||
} | ||
return false; | ||
} | ||
); | ||
} | ||
); | ||
}; |
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
Oops, something went wrong.