Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
07730df
first commit for fetchprionty
pbearne Sep 12, 2022
9b8f5ce
Merge remote-tracking branch 'upstream/trunk' into experiment/fetchpr…
pbearne Sep 12, 2022
412ae47
added basic tests
pbearne Sep 12, 2022
5793388
Update modules/images/fetchpriority/load.php
pbearne Sep 13, 2022
4dcb016
Update modules/images/fetchpriority/load.php
pbearne Sep 13, 2022
ca092d6
Update modules/images/fetchpriority/load.php
pbearne Sep 13, 2022
8939080
code review feedback
pbearne Sep 13, 2022
280f11d
Add CODEOWNERS update for fetchpriority module.
felixarntz Sep 13, 2022
5480988
Use lowercase file name for test class file.
felixarntz Sep 13, 2022
ddc78b8
Fix CODEOWNERS indentation.
felixarntz Sep 13, 2022
1cdf6a4
Update modules/images/fetchpriority/load.php
pbearne Sep 13, 2022
0946219
Update modules/images/fetchpriority/load.php
pbearne Sep 13, 2022
15665fb
Update modules/images/fetchpriority/load.php
pbearne Sep 13, 2022
a573ecc
Update modules/images/fetchpriority/load.php
pbearne Sep 13, 2022
6702525
Update modules/images/fetchpriority/load.php
pbearne Sep 13, 2022
2fbc825
Update modules/images/fetchpriority/load.php
pbearne Sep 13, 2022
7caf166
Update modules/images/fetchpriority/load.php
pbearne Sep 13, 2022
e6826eb
code review feedback
pbearne Sep 13, 2022
6dd14bb
added test for wp_filter_content_tags() function
pbearne Sep 14, 2022
958987e
Update tests/modules/images/fetchpriority/fetchpriority-tests.php
pbearne Sep 22, 2022
28122a2
Update tests/modules/images/fetchpriority/fetchpriority-tests.php
pbearne Sep 22, 2022
55b3b92
added test for wp_filter_content_tags() function
pbearne Sep 28, 2022
1201df6
Merge remote-tracking branch 'origin/experiment/fetchpriority' into e…
pbearne Sep 28, 2022
fb18628
Merge branch 'trunk' into experiment/fetchpriority
pbearne Sep 28, 2022
ec41481
Merge branch 'trunk' into experiment/fetchpriority
adamsilverstein Oct 28, 2022
bf515a2
Improve tests with multiple attachments, in_the_loop true
adamsilverstein Oct 28, 2022
4a4c237
Mock is_main_query
adamsilverstein Oct 28, 2022
8f42c02
Update modules/images/fetchpriority/load.php
adamsilverstein Nov 14, 2022
aa9f635
Update modules/images/fetchpriority/load.php
adamsilverstein Nov 14, 2022
0e3061c
test_fetchpriority… expect exactly one
adamsilverstein Nov 14, 2022
0494e6d
Fetchpriority relies on lazy loading logic
adamsilverstein Nov 14, 2022
ae0eb60
Add test_fetchpriority_img_tag_with_lazyload_disabled
adamsilverstein Nov 14, 2022
a7392d2
Combine tests
adamsilverstein Nov 14, 2022
0a4fe58
Correct assertion typo
adamsilverstein Nov 14, 2022
a709c91
Merge branch 'trunk' into experiment/fetchpriority
felixarntz Nov 22, 2022
66d2a0d
SImplify fetchpriority module description.
felixarntz Nov 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added test for wp_filter_content_tags() function
tests not working
  • Loading branch information
pbearne committed Sep 28, 2022
commit 55b3b921ebb2f27e1dd817f8f5e651bdf4b6b82a
1 change: 1 addition & 0 deletions modules/images/fetchpriority/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
function fetchpriority_img_tag_add_attr( $filtered_image, $context ) {

if ( 'the_content' !== $context && 'the_post_thumbnail' !== $context ) {

return $filtered_image;
}

Expand Down
24 changes: 24 additions & 0 deletions tests/modules/images/fetchpriority/fetchpriority-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,28 @@ public function test_fetchpriority_img_tag_add_attr_based_on_context_and_loading
$img = str_replace( '<img ', '<img loading="lazy" ', $img );
$this->assertStringNotContainsString( 'fetchpriority="high"', fetchpriority_img_tag_add_attr( $img, 'the_content' ) );
}

public function test_fetchpriority_img_tag_add_in_wp_filter_content_tags() {
$img = get_image_tag( self::$attachment_id, '', '', '', 'large' );

$img = '<!-- wp:image {"id":' . self::$attachment_id . ',"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large">' . $img . '</figure>
<!-- /wp:image -->
<!-- wp:paragraph -->
<p>This is an example page. It\'s different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:</p>
<!-- /wp:paragraph -->
<!-- wp:image {"id":' . self::$attachment_id . ',"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large">' . $img . '</figure>
<!-- /wp:image -->
';
$content = wp_filter_content_tags( $img, 'the_content' );
$this->assertStringContainsString( 'fetchpriority="high"', $content );

$spilt = explode( 'fetchpriority', $content );
$this->assertEquals( 2, count( $spilt ) );
}
public function test_get_the_post_thumbnail() {
set_post_thumbnail( self::$post, self::$attachment_id );
$this->assertStringContainsString( 'fetchpriority="high"', get_the_post_thumbnail( self::$post ) );
}
}