Changeset 7783
- Timestamp:
- 10/04/2026 07:57:23 AM (5 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/topics/template/topic.php
r7669 r7783 11 11 /** 12 12 * @covers ::bbp_show_lead_topic 13 * @todo Implement test_bbp_show_lead_topic().14 13 */ 15 14 public function test_bbp_show_lead_topic() { 16 // Remove the following lines when you implement this test. 17 $this->markTestIncomplete( 18 'This test has not been implemented yet.' 19 ); 15 $this->assertFalse( bbp_show_lead_topic() ); 16 $this->assertTrue( bbp_show_lead_topic( true ) ); 17 $this->assertFalse( bbp_show_lead_topic( 0 ) ); 20 18 } 21 19 … … 39 37 /** 40 38 * @covers ::bbp_get_topic 41 * @todo Implement test_bbp_get_topic().42 39 */ 43 40 public function test_bbp_get_topic() { 44 // Remove the following lines when you implement this test. 45 $this->markTestIncomplete( 46 'This test has not been implemented yet.' 47 ); 41 $topic_id = $this->factory->topic->create(); 42 $forum_id = $this->factory->forum->create(); 43 44 $this->assertSame( $topic_id, bbp_get_topic( $topic_id )->ID ); 45 $this->assertSame( $topic_id, bbp_get_topic( get_post( $topic_id ) )->ID ); 46 $this->assertSame( $topic_id, bbp_get_topic( $topic_id, ARRAY_A )['ID'] ); 47 $this->assertNull( bbp_get_topic( $forum_id ) ); 48 48 } 49 49 … … 189 189 * @covers ::bbp_topic_archive_title 190 190 * @covers ::bbp_get_topic_archive_title 191 * @todo Implement test_bbp_get_topic_archive_title().192 191 */ 193 192 public function test_bbp_get_topic_archive_title() { 194 // Remove the following lines when you implement this test.195 $this-> markTestIncomplete(196 'This test has not been implemented yet.'197 );193 $this->assertSame( 'Topics', bbp_get_topic_archive_title() ); 194 $this->assertSame( 'Custom archive', bbp_get_topic_archive_title( 'Custom archive' ) ); 195 $this->expectOutputString( 'Custom archive' ); 196 bbp_topic_archive_title( 'Custom archive' ); 198 197 } 199 198 … … 319 318 * @covers ::bbp_topic_pagination 320 319 * @covers ::bbp_get_topic_pagination 321 * @todo Implement test_bbp_get_topic_pagination().322 320 */ 323 321 public function test_bbp_get_topic_pagination() { 324 // Remove the following lines when you implement this test. 325 $this->markTestIncomplete( 326 'This test has not been implemented yet.' 327 ); 322 $topic_id = $this->factory->topic->create(); 323 $this->factory->reply->create_many( 2, array( 'post_parent' => $topic_id ) ); 324 update_option( '_bbp_replies_per_page', 1 ); 325 $args = array( 'topic_id' => $topic_id ); 326 $pagination = bbp_get_topic_pagination( $args ); 327 328 $this->assertStringContainsString( 'bbp-topic-pagination', $pagination ); 329 $this->assertStringContainsString( 'paged=', $pagination ); 330 $this->expectOutputString( $pagination ); 331 bbp_topic_pagination( $args ); 328 332 } 329 333 … … 365 369 * @covers ::bbp_topic_class 366 370 * @covers ::bbp_get_topic_class 367 * @todo Implement test_bbp_get_topic_class().368 371 */ 369 372 public function test_bbp_get_topic_class() { 370 // Remove the following lines when you implement this test. 371 $this->markTestIncomplete( 372 'This test has not been implemented yet.' 373 ); 373 $forum_id = $this->factory->forum->create(); 374 $topic_id = $this->factory->topic->create( array( 'post_parent' => $forum_id ) ); 375 $classes = bbp_get_topic_class( $topic_id, array( 'extra-topic-class' ) ); 376 377 $this->assertStringContainsString( 'bbp-parent-forum-' . $forum_id, $classes ); 378 $this->assertStringContainsString( 'extra-topic-class', $classes ); 379 bbp_stick_topic( $topic_id ); 380 $classes = bbp_get_topic_class( $topic_id, array( 'extra-topic-class' ) ); 381 $this->assertStringContainsString( ' sticky', $classes ); 382 $this->expectOutputString( $classes ); 383 bbp_topic_class( $topic_id, array( 'extra-topic-class' ) ); 374 384 } 375 385 … … 377 387 * @covers ::bbp_forum_pagination_count 378 388 * @covers ::bbp_get_forum_pagination_count 379 * @todo Implement test_bbp_get_forum_pagination_count().380 389 */ 381 390 public function test_bbp_get_forum_pagination_count() { 382 // Remove the following lines when you implement this test. 383 $this->markTestIncomplete( 384 'This test has not been implemented yet.' 385 ); 391 $forum_id = $this->factory->forum->create(); 392 $this->factory->topic->create_many( 2, array( 'post_parent' => $forum_id ) ); 393 bbp_has_topics( array( 'post_parent' => $forum_id, 'posts_per_page' => 1 ) ); 394 $count = bbp_get_forum_pagination_count(); 395 396 $this->assertStringContainsString( 'Viewing', $count ); 397 $this->assertStringContainsString( '2 total', $count ); 398 $this->expectOutputString( $count ); 399 bbp_forum_pagination_count(); 386 400 } 387 401 388 402 /** 389 403 * @covers ::bbp_topic_notices 390 * @todo Implement test_bbp_topic_notices().391 404 */ 392 405 public function test_bbp_topic_notices() { 393 // Remove the following lines when you implement this test. 394 $this->markTestIncomplete( 395 'This test has not been implemented yet.' 396 ); 406 $topic_id = $this->factory->topic->create(); 407 bbp_unapprove_topic( $topic_id ); 408 $previous_topic_id = bbpress()->current_topic_id; 409 bbpress()->current_topic_id = $topic_id; 410 add_filter( 'bbp_is_single_topic', '__return_true' ); 411 try { 412 bbp_topic_notices(); 413 $this->assertSame( 'This topic is pending moderation.', bbpress()->errors->get_error_message( 'topic_notice' ) ); 414 } finally { 415 bbpress()->errors->remove( 'topic_notice' ); 416 remove_filter( 'bbp_is_single_topic', '__return_true' ); 417 bbpress()->current_topic_id = $previous_topic_id; 418 } 397 419 } 398 420 399 421 /** 400 422 * @covers ::bbp_topic_type_select 401 * @todo Implement test_bbp_topic_type_select().402 423 */ 403 424 public function test_bbp_topic_type_select() { 404 // Remove the following lines when you implement this test. 405 $this->markTestIncomplete( 406 'This test has not been implemented yet.' 407 ); 425 $topic_id = $this->factory->topic->create(); 426 $args = array( 'topic_id' => $topic_id ); 427 $dropdown = bbp_get_form_topic_type_dropdown( $args ); 428 429 $this->assertStringContainsString( 'bbp_stick_topic', $dropdown ); 430 $this->assertStringContainsString( 'value="unstick"', $dropdown ); 431 $this->expectOutputString( $dropdown ); 432 bbp_topic_type_select( $args ); 408 433 } 409 434 … … 411 436 * @covers ::bbp_single_topic_description 412 437 * @covers ::bbp_get_single_topic_description 413 * @todo Implement test_bbp_get_single_topic_description().414 438 */ 415 439 public function test_bbp_get_single_topic_description() { 416 // Remove the following lines when you implement this test. 417 $this->markTestIncomplete( 418 'This test has not been implemented yet.' 419 ); 440 $topic_id = $this->factory->topic->create(); 441 $args = array( 'topic_id' => $topic_id, 'before' => '<p>', 'after' => '</p>' ); 442 $description = bbp_get_single_topic_description( $args ); 443 444 $this->assertStringStartsWith( '<p>', $description ); 445 $this->assertStringEndsWith( '</p>', $description ); 446 $this->assertStringContainsString( 'This topic', $description ); 447 $this->expectOutputString( $description ); 448 bbp_single_topic_description( $args ); 420 449 } 421 450 422 451 /** 423 452 * @covers ::bbp_topic_row_actions 424 * @todo Implement test_bbp_topic_row_actions().425 453 */ 426 454 public function test_bbp_topic_row_actions() { 427 // Remove the following lines when you implement this test. 428 $this->markTestIncomplete( 429 'This test has not been implemented yet.' 430 ); 455 $called = 0; 456 $callback = function() use ( &$called ) { 457 ++$called; 458 }; 459 add_action( 'bbp_topic_row_actions', $callback ); 460 try { 461 bbp_topic_row_actions(); 462 $this->assertSame( 1, $called ); 463 } finally { 464 remove_action( 'bbp_topic_row_actions', $callback ); 465 } 431 466 } 432 467 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)