post_content = new PostContentManager( $this->make(WooCommerceHelper::class, ['isWooCommerceActive' => false]) ); } public function testFilterContentRetainsStructuralTags() { $html = '
some paragraph text
'; expect($this->post_content->filterContent($html, 'full'))->equals( 'some paragraph text
' ); $html = 'spanning'; expect($this->post_content->filterContent($html, 'full'))->equals( '' . $html . '
' ); $html = 'do not strip this'; expect($this->post_content->filterContent($html, 'full'))->equals( '
' ); $html = 'do not strip this
heading 1
'); $html = 'heading 2
'); $html = 'heading 3
'); } public function testFilterContentRetainsTextStyling() { $text_tags = [ 'emphasized>', 'bold', 'strong', 'italic', 'Text' . $html . '
' ); } } public function testFilterContentRetainsImagesAndLinks() { $html = '' . $html . '
' ); } public function testFilterContentStripsUndesirableTags() { $undesirable_tags = [ '', '', '', '', 'one two three four five six
', ]; $excerpt = $post_content_manager->getContent($post, 'excerpt'); expect($excerpt)->equals('one two three four five six'); (new WPFunctions)->addFilter( 'mailpoet_newsletter_post_excerpt_length', function() { return 2; } ); $post_content_manager = new PostContentManager( $this->make(WooCommerceHelper::class, ['isWooCommerceActive' => false]) ); $excerpt = $post_content_manager->getContent($post, 'excerpt'); expect($excerpt)->equals('one two …'); } public function testItStripsShortcodesWhenGettingPostContent() { // shortcodes are stripped in excerpt $post = (object)[ 'post_excerpt' => '[shortcode]some text in excerpt[/shortcode]', ]; expect($this->post_content->getContent($post, 'excerpt'))->equals('some text in excerpt'); // shortcodes are stripped in post content when excerpt doesn't exist $post = (object)[ 'post_content' => '[shortcode]some text in content[/shortcode]', ]; expect($this->post_content->getContent($post, 'excerpt'))->equals('some text in content'); // shortcodes are stripped in post content $post = (object)[ 'post_content' => '[shortcode]some text in content[/shortcode]', ]; expect($this->post_content->getContent($post, ''))->equals('some text in content'); } public function testItRemovesImageCaptionsFromClassicEditorPosts() { $post = (object)[ 'post_content' => 'Text [caption id="attachment_23" align="alignnone" width="300"]Text
Text
Text
EOT; $post = (object)[ 'post_content' => $content, ]; expect($this->post_content->getContent($post, 'excerpt'))->equals('Text Text Text'); } }