Changeset 45261 for trunk/tests/phpunit/tests/post/output.php
- Timestamp:
- 04/24/2019 05:40:01 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/post/output.php
r44569 r45261 176 176 kses_remove_filters(); 177 177 } 178 179 /** 180 * Ensure the_content handles a More block on a singular page. 181 * 182 * @ticket 46471 183 * 184 * @group blocks 185 */ 186 public function test_the_content_should_handle_more_block_on_singular() { 187 $post_content = <<<EOF 188 <!-- wp:paragraph --> 189 <p>Teaser part.</p> 190 <!-- /wp:paragraph --> 191 192 <!-- wp:more {"customText":"Read More"} --> 193 <!--more Read More--> 194 <!-- /wp:more --> 195 196 <!-- wp:paragraph --> 197 <p>Second block.</p> 198 <!-- /wp:paragraph --> 199 EOF; 200 201 $post_id = self::factory()->post->create( compact( 'post_content' ) ); 202 203 $expected_without_teaser = <<<EOF 204 <span id="more-{$post_id}"></span> 205 <p>Second block.</p> 206 EOF; 207 208 $expected_with_teaser = <<<EOF 209 <p>Teaser part.</p> 210 <span id="more-{$post_id}"></span> 211 <p>Second block.</p> 212 EOF; 213 214 $this->go_to( get_permalink( $post_id ) ); 215 $this->assertTrue( is_singular() ); 216 $this->assertTrue( have_posts() ); 217 $this->assertNull( the_post() ); 218 219 // Without the teaser. 220 $actual = get_echo( 'the_content', array( null, true ) ); 221 $this->assertSame( strip_ws( $expected_without_teaser ), strip_ws( $actual ) ); 222 223 // With the teaser. 224 $actual = get_echo( 'the_content', array( null, false ) ); 225 $this->assertSame( strip_ws( $expected_with_teaser ), strip_ws( $actual ) ); 226 } 227 228 /** 229 * Ensure the_content handles a More block when using the noteaser text tag on a singular page. 230 * 231 * @ticket 46471 232 * 233 * @group blocks 234 */ 235 public function test_the_content_should_handle_more_block_when_noteaser_on_singular() { 236 $post_content = <<<EOF 237 <!-- wp:paragraph --> 238 <p>Teaser part.</p> 239 <!-- /wp:paragraph --> 240 241 <!-- wp:more --> 242 <!--more--> 243 <!--noteaser--> 244 <!-- /wp:more --> 245 246 <!-- wp:paragraph --> 247 <p>Second block.</p> 248 <!-- /wp:paragraph --> 249 EOF; 250 251 $post_id = self::factory()->post->create( compact( 'post_content' ) ); 252 253 $expected = <<<EOF 254 <span id="more-{$post_id}"></span> 255 <!--noteaser--> 256 <p>Second block.</p> 257 EOF; 258 259 $this->go_to( get_permalink( $post_id ) ); 260 $this->assertTrue( is_singular() ); 261 $this->assertTrue( have_posts() ); 262 $this->assertNull( the_post() ); 263 264 $actual = get_echo( 'the_content', array( null, true ) ); 265 $this->assertSame( strip_ws( $expected ), strip_ws( $actual ) ); 266 267 $actual = get_echo( 'the_content', array( null, false ) ); 268 $this->assertSame( strip_ws( $expected ), strip_ws( $actual ) ); 269 } 270 271 /** 272 * Ensure the_content displays the teaser part with a read more link 273 * for a More block on a non-singular page. 274 * 275 * @ticket 46471 276 * 277 * @group blocks 278 */ 279 public function test_the_content_should_handle_more_block_when_non_singular() { 280 $post_content = <<<EOF 281 <!-- wp:paragraph --> 282 <p>Teaser part.</p> 283 <!-- /wp:paragraph --> 284 285 <!-- wp:more {"customText":"Read More"} --> 286 <!--more Read More--> 287 <!-- /wp:more --> 288 289 <!-- wp:paragraph --> 290 <p>Second block.</p> 291 <!-- /wp:paragraph --> 292 EOF; 293 294 $post_id = self::factory()->post->create( compact( 'post_content' ) ); 295 296 $expected = <<<EOF 297 <span id="more-{$post_id}"></span> 298 <p>Second block.</p> 299 EOF; 300 301 $this->go_to( home_url() ); 302 $this->assertFalse( is_singular() ); 303 $this->assertTrue( have_posts() ); 304 $this->assertNull( the_post() ); 305 306 foreach ( array( true, false ) as $strip_teaser ) { 307 $actual = get_echo( 'the_content', array( null, $strip_teaser ) ); 308 $this->assertContains( 'Teaser part', $actual ); 309 $this->assertContains( 'Read More</a>', $actual ); 310 $this->assertNotContains( '<!--more-->', $actual ); 311 $this->assertNotContains( 'wp:more', $actual ); 312 $this->assertNotContains( 'wp:paragraph', $actual ); 313 } 314 } 315 316 /** 317 * Ensure the_content displays the teaser part with a read more link for a More block 318 * when using the noteaser text tag on a non-singular page. 319 * 320 * @ticket 46471 321 * 322 * @group blocks 323 */ 324 public function test_the_content_should_handle_more_block_when_noteaser_on_non_singular() { 325 $post_content = <<<EOF 326 <!-- wp:paragraph --> 327 <p>Teaser part.</p> 328 <!-- /wp:paragraph --> 329 330 <!-- wp:more --> 331 <!--more--> 332 <!--noteaser--> 333 <!-- /wp:more --> 334 335 <!-- wp:paragraph --> 336 <p>Second block.</p> 337 <!-- /wp:paragraph --> 338 EOF; 339 340 $post_id = self::factory()->post->create( compact( 'post_content' ) ); 341 342 $this->go_to( home_url() ); 343 $this->assertFalse( is_singular() ); 344 $this->assertTrue( have_posts() ); 345 $this->assertNull( the_post() ); 346 347 foreach ( array( true, false ) as $strip_teaser ) { 348 $actual = get_echo( 'the_content', array( null, $strip_teaser ) ); 349 $this->assertContains( 'Teaser part', $actual ); 350 $this->assertContains( '(more…)</span></a>', $actual ); 351 $this->assertNotContains( '<!--more-->', $actual ); 352 $this->assertNotContains( '<!--noteaser-->', $actual ); // We placed the noteaser tag below the more tag. 353 $this->assertNotContains( 'wp:more', $actual ); 354 $this->assertNotContains( 'wp:paragraph', $actual ); 355 } 356 } 178 357 }
Note: See TracChangeset
for help on using the changeset viewer.