Skip to content

Commit dc44b89

Browse files
Test: Verify that default excerpt strips all HTML tags
1 parent 180a364 commit dc44b89

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/phpunit/tests/formatting/wpTrimExcerpt.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,4 +223,21 @@ public function test_wp_trim_excerpt_does_not_restore_do_blocks_if_previously_un
223223
// Assert that the filter callback was not restored after running 'the_content'.
224224
$this->assertFalse( has_filter( 'the_content', 'do_blocks' ) );
225225
}
226+
227+
/**
228+
* Tests that by default all HTML is stripped from the excerpt.
229+
*
230+
* @ticket 12084
231+
*/
232+
public function test_excerpt_allowed_tags_default_strips_all_html() {
233+
$post = self::factory()->post->create(
234+
array(
235+
'post_content' => '<p>Hello <strong>world</strong>.</p>',
236+
)
237+
);
238+
239+
$excerpt = wp_trim_excerpt( '', $post );
240+
241+
$this->assertStringNotContainsString( '<', $excerpt, 'Default excerpt should contain no HTML tags.' );
242+
}
226243
}

0 commit comments

Comments
 (0)