forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetTheContent.php
More file actions
87 lines (69 loc) · 2.26 KB
/
getTheContent.php
File metadata and controls
87 lines (69 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/**
* @group post
* @group formatting
*/
class Tests_Post_GetTheContent extends WP_UnitTestCase {
/**
* @ticket 42814
*/
public function test_argument_back_compat_more_link_text() {
$text = 'Foo<!--more-->Bar';
$p = self::factory()->post->create( array( 'post_content' => $text ) );
$q = new WP_Query( array( 'p' => $p ) );
while ( $q->have_posts() ) {
$q->the_post();
$found = get_the_content( 'Ping' );
}
$this->assertStringContainsString( '>Ping<', $found );
}
/**
* @ticket 42814
*/
public function test_argument_back_compat_strip_teaser() {
$text = 'Foo<!--more-->Bar';
$p = self::factory()->post->create( array( 'post_content' => $text ) );
$this->go_to( get_permalink( $p ) );
$q = new WP_Query( array( 'p' => $p ) );
while ( $q->have_posts() ) {
$q->the_post();
$found = get_the_content( null, true );
}
$this->assertStringNotContainsString( 'Foo', $found );
}
/**
* @ticket 42814
*/
public function test_content_other_post() {
$text_1 = 'Foo<!--nextpage-->Bar<!--nextpage-->Baz';
$post_1 = self::factory()->post->create_and_get( array( 'post_content' => $text_1 ) );
$text_2 = 'Bing<!--nextpage-->Bang<!--nextpage-->Boom';
$post_2 = self::factory()->post->create_and_get( array( 'post_content' => $text_2 ) );
setup_postdata( $post_1 );
$found = get_the_content( null, true, $post_2 );
$this->assertSame( 'Bing', $found );
}
/**
* @ticket 42814
*/
public function test_should_respect_pagination_of_inner_post() {
$text_1 = 'Foo<!--nextpage-->Bar<!--nextpage-->Baz';
$post_1 = self::factory()->post->create_and_get( array( 'post_content' => $text_1 ) );
$text_2 = 'Bing<!--nextpage-->Bang<!--nextpage-->Boom';
$post_2 = self::factory()->post->create_and_get( array( 'post_content' => $text_2 ) );
$go_to = add_query_arg( 'page', '2', get_permalink( $post_1->ID ) );
$this->go_to( $go_to );
while ( have_posts() ) {
the_post();
$found = get_the_content( '', false, $post_2 );
}
$this->assertSame( 'Bang', $found );
}
/**
* @ticket 47824
*/
public function test_should_fall_back_to_post_global_outside_of_the_loop() {
$GLOBALS['post'] = self::factory()->post->create( array( 'post_content' => 'Foo' ) );
$this->assertSame( 'Foo', get_the_content() );
}
}