Changeset 7762 for trunk/tests/phpunit/testcases/admin/tools.php
- Timestamp:
- 10/01/2026 12:18:13 AM (4 weeks ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/testcases/admin/tools.php (modified) (1 diff)
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
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)