Changeset 55850 for trunk/tests/phpunit/tests/formatting/wpTrimExcerpt.php
- Timestamp:
- 05/23/2023 06:23:59 PM (22 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/formatting/wpTrimExcerpt.php
r53562 r55850 93 93 $this->assertSame( 'Post content', wp_trim_excerpt( false, $post ) ); 94 94 } 95 96 /** 97 * Tests that `wp_trim_excerpt()` unhooks `wp_filter_content_tags()` from 'the_content' filter. 98 * 99 * @ticket 56588 100 */ 101 public function test_wp_trim_excerpt_unhooks_wp_filter_content_tags() { 102 $post = self::factory()->post->create(); 103 104 /* 105 * Record that during 'the_content' filter run by wp_trim_excerpt() the 106 * wp_filter_content_tags() callback is not used. 107 */ 108 $has_filter = true; 109 add_filter( 110 'the_content', 111 static function( $content ) use ( &$has_filter ) { 112 $has_filter = has_filter( 'the_content', 'wp_filter_content_tags' ); 113 return $content; 114 } 115 ); 116 117 wp_trim_excerpt( '', $post ); 118 119 $this->assertFalse( $has_filter, 'wp_filter_content_tags() was not unhooked in wp_trim_excerpt()' ); 120 } 121 122 /** 123 * Tests that `wp_trim_excerpt()` doesn't permanently unhook `wp_filter_content_tags()` from 'the_content' filter. 124 * 125 * @ticket 56588 126 */ 127 public function test_wp_trim_excerpt_should_not_permanently_unhook_wp_filter_content_tags() { 128 $post = self::factory()->post->create(); 129 130 wp_trim_excerpt( '', $post ); 131 132 $this->assertSame( 10, has_filter( 'the_content', 'wp_filter_content_tags' ), 'wp_filter_content_tags() was not restored in wp_trim_excerpt()' ); 133 } 134 135 /** 136 * Tests that `wp_trim_excerpt()` doesn't restore `wp_filter_content_tags()` if it was previously unhooked. 137 * 138 * @ticket 56588 139 */ 140 public function test_wp_trim_excerpt_does_not_restore_wp_filter_content_tags_if_previously_unhooked() { 141 $post = self::factory()->post->create(); 142 143 // Remove wp_filter_content_tags() from 'the_content' filter generally. 144 remove_filter( 'the_content', 'wp_filter_content_tags' ); 145 146 wp_trim_excerpt( '', $post ); 147 148 // Assert that the filter callback was not restored after running 'the_content'. 149 $this->assertFalse( has_filter( 'the_content', 'wp_filter_content_tags' ) ); 150 } 95 151 }
Note: See TracChangeset
for help on using the changeset viewer.