wordpress-develop/tests/phpunit/tests/formatting/WpTrimExcerpt.php
Boone Gorges fd4231c2a1 Use correct notation for global functions in @covers test annotations.
Props sgrant.
Fixes #30769.

git-svn-id: https://develop.svn.wordpress.org/trunk@30976 602fd350-edb4-49c9-b593-d223f7449a82
2014-12-19 15:20:41 +00:00

58 lines
1.3 KiB
PHP

<?php
/**
* @group formatting
* @covers ::wp_trim_excerpt
*/
class Tests_Formatting_WpTrimExcerpt extends WP_UnitTestCase {
/**
* @ticket 25349
*/
public function test_secondary_loop_respect_more() {
$post1 = $this->factory->post->create( array(
'post_content' => 'Post 1 Page 1<!--more-->Post 1 Page 2',
) );
$post2 = $this->factory->post->create( array(
'post_content' => 'Post 2 Page 1<!--more-->Post 2 Page 2',
) );
$this->go_to( '/?p=' . $post1 );
setup_postdata( get_post( $post1 ) );
$q = new WP_Query( array(
'post__in' => array( $post2 ),
) );
if ( $q->have_posts() ) {
while ( $q->have_posts() ) {
$q->the_post();
$this->assertSame( 'Post 2 Page 1', wp_trim_excerpt() );
}
}
}
/**
* @ticket 25349
*/
public function test_secondary_loop_respect_nextpage() {
$post1 = $this->factory->post->create( array(
'post_content' => 'Post 1 Page 1<!--nextpage-->Post 1 Page 2',
) );
$post2 = $this->factory->post->create( array(
'post_content' => 'Post 2 Page 1<!--nextpage-->Post 2 Page 2',
) );
$this->go_to( '/?p=' . $post1 );
setup_postdata( get_post( $post1 ) );
$q = new WP_Query( array(
'post__in' => array( $post2 ),
) );
if ( $q->have_posts() ) {
while ( $q->have_posts() ) {
$q->the_post();
$this->assertSame( 'Post 2 Page 1', wp_trim_excerpt() );
}
}
}
}