Changeset 44941 for trunk/tests/phpunit/tests/post/getTheExcerpt.php
- Timestamp:
- 03/20/2019 03:48:46 PM (7 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/post/getTheExcerpt.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/post/getTheExcerpt.php
r42343 r44941 58 58 $this->assertSame( 'Bar', get_the_excerpt( $post_id ) ); 59 59 } 60 61 /** 62 * @ticket 42814 63 */ 64 public function test_should_fall_back_on_post_content_if_excerpt_is_empty_and_post_is_inferred_from_context() { 65 $post_id = self::factory()->post->create( 66 array( 67 'post_content' => 'Foo', 68 'post_excerpt' => '', 69 ) 70 ); 71 72 $q = new WP_Query( 73 array( 74 'p' => $post_id, 75 ) 76 ); 77 78 while ( $q->have_posts() ) { 79 $q->the_post(); 80 $found = get_the_excerpt(); 81 } 82 83 $this->assertSame( 'Foo', $found ); 84 } 85 86 /** 87 * @ticket 42814 88 */ 89 public function test_should_fall_back_on_post_content_if_excerpt_is_empty_and_post_is_provided() { 90 $GLOBALS['post'] = self::factory()->post->create_and_get( 91 array( 92 'post_content' => 'Foo', 93 'post_excerpt' => '', 94 ) 95 ); 96 $this->assertSame( 'Foo', get_the_excerpt( $GLOBALS['post'] ) ); 97 } 98 99 /** 100 * @ticket 42814 101 */ 102 public function test_should_respect_post_parameter_in_the_loop() { 103 $p1 = self::factory()->post->create_and_get( array( 'post_excerpt' => 'Foo' ) ); 104 $p2 = self::factory()->post->create_and_get( array( 'post_excerpt' => 'Bar' ) ); 105 $q = new WP_Query( 106 array( 107 'p' => $p1->ID, 108 ) 109 ); 110 111 while ( $q->have_posts() ) { 112 $q->the_post(); 113 $found = get_the_excerpt( $p2 ); 114 } 115 116 $this->assertSame( 'Bar', $found ); 117 } 118 119 /** 120 * @ticket 42814 121 */ 122 public function test_should_respect_post_parameter_in_the_loop_when_falling_back_on_post_content() { 123 $p1 = self::factory()->post->create_and_get( 124 array( 125 'post_content' => 'Foo', 126 'post_excerpt' => '', 127 ) 128 ); 129 $p2 = self::factory()->post->create_and_get( 130 array( 131 'post_content' => 'Bar', 132 'post_excerpt' => '', 133 ) 134 ); 135 $q = new WP_Query( 136 array( 137 'p' => $p1->ID, 138 ) 139 ); 140 141 while ( $q->have_posts() ) { 142 $q->the_post(); 143 $found = get_the_excerpt( $p2 ); 144 } 145 146 $this->assertSame( 'Bar', $found ); 147 } 60 148 }
Note: See TracChangeset
for help on using the changeset viewer.