post_content = new PostContentManager();
}
function testFilterContentRetainsStructuralTags() {
$html = '
some paragraph text
';
expect($this->post_content->filterContent($html))->equals(
'some paragraph text
'
);
$html = 'spanning';
expect($this->post_content->filterContent($html))->equals(
'' . $html . '
'
);
$html = 'do not strip this
';
expect($this->post_content->filterContent($html))->equals(
'do not strip this
'
);
$html = '';
expect($this->post_content->filterContent($html))->equals(
"\n- First item
\n- Second item
\n
"
);
$html = '- First item
- Second item
';
expect($this->post_content->filterContent($html))->equals(
"\n- First item
\n- Second item
\n
"
);
}
function testFilterContentRetainsHeadings() {
$html = 'heading 1
';
expect($this->post_content->filterContent($html))->equals($html);
$html = 'heading 2
';
expect($this->post_content->filterContent($html))->equals($html);
$html = 'heading 3
';
expect($this->post_content->filterContent($html))->equals($html);
}
function testFilterContentRetainsTextStyling() {
$text_tags = array(
'emphasized>',
'bold',
'strong',
'italic',
'Text
new line'
);
foreach($text_tags as $html) {
expect($this->post_content->filterContent($html))->equals(
'' . $html . '
'
);
}
}
function testFilterContentRetainsImagesAndLinks() {
$html = '
';
expect($this->post_content->filterContent($html))->equals(
'
'
);
$html = 'some link';
expect($this->post_content->filterContent($html))->equals(
'' . $html . '
'
);
}
function testFilterContentStripsUndesirableTags() {
$undesirable_tags = array(
'',
'',
'',
'',
'
',
'',
'',
'',
'
',
' | ',
);
foreach($undesirable_tags as $html) {
expect($this->post_content->filterContent($html))->equals('');
}
}
function testItAppliesCustomMaxExcerptLenghViaHook() {
$post_content_manager = new PostContentManager();
$post = (object)array(
'post_content' => 'one two three four five six
'
);
$excerpt = $post_content_manager->getContent($post, 'excerpt');
expect($excerpt)->equals('one two three four five six');
Hooks::addFilter(
'mailpoet_newsletter_post_excerpt_length',
function() {
return 2;
}
);
$post_content_manager = new PostContentManager();
$excerpt = $post_content_manager->getContent($post, 'excerpt');
expect($excerpt)->equals('one two …');
}
function _after() {
WPHooksHelper::releaseAllHooks();
}
}