Changeset 7762
- Timestamp:
- 10/01/2026 12:18:13 AM (7 weeks ago)
- Location:
- trunk/tests/phpunit/testcases
- Files:
-
- 4 edited
-
admin/tools.php (modified) (1 diff)
-
common/functions.php (modified) (5 diffs)
-
search/functions/search.php (modified) (1 diff)
-
users/template/user.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/admin/tools.php
r7467 r7762 30 30 31 31 /** 32 * @covers ::bbp_admin_repair 33 * @todo Implement test_bbp_admin_repair(). 32 * @covers ::bbp_admin_repair_page 34 33 */ 35 34 public function test_bbp_admin_repair() { 36 // Remove the following lines when you implement this test. 37 $this->markTestIncomplete( 38 'This test has not been implemented yet.' 39 ); 35 $original_get = $_GET; 36 $original_tools = bbp_admin()->tools; 37 $_GET = array( 'page' => 'bbp-repair' ); 38 bbp_register_default_repair_tools(); 39 40 try { 41 ob_start(); 42 bbp_admin_repair_page(); 43 $output = ob_get_clean(); 44 45 $this->assertStringContainsString( 'name="page" value="bbp-repair"', $output ); 46 $this->assertStringContainsString( 'name="checked[]"', $output ); 47 $this->assertStringContainsString( 'name="_wpnonce"', $output ); 48 } finally { 49 $_GET = $original_get; 50 bbp_admin()->tools = $original_tools; 51 } 40 52 } 41 53 42 54 /** 43 55 * @covers ::bbp_admin_repair_handler 44 * @t odo Implement test_bbp_admin_repair_handler().56 * @ticket 3695 45 57 */ 46 58 public function test_bbp_admin_repair_handler() { 47 // Remove the following lines when you implement this test. 48 $this->markTestIncomplete( 49 'This test has not been implemented yet.' 50 ); 59 $original_get = $_GET; 60 $original_method = isset( $_SERVER['REQUEST_METHOD'] ) ? $_SERVER['REQUEST_METHOD'] : null; 61 $_GET = array( 'action' => 'not-run' ); 62 $_SERVER['REQUEST_METHOD'] = 'GET'; 63 64 try { 65 $this->assertNull( bbp_admin_repair_handler() ); 66 } finally { 67 $_GET = $original_get; 68 if ( is_null( $original_method ) ) { 69 unset( $_SERVER['REQUEST_METHOD'] ); 70 } else { 71 $_SERVER['REQUEST_METHOD'] = $original_method; 72 } 73 } 51 74 } 52 75 53 76 /** 54 77 * @covers ::bbp_admin_tools_repair_help 55 * @t odo Implement test_bbp_admin_tools_repair_help().78 * @ticket 3695 56 79 */ 57 80 public function test_bbp_admin_tools_repair_help() { 58 // Remove the following lines when you implement this test. 59 $this->markTestIncomplete( 60 'This test has not been implemented yet.' 61 ); 81 $previous = get_current_screen(); 82 set_current_screen( 'tools_page_bbp-repair' ); 83 84 try { 85 bbp_admin_tools_repair_help(); 86 $tabs = get_current_screen()->get_help_tabs(); 87 $this->assertArrayHasKey( 'repair_forums', $tabs ); 88 $this->assertStringContainsString( 'bbPress: Repair Forums', $tabs['repair_forums']['content'] ); 89 $this->assertStringContainsString( 'bbPress Documentation', get_current_screen()->get_help_sidebar() ); 90 } finally { 91 $GLOBALS['current_screen'] = $previous; 92 } 62 93 } 63 94 64 95 /** 65 96 * @covers ::bbp_admin_tools_reset_help 66 * @t odo Implement test_bbp_admin_tools_reset_help().97 * @ticket 3695 67 98 */ 68 99 public function test_bbp_admin_tools_reset_help() { 69 // Remove the following lines when you implement this test. 70 $this->markTestIncomplete( 71 'This test has not been implemented yet.' 72 ); 100 $previous = get_current_screen(); 101 set_current_screen( 'tools_page_bbp-reset' ); 102 103 try { 104 bbp_admin_tools_reset_help(); 105 $tabs = get_current_screen()->get_help_tabs(); 106 $this->assertArrayHasKey( 'reset_forums', $tabs ); 107 $this->assertStringContainsString( 'bbPress: Reset Forums', $tabs['reset_forums']['content'] ); 108 } finally { 109 $GLOBALS['current_screen'] = $previous; 110 } 73 111 } 74 112 75 113 /** 76 114 * @covers ::bbp_admin_tools_converter_help 77 * @t odo Implement test_bbp_admin_tools_converter_help().115 * @ticket 3695 78 116 */ 79 117 public function test_bbp_admin_tools_converter_help() { 80 // Remove the following lines when you implement this test. 81 $this->markTestIncomplete( 82 'This test has not been implemented yet.' 83 ); 118 $previous = get_current_screen(); 119 set_current_screen( 'tools_page_bbp-converter' ); 120 121 try { 122 bbp_admin_tools_converter_help(); 123 $tabs = get_current_screen()->get_help_tabs(); 124 $this->assertSame( array( 'overview', 'database_settings', 'importer_options' ), array_keys( $tabs ) ); 125 $this->assertStringContainsString( 'bbPress: Import Forums', $tabs['overview']['content'] ); 126 } finally { 127 $GLOBALS['current_screen'] = $previous; 128 } 84 129 } 85 130 86 131 /** 87 132 * @covers ::bbp_admin_tools_feedback 88 * @t odo Implement test_bbp_admin_tools_feedback().133 * @ticket 3695 89 134 */ 90 135 public function test_bbp_admin_tools_feedback() { 91 // Remove the following lines when you implement this test. 92 $this->markTestIncomplete( 93 'This test has not been implemented yet.' 94 ); 136 $notices = bbp_admin()->notices; 137 138 try { 139 bbp_admin_tools_feedback( 'Repair complete', 'success', false ); 140 $this->assertStringContainsString( 'notice success', end( bbp_admin()->notices ) ); 141 $this->assertStringContainsString( '<p>Repair complete</p>', end( bbp_admin()->notices ) ); 142 $this->assertStringNotContainsString( 'is-dismissible', end( bbp_admin()->notices ) ); 143 $this->assertFalse( bbp_admin_tools_feedback( array( 'invalid' ) ) ); 144 } finally { 145 bbp_admin()->notices = $notices; 146 } 95 147 } 96 148 97 149 /** 98 150 * @covers ::bbp_admin_repair_list 99 * @t odo Implement test_bbp_admin_repair_list().151 * @ticket 3695 100 152 */ 101 153 public function test_bbp_admin_repair_list() { 102 // Remove the following lines when you implement this test. 103 $this->markTestIncomplete( 104 'This test has not been implemented yet.' 105 ); 154 $original_get = $_GET; 155 $original_tools = bbp_admin()->tools; 156 $_GET = array( 's' => 'Recount' ); 157 bbp_register_default_repair_tools(); 158 159 try { 160 $list = bbp_admin_repair_list(); 161 $this->assertNotEmpty( $list ); 162 foreach ( $list as $tool ) { 163 $this->assertSame( 'repair', $tool['type'] ); 164 $this->assertStringContainsString( 'recount', strtolower( $tool['title'] ) ); 165 } 166 } finally { 167 $_GET = $original_get; 168 bbp_admin()->tools = $original_tools; 169 } 106 170 } 107 171 -
trunk/tests/phpunit/testcases/common/functions.php
r7713 r7762 15 15 /** 16 16 * @covers ::bbp_number_format 17 * @todo Implement test_bbp_number_format().18 17 */ 19 18 public function test_bbp_number_format() { 20 // Remove the following lines when you implement this test. 21 $this->markTestIncomplete( 22 'This test has not been implemented yet.' 23 ); 19 $this->assertSame( '1,234', bbp_number_format( 1234 ) ); 20 $this->assertSame( '1 234,50', bbp_number_format( 1234.5, 2, ',', ' ' ) ); 21 $this->assertSame( '0', bbp_number_format( 'not a number' ) ); 24 22 } 25 23 26 24 /** 27 25 * @covers ::bbp_number_format_i18n 28 * @todo Implement test_bbp_number_format_i18n().29 26 */ 30 27 public function test_bbp_number_format_i18n() { 31 // Remove the following lines when you implement this test. 32 $this->markTestIncomplete( 33 'This test has not been implemented yet.' 34 ); 28 $this->assertSame( number_format_i18n( 1234.5, 2 ), bbp_number_format_i18n( 1234.5, 2 ) ); 29 $this->assertSame( number_format_i18n( 0 ), bbp_number_format_i18n( 'not a number' ) ); 35 30 } 36 31 37 32 /** 38 33 * @covers ::bbp_convert_date 39 * @todo Implement test_bbp_convert_date().40 34 */ 41 35 public function test_bbp_convert_date() { 42 // Remove the following lines when you implement this test. 43 $this->markTestIncomplete( 44 'This test has not been implemented yet.' 45 ); 36 $this->assertSame( '2020-01-02', bbp_convert_date( '2020-01-02 03:04:05', 'Y-m-d' ) ); 37 $this->assertSame( mysql2date( 'U', '2020-01-02 03:04:05' ), bbp_convert_date( '2020-01-02 03:04:05' ) ); 46 38 } 47 39 … … 562 554 /** 563 555 * @covers ::bbp_format_revision_reason 564 * @todo Implement test_bbp_format_revision_reason().565 556 */ 566 557 public function test_bbp_format_revision_reason() { 567 // Remove the following lines when you implement this test. 568 $this->markTestIncomplete( 569 'This test has not been implemented yet.' 570 ); 558 $this->assertSame( '', bbp_format_revision_reason() ); 559 $this->assertSame( 'Correct typo', bbp_format_revision_reason( ' Correct typo... ' ) ); 560 $this->assertSame( 'Correct typo', bbp_format_revision_reason( 'Correct typo...' ) ); 571 561 } 572 562 573 563 /** 574 564 * @covers ::bbp_get_redirect_to 575 * @todo Implement test_bbp_get_redirect_to().576 565 */ 577 566 public function test_bbp_get_redirect_to() { 578 // Remove the following lines when you implement this test. 579 $this->markTestIncomplete( 580 'This test has not been implemented yet.' 581 ); 567 $old_request = $_REQUEST; 568 try { 569 unset( $_REQUEST['redirect_to'] ); 570 $this->assertSame( '', bbp_get_redirect_to() ); 571 $_REQUEST['redirect_to'] = '/forums/'; 572 $this->assertSame( '/forums/', bbp_get_redirect_to() ); 573 } finally { 574 $_REQUEST = $old_request; 575 } 582 576 } 583 577 584 578 /** 585 579 * @covers ::bbp_add_view_all 586 * @todo Implement test_bbp_add_view_all().587 580 */ 588 581 public function test_bbp_add_view_all() { 589 // Remove the following lines when you implement this test. 590 $this->markTestIncomplete( 591 'This test has not been implemented yet.' 592 ); 582 $url = 'https://example.org/forums/?paged=2'; 583 $this->assertSame( $url, bbp_add_view_all( $url ) ); 584 $this->assertSame( 'https://example.org/forums/?paged=2&view=all', bbp_add_view_all( $url, true ) ); 593 585 } 594 586 595 587 /** 596 588 * @covers ::bbp_remove_view_all 597 * @todo Implement test_bbp_remove_view_all().598 589 */ 599 590 public function test_bbp_remove_view_all() { 600 // Remove the following lines when you implement this test. 601 $this->markTestIncomplete( 602 'This test has not been implemented yet.' 603 ); 591 $this->assertSame( 'https://example.org/forums/?paged=2', bbp_remove_view_all( 'https://example.org/forums/?paged=2&view=all' ) ); 592 $this->assertSame( 'https://example.org/forums/', bbp_remove_view_all( 'https://example.org/forums/' ) ); 604 593 } 605 594 606 595 /** 607 596 * @covers ::bbp_get_view_all 608 * @todo Implement test_bbp_get_view_all().609 597 */ 610 598 public function test_bbp_get_view_all() { 611 // Remove the following lines when you implement this test. 612 $this->markTestIncomplete( 613 'This test has not been implemented yet.' 614 ); 599 $old_get = $_GET; 600 $old_user = get_current_user_id(); 601 try { 602 $_GET['view'] = 'all'; 603 wp_set_current_user( 0 ); 604 $this->assertFalse( bbp_get_view_all() ); 605 $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); 606 bbp_set_user_role( $user_id, bbp_get_keymaster_role() ); 607 wp_set_current_user( $user_id ); 608 $this->assertTrue( current_user_can( 'moderate' ) ); 609 $this->assertTrue( bbp_get_view_all() ); 610 $_GET['view'] = 'single'; 611 $this->assertFalse( bbp_get_view_all() ); 612 } finally { 613 $_GET = $old_get; 614 wp_set_current_user( $old_user ); 615 } 615 616 } 616 617 617 618 /** 618 619 * @covers ::bbp_get_paged 619 * @todo Implement test_bbp_get_paged().620 620 */ 621 621 public function test_bbp_get_paged() { 622 // Remove the following lines when you implement this test. 623 $this->markTestIncomplete( 624 'This test has not been implemented yet.' 625 ); 622 $wp_query = bbp_get_wp_query(); 623 $old_query = $wp_query->query; 624 $old_query_var = get_query_var( 'paged' ); 625 try { 626 unset( $wp_query->query['paged'] ); 627 set_query_var( 'paged', 0 ); 628 $this->assertSame( 1, bbp_get_paged() ); 629 $wp_query->query['paged'] = '3'; 630 $this->assertSame( 3, bbp_get_paged() ); 631 set_query_var( 'paged', '2' ); 632 $this->assertSame( 2, bbp_get_paged() ); 633 } finally { 634 $wp_query->query = $old_query; 635 set_query_var( 'paged', $old_query_var ); 636 } 626 637 } 627 638 628 639 /** 629 640 * @covers ::bbp_fix_post_author 630 * @todo Implement test_bbp_fix_post_author().631 641 */ 632 642 public function test_bbp_fix_post_author() { 633 // Remove the following lines when you implement this test. 634 $this->markTestIncomplete( 635 'This test has not been implemented yet.' 636 ); 643 $author_id = $this->factory->user->create(); 644 $topic_id = $this->factory->topic->create( array( 'post_author' => 0 ) ); 645 $data = array( 'post_type' => bbp_get_topic_post_type(), 'post_author' => $author_id ); 646 $this->assertSame( 0, bbp_fix_post_author( $data, array( 'ID' => $topic_id ) )['post_author'] ); 647 $this->assertSame( $data, bbp_fix_post_author( $data, array() ) ); 648 $authored_topic = $this->factory->topic->create( array( 'post_author' => $author_id ) ); 649 $this->assertSame( $data, bbp_fix_post_author( $data, array( 'ID' => $authored_topic ) ) ); 650 $non_bbp_data = array( 'post_type' => 'post', 'post_author' => $author_id ); 651 $this->assertSame( $non_bbp_data, bbp_fix_post_author( $non_bbp_data, array( 'ID' => $this->factory->post->create() ) ) ); 637 652 } 638 653 … … 781 796 /** 782 797 * @covers ::bbp_filter_anonymous_post_data 783 * @todo Implement test_bbp_filter_anonymous_post_data().784 798 */ 785 799 public function test_bbp_filter_anonymous_post_data() { 786 // Remove the following lines when you implement this test. 787 $this->markTestIncomplete( 788 'This test has not been implemented yet.' 800 $error_messages = bbpress()->errors->get_error_messages(); 801 $result = bbp_filter_anonymous_post_data( array( 802 'bbp_anonymous_name' => 'Forum Visitor', 803 'bbp_anonymous_email' => 'visitor@example.org', 804 'bbp_anonymous_website' => '', 805 ) ); 806 $this->assertSame( 'Forum Visitor', $result['bbp_anonymous_name'] ); 807 $this->assertSame( 'visitor@example.org', $result['bbp_anonymous_email'] ); 808 $this->assertSame( '', $result['bbp_anonymous_website'] ); 809 $this->assertSame( $error_messages, bbpress()->errors->get_error_messages() ); 810 } 811 812 /** 813 * @covers ::bbp_check_for_duplicate 814 */ 815 public function test_bbp_check_for_duplicate() { 816 $author_id = $this->factory->user->create(); 817 $topic_id = $this->factory->topic->create( array( 818 'post_author' => $author_id, 819 'post_content' => 'Duplicate topic text', 820 'post_status' => 'publish', 821 ) ); 822 $post_data = array( 823 'post_author' => $author_id, 824 'post_type' => bbp_get_topic_post_type(), 825 'post_content' => 'Duplicate topic text', 789 826 ); 790 } 791 792 /** 793 * @covers ::bbp_check_for_duplicate 794 * @todo Implement test_bbp_check_for_duplicate(). 795 */ 796 public function test_bbp_check_for_duplicate() { 797 // Remove the following lines when you implement this test. 798 $this->markTestIncomplete( 799 'This test has not been implemented yet.' 800 ); 827 $this->assertFalse( bbp_check_for_duplicate( $post_data ) ); 828 $post_data['post_content'] = 'A different topic'; 829 $this->assertTrue( bbp_check_for_duplicate( $post_data ) ); 830 $this->assertSame( $author_id, (int) get_post_field( 'post_author', $topic_id ) ); 801 831 } 802 832 803 833 /** 804 834 * @covers ::bbp_check_for_flood 805 * @todo Implement test_bbp_check_for_flood().806 835 */ 807 836 public function test_bbp_check_for_flood() { 808 // Remove the following lines when you implement this test. 809 $this->markTestIncomplete( 810 'This test has not been implemented yet.' 811 ); 837 $old_throttle = get_option( '_bbp_throttle_time', null ); 838 $key = '_bbp_' . bbp_current_author_ip() . '_last_posted'; 839 $old_posted = get_transient( $key ); 840 try { 841 update_option( '_bbp_throttle_time', 60 ); 842 set_transient( $key, time() ); 843 $this->assertFalse( bbp_check_for_flood( array( 'bbp_anonymous_email' => 'visitor@example.org' ) ) ); 844 set_transient( $key, time() - 120 ); 845 $this->assertTrue( bbp_check_for_flood( array( 'bbp_anonymous_email' => 'visitor@example.org' ) ) ); 846 } finally { 847 if ( is_null( $old_throttle ) ) { 848 delete_option( '_bbp_throttle_time' ); 849 } else { 850 update_option( '_bbp_throttle_time', $old_throttle ); 851 } 852 if ( false === $old_posted ) { 853 delete_transient( $key ); 854 } else { 855 set_transient( $key, $old_posted ); 856 } 857 } 812 858 } 813 859 … … 1555 1601 /** 1556 1602 * @covers ::bbp_notify_subscribers 1557 * @todo Implement test_bbp_notify_subscribers().1558 1603 */ 1559 1604 public function test_bbp_notify_subscribers() { 1560 // Remove the following lines when you implement this test. 1561 $this->markTestIncomplete( 1562 'This test has not been implemented yet.' 1563 ); 1605 $this->assertFalse( bbp_notify_subscribers() ); 1564 1606 } 1565 1607 1566 1608 /** 1567 1609 * @covers ::bbp_logout_url 1568 * @todo Implement test_bbp_logout_url().1569 1610 */ 1570 1611 public function test_bbp_logout_url() { 1571 // Remove the following lines when you implement this test. 1572 $this->markTestIncomplete( 1573 'This test has not been implemented yet.' 1574 ); 1612 $url = 'https://example.org/logout/'; 1613 $redirect = home_url( '/forums/' ); 1614 $result = bbp_logout_url( $url, $redirect ); 1615 $query = array(); 1616 wp_parse_str( wp_parse_url( $result, PHP_URL_QUERY ), $query ); 1617 1618 $this->assertSame( $redirect . '?loggedout=true', $query['redirect_to'] ); 1619 $this->assertSame( $url . '?redirect_to=already-set', bbp_logout_url( $url . '?redirect_to=already-set', $redirect ) ); 1575 1620 } 1576 1621 1577 1622 /** 1578 1623 * @covers ::bbp_parse_args 1579 * @todo Implement test_bbp_parse_args().1580 1624 */ 1581 1625 public function test_bbp_parse_args() { 1582 // Remove the following lines when you implement this test. 1583 $this->markTestIncomplete( 1584 'This test has not been implemented yet.' 1585 ); 1626 $defaults = array( 'count' => 1, 'order' => 'ASC' ); 1627 $this->assertSame( array( 'count' => 2, 'order' => 'ASC' ), bbp_parse_args( array( 'count' => 2 ), $defaults ) ); 1628 $this->assertSame( array( 'count' => '3', 'order' => 'DESC' ), bbp_parse_args( 'count=3&order=DESC', $defaults ) ); 1629 1630 $before = function( $args ) { 1631 $args['count'] = 4; 1632 return $args; 1633 }; 1634 $after = function( $args ) { 1635 $args['order'] = 'DESC'; 1636 return $args; 1637 }; 1638 add_filter( 'bbp_before_common_test_parse_args', $before ); 1639 add_filter( 'bbp_after_common_test_parse_args', $after ); 1640 try { 1641 $this->assertSame( array( 'count' => 4, 'order' => 'DESC' ), bbp_parse_args( array(), $defaults, 'common_test' ) ); 1642 } finally { 1643 remove_filter( 'bbp_before_common_test_parse_args', $before ); 1644 remove_filter( 'bbp_after_common_test_parse_args', $after ); 1645 } 1586 1646 } 1587 1647 1588 1648 /** 1589 1649 * @covers ::bbp_get_global_post_field 1590 * @todo Implement test_bbp_get_global_post_field().1591 1650 */ 1592 1651 public function test_bbp_get_global_post_field() { 1593 // Remove the following lines when you implement this test. 1594 $this->markTestIncomplete( 1595 'This test has not been implemented yet.' 1596 ); 1652 global $post; 1653 $old_post = $post; 1654 $post_id = $this->factory->post->create( array( 'post_title' => 'Global field title' ) ); 1655 try { 1656 $post = get_post( $post_id ); 1657 $this->assertSame( $post_id, bbp_get_global_post_field() ); 1658 $this->assertSame( 'Global field title', bbp_get_global_post_field( 'post_title', 'raw' ) ); 1659 $this->assertSame( '', bbp_get_global_post_field( 'not_a_field' ) ); 1660 } finally { 1661 $post = $old_post; 1662 } 1597 1663 } 1598 1664 1599 1665 /** 1600 1666 * @covers ::bbp_verify_nonce_request 1601 * @todo Implement test_bbp_verify_nonce_request().1602 1667 */ 1603 1668 public function test_bbp_verify_nonce_request() { 1604 // Remove the following lines when you implement this test. 1605 $this->markTestIncomplete( 1606 'This test has not been implemented yet.' 1607 ); 1669 $old_request = $_REQUEST; 1670 $action = 'common-functions-nonce'; 1671 $match = function() { 1672 return home_url( '/forums/' ); 1673 }; 1674 add_filter( 'bbp_verify_nonce_request_url', $match ); 1675 try { 1676 $_REQUEST['_wpnonce'] = wp_create_nonce( $action ); 1677 $this->assertNotFalse( bbp_verify_nonce_request( $action ) ); 1678 $this->assertFalse( bbp_verify_nonce_request( 'wrong-action' ) ); 1679 unset( $_REQUEST['_wpnonce'] ); 1680 $this->assertFalse( bbp_verify_nonce_request( $action ) ); 1681 } finally { 1682 remove_filter( 'bbp_verify_nonce_request_url', $match ); 1683 $_REQUEST = $old_request; 1684 } 1608 1685 } 1609 1686 1610 1687 /** 1611 1688 * @covers ::bbp_request_feed_trap 1612 * @todo Implement test_bbp_request_feed_trap().1613 1689 */ 1614 1690 public function test_bbp_request_feed_trap() { 1615 // Remove the following lines when you implement this test. 1616 $this->markTestIncomplete( 1617 'This test has not been implemented yet.' 1618 ); 1691 $query_vars = array( 'post_type' => bbp_get_topic_post_type(), 'paged' => 2 ); 1692 $this->assertSame( $query_vars, bbp_request_feed_trap( $query_vars ) ); 1693 $this->assertSame( array( 'feed' => 'rss2', 'post_type' => 'post' ), bbp_request_feed_trap( array( 'feed' => 'rss2', 'post_type' => 'post' ) ) ); 1619 1694 } 1620 1695 1621 1696 /** 1622 1697 * @covers ::bbp_get_page_by_path 1623 * @todo Implement test_bbp_get_page_by_path().1624 1698 */ 1625 1699 public function test_bbp_get_page_by_path() { 1626 // Remove the following lines when you implement this test. 1627 $this->markTestIncomplete( 1628 'This test has not been implemented yet.' 1629 ); 1700 global $wp_rewrite; 1701 $old_permalinks = $wp_rewrite->permalink_structure; 1702 $wp_rewrite->set_permalink_structure( '/%postname%/' ); 1703 $slug = 'common-test-page'; 1704 try { 1705 $this->assertFalse( bbp_get_page_by_path( $slug ) ); 1706 $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_name' => $slug, 'post_status' => 'publish' ) ); 1707 $this->assertSame( $page_id, bbp_get_page_by_path( $slug )->ID ); 1708 } finally { 1709 $wp_rewrite->set_permalink_structure( $old_permalinks ); 1710 } 1630 1711 } 1631 1712 … … 1789 1870 /** 1790 1871 * @covers ::bbp_set_404 1791 * @todo Implement test_bbp_set_404().1792 1872 */ 1793 1873 public function test_bbp_set_404() { 1794 // Remove the following lines when you implement this test. 1795 $this->markTestIncomplete( 1796 'This test has not been implemented yet.' 1797 ); 1874 $query = new WP_Query(); 1875 bbp_set_404( $query ); 1876 $this->assertTrue( $query->is_404() ); 1798 1877 } 1799 1878 } -
trunk/tests/phpunit/testcases/search/functions/search.php
r5754 r7762 11 11 /** 12 12 * @covers ::bbp_search_query 13 * @todo Implement test_bbp_search_query().14 13 */ 15 14 public function test_bbp_search_query() { 16 // Remove the following lines when you implement this test. 17 $this->markTestIncomplete( 18 'This test has not been implemented yet.' 19 ); 15 $old_search_query = bbpress()->search_query; 16 $defaults = function() { 17 return array( 's' => 'bbp-3695-default-no-results', 'posts_per_page' => 10 ); 18 }; 19 20 add_filter( 'bbp_get_search_query_args', $defaults ); 21 try { 22 $this->assertFalse( bbp_search_query() ); 23 $this->assertSame( 'bbp-3695-default-no-results', bbpress()->search_query->get( 's' ) ); 24 $this->assertSame( 10, bbpress()->search_query->get( 'posts_per_page' ) ); 25 26 $this->assertFalse( bbp_search_query( array( 's' => 'bbp-3695-no-results', 'posts_per_page' => 2 ) ) ); 27 $this->assertSame( 'bbp-3695-no-results', bbpress()->search_query->get( 's' ) ); 28 $this->assertSame( 2, bbpress()->search_query->get( 'posts_per_page' ) ); 29 } finally { 30 remove_filter( 'bbp_get_search_query_args', $defaults ); 31 bbpress()->search_query = $old_search_query; 32 } 20 33 } 21 34 22 35 /** 23 36 * @covers ::bbp_get_search_query_args 24 * @todo Implement test_bbp_get_search_query_args().25 37 */ 26 38 public function test_bbp_get_search_query_args() { 27 // Remove the following lines when you implement this test. 28 $this->markTestIncomplete( 29 'This test has not been implemented yet.' 30 ); 39 $terms = function() { 40 return 'bbpress-needle'; 41 }; 42 $filtered = function( $args ) { 43 $this->assertSame( array( 's' => 'bbpress-needle' ), $args ); 44 return array( 's' => 'filtered' ); 45 }; 46 47 $no_terms = function() { 48 return false; 49 }; 50 add_filter( 'bbp_get_search_terms', $no_terms ); 51 try { 52 $this->assertSame( array(), bbp_get_search_query_args() ); 53 } finally { 54 remove_filter( 'bbp_get_search_terms', $no_terms ); 55 } 56 add_filter( 'bbp_get_search_terms', $terms ); 57 try { 58 $this->assertSame( array( 's' => 'bbpress-needle' ), bbp_get_search_query_args() ); 59 add_filter( 'bbp_get_search_query_args', $filtered ); 60 try { 61 $this->assertSame( array( 's' => 'filtered' ), bbp_get_search_query_args() ); 62 } finally { 63 remove_filter( 'bbp_get_search_query_args', $filtered ); 64 } 65 } finally { 66 remove_filter( 'bbp_get_search_terms', $terms ); 67 } 31 68 } 32 69 33 70 /** 34 71 * @covers ::bbp_search_results_redirect 35 * @todo Implement test_bbp_search_results_redirect().36 72 */ 37 73 public function test_bbp_search_results_redirect() { 38 // Remove the following lines when you implement this test. 39 $this->markTestIncomplete( 40 'This test has not been implemented yet.' 41 ); 74 $action = isset( $_GET['action'] ) ? $_GET['action'] : null; 75 $pretty_calls = 0; 76 $url_calls = 0; 77 $pretty_filter = function( $pretty ) use ( &$pretty_calls ) { 78 $pretty_calls++; 79 return $pretty; 80 }; 81 $url_filter = function() use ( &$url_calls ) { 82 $url_calls++; 83 return ''; 84 }; 85 86 add_filter( 'bbp_pretty_urls', $pretty_filter ); 87 add_filter( 'bbp_get_search_results_url', $url_filter ); 88 try { 89 unset( $_GET['action'] ); 90 $this->assertNull( bbp_search_results_redirect() ); 91 $_GET['action'] = 'other'; 92 $this->assertNull( bbp_search_results_redirect() ); 93 $this->assertSame( 0, $pretty_calls ); 94 95 $_GET['action'] = 'bbp-search-request'; 96 $this->assertNull( bbp_search_results_redirect() ); 97 $this->assertSame( 1, $pretty_calls ); 98 $this->assertSame( 0, $url_calls ); 99 100 add_filter( 'bbp_pretty_urls', '__return_true', 20 ); 101 try { 102 $this->assertNull( bbp_search_results_redirect() ); 103 $this->assertSame( 1, $url_calls ); 104 } finally { 105 remove_filter( 'bbp_pretty_urls', '__return_true', 20 ); 106 } 107 } finally { 108 remove_filter( 'bbp_get_search_results_url', $url_filter ); 109 remove_filter( 'bbp_pretty_urls', $pretty_filter ); 110 if ( is_null( $action ) ) { 111 unset( $_GET['action'] ); 112 } else { 113 $_GET['action'] = $action; 114 } 115 } 116 } 117 118 /** 119 * @covers ::bbp_get_search_type_ids 120 */ 121 public function test_bbp_get_search_type_ids() { 122 $this->assertSame( array( 's', 'fs', 'ts', 'rs' ), bbp_get_search_type_ids() ); 123 124 $filter = function() { 125 return array( 'custom' ); 126 }; 127 add_filter( 'bbp_get_search_types', $filter ); 128 try { 129 $this->assertSame( array( 'custom' ), bbp_get_search_type_ids() ); 130 } finally { 131 remove_filter( 'bbp_get_search_types', $filter ); 132 } 133 } 134 135 /** 136 * @covers ::bbp_sanitize_search_request 137 */ 138 public function test_bbp_sanitize_search_request() { 139 $request = $_REQUEST; 140 $filter = function( $terms, $query_arg ) { 141 $this->assertSame( 's', $query_arg ); 142 $this->assertSame( 'alpha beta', $terms ); 143 return 'filtered'; 144 }; 145 146 try { 147 $_REQUEST = array(); 148 $this->assertFalse( bbp_sanitize_search_request( 'invalid' ) ); 149 $this->assertFalse( bbp_sanitize_search_request() ); 150 151 $_REQUEST['s'] = ' <strong>alpha</strong> beta '; 152 $this->assertSame( 'alpha beta', bbp_sanitize_search_request() ); 153 154 $_REQUEST['s'] = array( 'alpha', array( 'ignored' ), 'beta' ); 155 $this->assertSame( 'alpha beta', bbp_sanitize_search_request() ); 156 add_filter( 'bbp_sanitize_search_request', $filter, 10, 2 ); 157 try { 158 $this->assertSame( 'filtered', bbp_sanitize_search_request() ); 159 } finally { 160 remove_filter( 'bbp_sanitize_search_request', $filter ); 161 } 162 } finally { 163 $_REQUEST = $request; 164 } 42 165 } 43 166 } -
trunk/tests/phpunit/testcases/users/template/user.php
r7698 r7762 65 65 * @covers ::bbp_displayed_user_id 66 66 * @covers ::bbp_get_displayed_user_id 67 * @todo Implement test_bbp_get_displayed_user_id().68 67 */ 69 68 public function test_bbp_get_displayed_user_id() { 70 // Remove the following lines when you implement this test. 71 $this->markTestIncomplete( 72 'This test has not been implemented yet.' 73 ); 69 $old_displayed_user = bbpress()->displayed_user; 70 bbpress()->displayed_user = $this->keymaster_userdata; 71 72 try { 73 $this->assertSame( $this->keymaster_id, bbp_get_displayed_user_id() ); 74 $this->expectOutputString( (string) $this->keymaster_id ); 75 bbp_displayed_user_id(); 76 } finally { 77 bbpress()->displayed_user = $old_displayed_user; 78 } 74 79 } 75 80 … … 77 82 * @covers ::bbp_displayed_user_field 78 83 * @covers ::bbp_get_displayed_user_field 79 * @todo Implement test_bbp_get_displayed_user_field().80 84 */ 81 85 public function test_bbp_get_displayed_user_field() { 82 // Remove the following lines when you implement this test. 83 $this->markTestIncomplete( 84 'This test has not been implemented yet.' 85 ); 86 $old_displayed_user = bbpress()->displayed_user; 87 bbpress()->displayed_user = $this->keymaster_userdata; 88 $old_filter = $this->keymaster_userdata->filter; 89 90 try { 91 $expected_display_name = sanitize_user_field( 'display_name', $this->keymaster_userdata->display_name, $this->keymaster_id, 'display' ); 92 $this->assertSame( $expected_display_name, bbp_get_displayed_user_field( 'display_name' ) ); 93 $this->assertSame( $old_filter, $this->keymaster_userdata->filter ); 94 $this->assertSame( $this->keymaster_userdata->user_email, bbp_get_displayed_user_field( 'user_email', 'raw' ) ); 95 $this->assertSame( $old_filter, $this->keymaster_userdata->filter ); 96 $this->expectOutputString( $expected_display_name ); 97 bbp_displayed_user_field( 'display_name' ); 98 } finally { 99 bbpress()->displayed_user = $old_displayed_user; 100 } 86 101 } 87 102 … … 335 350 * @covers ::bbp_author_display_name 336 351 * @covers ::bbp_get_author_display_name 337 * @todo Implement test_bbp_get_author_display_name().338 352 */ 339 353 public function test_bbp_get_author_display_name() { 340 // Remove the following lines when you implement this test. 341 $this->markTestIncomplete( 342 'This test has not been implemented yet.' 343 ); 354 $this->assertSame( '', bbp_get_author_display_name() ); 355 $this->expectOutputString( '' ); 356 bbp_author_display_name(); 344 357 } 345 358 … … 347 360 * @covers ::bbp_author_email 348 361 * @covers ::bbp_get_author_email 349 * @todo Implement test_bbp_get_author_email().350 362 */ 351 363 public function test_bbp_get_author_email() { 352 // Remove the following lines when you implement this test. 353 $this->markTestIncomplete( 354 'This test has not been implemented yet.' 355 ); 364 $this->assertSame( '', bbp_get_author_email() ); 365 $this->expectOutputString( '' ); 366 bbp_author_email(); 356 367 } 357 368 … … 359 370 * @covers ::bbp_author_url 360 371 * @covers ::bbp_get_author_url 361 * @todo Implement test_bbp_get_author_url().362 372 */ 363 373 public function test_bbp_get_author_url() { 364 // Remove the following lines when you implement this test. 365 $this->markTestIncomplete( 366 'This test has not been implemented yet.' 367 ); 374 $this->assertSame( '', bbp_get_author_url() ); 375 $this->expectOutputString( '' ); 376 bbp_author_url(); 368 377 } 369 378 … … 415 424 * @covers ::bbp_user_favorites_link 416 425 * @covers ::bbp_get_user_favorites_link 417 * @todo Implement test_bbp_get_user_favorites_link().418 426 */ 419 427 public function test_bbp_get_user_favorites_link() { 420 // Remove the following lines when you implement this test. 421 $this->markTestIncomplete( 422 'This test has not been implemented yet.' 423 ); 428 $this->assertFalse( bbp_get_user_favorites_link( array( 'object_id' => 0 ) ) ); 429 $this->expectOutputString( '' ); 430 bbp_user_favorites_link( array( 'object_id' => 0 ) ); 424 431 } 425 432 … … 471 478 * @covers ::bbp_user_subscribe_link 472 479 * @covers ::bbp_get_user_subscribe_link 473 * @todo Implement test_bbp_get_user_subscribe_link().474 480 */ 475 481 public function test_bbp_get_user_subscribe_link() { 476 // Remove the following lines when you implement this test. 477 $this->markTestIncomplete( 478 'This test has not been implemented yet.' 479 ); 482 $this->assertFalse( bbp_get_user_subscribe_link( array( 'object_id' => 0 ) ) ); 483 $this->expectOutputString( '' ); 484 bbp_user_subscribe_link( array( 'object_id' => 0 ) ); 480 485 } 481 486 482 487 /** 483 488 * @covers ::bbp_notice_edit_user_success 484 * @todo Implement test_bbp_notice_edit_user_success().485 489 */ 486 490 public function test_bbp_notice_edit_user_success() { 487 // Remove the following lines when you implement this test. 488 $this->markTestIncomplete( 489 'This test has not been implemented yet.' 490 ); 491 ob_start(); 492 bbp_notice_edit_user_success(); 493 $this->assertSame( '', ob_get_clean() ); 494 495 $_GET['updated'] = '1'; 496 add_filter( 'bbp_is_single_user_edit', '__return_true' ); 497 try { 498 ob_start(); 499 bbp_notice_edit_user_success(); 500 $this->assertStringContainsString( 'User updated.', ob_get_clean() ); 501 } finally { 502 remove_filter( 'bbp_is_single_user_edit', '__return_true' ); 503 unset( $_GET['updated'] ); 504 } 491 505 } 492 506 493 507 /** 494 508 * @covers ::bbp_notice_edit_user_pending_email 495 * @todo Implement test_bbp_notice_edit_user_pending_email().496 509 */ 497 510 public function test_bbp_notice_edit_user_pending_email() { 498 // Remove the following lines when you implement this test. 499 $this->markTestIncomplete( 500 'This test has not been implemented yet.' 501 ); 511 ob_start(); 512 bbp_notice_edit_user_pending_email(); 513 $this->assertSame( '', ob_get_clean() ); 514 515 $old_displayed_user = bbpress()->displayed_user; 516 bbpress()->displayed_user = $this->keymaster_userdata; 517 add_filter( 'bbp_is_user_home_edit', '__return_true' ); 518 update_user_meta( $this->keymaster_id, '_new_email', array( 'newemail' => 'new@example.org' ) ); 519 try { 520 ob_start(); 521 bbp_notice_edit_user_pending_email(); 522 $output = ob_get_clean(); 523 $this->assertStringContainsString( '<code>new@example.org</code>', $output ); 524 $this->assertStringContainsString( 'Cancel', $output ); 525 } finally { 526 delete_user_meta( $this->keymaster_id, '_new_email' ); 527 remove_filter( 'bbp_is_user_home_edit', '__return_true' ); 528 bbpress()->displayed_user = $old_displayed_user; 529 } 502 530 } 503 531 504 532 /** 505 533 * @covers ::bbp_notice_edit_user_is_super_admin 506 * @todo Implement test_bbp_notice_edit_user_is_super_admin().507 534 */ 508 535 public function test_bbp_notice_edit_user_is_super_admin() { 509 // Remove the following lines when you implement this test. 510 $this->markTestIncomplete( 511 'This test has not been implemented yet.' 512 ); 536 ob_start(); 537 bbp_notice_edit_user_is_super_admin(); 538 $this->assertSame( '', ob_get_clean() ); 513 539 } 514 540 … … 538 564 /** 539 565 * @covers ::bbp_edit_user_blog_role 540 * @todo Implement test_bbp_edit_user_blog_role().541 566 */ 542 567 public function test_bbp_edit_user_blog_role() { 543 // Remove the following lines when you implement this test. 544 $this->markTestIncomplete( 545 'This test has not been implemented yet.' 546 ); 568 ob_start(); 569 bbp_edit_user_blog_role(); 570 $this->assertSame( '', ob_get_clean() ); 571 572 $old_displayed_user = bbpress()->displayed_user; 573 bbpress()->displayed_user = $this->keymaster_userdata; 574 add_filter( 'bbp_is_single_user_edit', '__return_true' ); 575 try { 576 ob_start(); 577 bbp_edit_user_blog_role(); 578 $output = ob_get_clean(); 579 $this->assertStringContainsString( '<select name="role" id="role">', $output ); 580 $this->assertStringContainsString( 'value="administrator"', $output ); 581 } finally { 582 remove_filter( 'bbp_is_single_user_edit', '__return_true' ); 583 bbpress()->displayed_user = $old_displayed_user; 584 } 547 585 } 548 586 549 587 /** 550 588 * @covers ::bbp_edit_user_forums_role 551 * @todo Implement test_bbp_edit_user_forums_role().552 589 */ 553 590 public function test_bbp_edit_user_forums_role() { 554 // Remove the following lines when you implement this test. 555 $this->markTestIncomplete( 556 'This test has not been implemented yet.' 557 ); 591 ob_start(); 592 bbp_edit_user_forums_role(); 593 $this->assertSame( '', ob_get_clean() ); 594 595 $old_displayed_user = bbpress()->displayed_user; 596 bbpress()->displayed_user = $this->keymaster_userdata; 597 add_filter( 'bbp_is_single_user_edit', '__return_true' ); 598 try { 599 ob_start(); 600 bbp_edit_user_forums_role(); 601 $output = ob_get_clean(); 602 $this->assertStringContainsString( '<select name="bbp-forums-role" id="bbp-forums-role">', $output ); 603 $this->assertStringContainsString( 'value="bbp_keymaster"', $output ); 604 } finally { 605 remove_filter( 'bbp_is_single_user_edit', '__return_true' ); 606 bbpress()->displayed_user = $old_displayed_user; 607 } 558 608 } 559 609 560 610 /** 561 611 * @covers ::bbp_edit_user_contact_methods 562 * @todo Implement test_bbp_edit_user_contact_methods().563 612 */ 564 613 public function test_bbp_edit_user_contact_methods() { 565 // Remove the following lines when you implement this test. 566 $this->markTestIncomplete( 567 'This test has not been implemented yet.' 568 ); 614 $old_displayed_user = bbpress()->displayed_user; 615 bbpress()->displayed_user = $this->keymaster_userdata; 616 617 try { 618 $this->assertSame( wp_get_user_contact_methods( $this->keymaster_userdata ), bbp_edit_user_contact_methods() ); 619 } finally { 620 bbpress()->displayed_user = $old_displayed_user; 621 } 569 622 } 570 623 … … 659 712 /** 660 713 * @covers ::bbp_login_notices 661 * @todo Implement test_bbp_login_notices().662 714 */ 663 715 public function test_bbp_login_notices() { 664 // Remove the following lines when you implement this test. 665 $this->markTestIncomplete( 666 'This test has not been implemented yet.' 667 ); 716 $old_errors = bbpress()->errors; 717 bbpress()->errors = new WP_Error(); 718 719 try { 720 bbp_login_notices(); 721 $this->assertFalse( bbp_has_errors() ); 722 723 $_GET['loggedout'] = 'true'; 724 bbp_login_notices(); 725 $this->assertSame( 'message', bbpress()->errors->get_error_data( 'loggedout' ) ); 726 $this->assertSame( 'You are now logged out.', bbpress()->errors->get_error_message( 'loggedout' ) ); 727 } finally { 728 unset( $_GET['loggedout'] ); 729 bbpress()->errors = $old_errors; 730 } 668 731 } 669 732 670 733 /** 671 734 * @covers ::bbp_logged_in_redirect 672 * @todo Implement test_bbp_logged_in_redirect().673 735 */ 674 736 public function test_bbp_logged_in_redirect() { 675 // Remove the following lines when you implement this test. 676 $this->markTestIncomplete( 677 'This test has not been implemented yet.' 678 ); 737 $this->set_current_user( 0 ); 738 $this->assertNull( bbp_logged_in_redirect( 'https://example.org/' ) ); 679 739 } 680 740 681 741 /** 682 742 * @covers ::bbp_user_login_fields 683 * @todo Implement test_bbp_user_login_fields().684 743 */ 685 744 public function test_bbp_user_login_fields() { 686 // Remove the following lines when you implement this test. 687 $this->markTestIncomplete( 688 'This test has not been implemented yet.' 689 ); 745 ob_start(); 746 bbp_user_login_fields(); 747 $output = ob_get_clean(); 748 $this->assertStringContainsString( 'name="user-cookie" value="1"', $output ); 749 $this->assertStringContainsString( 'name="_wpnonce"', $output ); 750 $this->assertStringContainsString( 'name="_wp_http_referer"', $output ); 690 751 } 691 752 692 753 /** 693 754 * @covers ::bbp_user_register_fields 694 * @todo Implement test_bbp_user_register_fields().695 755 */ 696 756 public function test_bbp_user_register_fields() { 697 // Remove the following lines when you implement this test. 698 $this->markTestIncomplete( 699 'This test has not been implemented yet.' 700 ); 757 ob_start(); 758 bbp_user_register_fields(); 759 $output = ob_get_clean(); 760 $this->assertStringContainsString( 'name="action" value="register"', $output ); 761 $this->assertStringContainsString( 'name="user-cookie" value="1"', $output ); 762 $this->assertStringContainsString( 'name="_wpnonce"', $output ); 763 $this->assertStringContainsString( 'checkemail=registered', $output ); 701 764 } 702 765 703 766 /** 704 767 * @covers ::bbp_user_lost_pass_fields 705 * @todo Implement test_bbp_user_lost_pass_fields().706 768 */ 707 769 public function test_bbp_user_lost_pass_fields() { 708 // Remove the following lines when you implement this test. 709 $this->markTestIncomplete( 710 'This test has not been implemented yet.' 711 ); 770 ob_start(); 771 bbp_user_lost_pass_fields(); 772 $output = ob_get_clean(); 773 $this->assertStringContainsString( 'name="user-cookie" value="1"', $output ); 774 $this->assertStringContainsString( 'name="_wpnonce"', $output ); 775 $this->assertStringContainsString( 'checkemail=confirm', $output ); 712 776 } 713 777 … … 754 818 /** 755 819 * @covers ::bbp_user_can_view_forum 756 * @todo Implement test_bbp_user_can_view_forum().757 820 */ 758 821 public function test_bbp_user_can_view_forum() { 759 // Remove the following lines when you implement this test. 760 $this->markTestIncomplete( 761 'This test has not been implemented yet.' 762 ); 822 $public_id = $this->factory->forum->create(); 823 $private_id = $this->factory->forum->create( array( 'post_status' => bbp_get_private_status_id() ) ); 824 $hidden_id = $this->factory->forum->create( array( 'post_status' => bbp_get_hidden_status_id() ) ); 825 $child_id = $this->factory->forum->create( array( 'post_parent' => $hidden_id ) ); 826 827 $participant_id = $this->factory->user->create(); 828 bbp_set_user_role( $participant_id, bbp_get_participant_role() ); 829 $moderator_id = $this->factory->user->create(); 830 bbp_set_user_role( $moderator_id, bbp_get_moderator_role() ); 831 832 $this->assertTrue( bbp_user_can_view_forum( array( 'user_id' => 0, 'forum_id' => $public_id ) ) ); 833 $this->assertFalse( bbp_user_can_view_forum( array( 'user_id' => 0, 'forum_id' => $private_id ) ) ); 834 $this->assertFalse( bbp_user_can_view_forum( array( 'user_id' => $participant_id, 'forum_id' => $hidden_id ) ) ); 835 $this->assertFalse( bbp_user_can_view_forum( array( 'user_id' => 0, 'forum_id' => $child_id ) ) ); 836 $this->assertTrue( bbp_user_can_view_forum( array( 'user_id' => 0, 'forum_id' => $child_id, 'check_ancestors' => false ) ) ); 837 $this->assertTrue( bbp_user_can_view_forum( array( 'user_id' => $moderator_id, 'forum_id' => $private_id ) ) ); 838 $this->assertTrue( bbp_user_can_view_forum( array( 'user_id' => $moderator_id, 'forum_id' => $hidden_id ) ) ); 839 $this->assertTrue( bbp_user_can_view_forum( array( 'user_id' => $this->keymaster_id, 'forum_id' => $hidden_id ) ) ); 763 840 } 764 841 765 842 /** 766 843 * @covers ::bbp_current_user_can_publish_forums 767 * @todo Implement test_bbp_current_user_can_publish_forums().768 844 */ 769 845 public function test_bbp_current_user_can_publish_forums() { 770 // Remove the following lines when you implement this test. 771 $this->markTestIncomplete( 772 'This test has not been implemented yet.' 773 ); 846 $this->assertTrue( bbp_current_user_can_publish_forums() ); 847 $this->set_current_user( 0 ); 848 $this->assertFalse( bbp_current_user_can_publish_forums() ); 774 849 } 775 850 776 851 /** 777 852 * @covers ::bbp_current_user_can_publish_topics 778 * @todo Implement test_bbp_current_user_can_publish_topics().779 853 */ 780 854 public function test_bbp_current_user_can_publish_topics() { 781 // Remove the following lines when you implement this test. 782 $this->markTestIncomplete( 783 'This test has not been implemented yet.' 784 ); 855 $this->assertTrue( bbp_current_user_can_publish_topics() ); 856 $this->set_current_user( 0 ); 857 $this->assertSame( bbp_allow_anonymous(), bbp_current_user_can_publish_topics() ); 785 858 } 786 859 787 860 /** 788 861 * @covers ::bbp_current_user_can_publish_replies 789 * @todo Implement test_bbp_current_user_can_publish_replies().790 862 */ 791 863 public function test_bbp_current_user_can_publish_replies() { 792 // Remove the following lines when you implement this test. 793 $this->markTestIncomplete( 794 'This test has not been implemented yet.' 795 ); 864 $this->assertTrue( bbp_current_user_can_publish_replies() ); 865 $this->set_current_user( 0 ); 866 $this->assertSame( bbp_allow_anonymous(), bbp_current_user_can_publish_replies() ); 796 867 } 797 868 798 869 /** 799 870 * @covers ::bbp_get_forums_for_current_user 800 * @todo Implement test_bbp_get_forums_for_current_user().801 871 */ 802 872 public function test_bbp_get_forums_for_current_user() { 803 // Remove the following lines when you implement this test. 804 $this->markTestIncomplete( 805 'This test has not been implemented yet.' 806 ); 873 $this->assertFalse( bbp_get_forums_for_current_user() ); 874 $forum_id = $this->factory->forum->create(); 875 $forums = bbp_get_forums_for_current_user(); 876 $this->assertCount( 1, $forums ); 877 $this->assertSame( $forum_id, $forums[0]->ID ); 807 878 } 808 879 809 880 /** 810 881 * @covers ::bbp_current_user_can_access_create_forum_form 811 * @todo Implement test_bbp_current_user_can_access_create_forum_form().812 882 */ 813 883 public function test_bbp_current_user_can_access_create_forum_form() { 814 // Remove the following lines when you implement this test. 815 $this->markTestIncomplete( 816 'This test has not been implemented yet.' 817 ); 884 $this->assertTrue( bbp_current_user_can_access_create_forum_form() ); 885 $this->set_current_user( 0 ); 886 $this->assertFalse( bbp_current_user_can_access_create_forum_form() ); 818 887 } 819 888 820 889 /** 821 890 * @covers ::bbp_current_user_can_access_create_topic_form 822 * @todo Implement test_bbp_current_user_can_access_create_topic_form().823 891 */ 824 892 public function test_bbp_current_user_can_access_create_topic_form() { 825 // Remove the following lines when you implement this test. 826 $this->markTestIncomplete( 827 'This test has not been implemented yet.' 828 ); 893 $this->assertTrue( bbp_current_user_can_access_create_topic_form() ); 894 $this->set_current_user( 0 ); 895 $this->assertFalse( bbp_current_user_can_access_create_topic_form() ); 829 896 } 830 897 831 898 /** 832 899 * @covers ::bbp_current_user_can_access_create_reply_form 833 * @todo Implement test_bbp_current_user_can_access_create_reply_form().834 900 */ 835 901 public function test_bbp_current_user_can_access_create_reply_form() { 836 // Remove the following lines when you implement this test. 837 $this->markTestIncomplete( 838 'This test has not been implemented yet.' 839 ); 902 $this->assertTrue( bbp_current_user_can_access_create_reply_form() ); 903 $this->set_current_user( 0 ); 904 $this->assertFalse( bbp_current_user_can_access_create_reply_form() ); 840 905 } 841 906 842 907 /** 843 908 * @covers ::bbp_current_user_can_access_anonymous_user_form 844 * @todo Implement test_bbp_current_user_can_access_anonymous_user_form().845 909 */ 846 910 public function test_bbp_current_user_can_access_anonymous_user_form() { 847 // Remove the following lines when you implement this test. 848 $this->markTestIncomplete( 849 'This test has not been implemented yet.' 850 ); 911 $this->assertFalse( bbp_current_user_can_access_anonymous_user_form() ); 912 $this->set_current_user( 0 ); 913 $this->assertSame( bbp_allow_anonymous(), bbp_current_user_can_access_anonymous_user_form() ); 851 914 } 852 915 }
Note:
See TracChangeset
for help on using the changeset viewer.