[ Index ] |
PHP Cross Reference of BBPress |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Tests for bbPress forum functions. 5 * 6 * @group forums 7 * @group functions 8 * @group forum 9 */ 10 class BBP_Tests_Forums_Functions_Forum extends BBP_UnitTestCase { 11 12 /** 13 * @group canonical 14 * @covers ::bbp_insert_forum 15 */ 16 public function test_bbp_insert_forum() { 17 18 $c = $this->factory->forum->create( array( 19 'post_title' => 'Category 1', 20 'post_content' => 'Content of Category 1', 21 'forum_meta' => array( 22 'forum_type' => 'category', 23 'status' => 'open', 24 ), 25 ) ); 26 27 $f = $this->factory->forum->create( array( 28 'post_title' => 'Forum 1', 29 'post_content' => 'Content of Forum 1', 30 'post_parent' => $c, 31 'forum_meta' => array( 32 'forum_id' => $c, 33 'forum_type' => 'forum', 34 'status' => 'open', 35 ), 36 ) ); 37 38 $now = time(); 39 $post_date = date( 'Y-m-d H:i:s', $now - 60 * 60 * 100 ); 40 41 $t = $this->factory->topic->create( array( 42 'post_parent' => $f, 43 'post_date' => $post_date, 44 'topic_meta' => array( 45 'forum_id' => $f, 46 ), 47 ) ); 48 49 $r = $this->factory->reply->create( array( 50 'post_parent' => $t, 51 'post_date' => $post_date, 52 'reply_meta' => array( 53 'forum_id' => $f, 54 'topic_id' => $t, 55 ), 56 ) ); 57 58 // Get the category. 59 $category = bbp_get_forum( $c ); 60 61 // Get the forum. 62 $forum = bbp_get_forum( $f ); 63 64 // Category post. 65 $this->assertSame( 'Category 1', bbp_get_forum_title( $c ) ); 66 $this->assertSame( 'Content of Category 1', bbp_get_forum_content( $c ) ); 67 $this->assertSame( 'open', bbp_get_forum_status( $c ) ); 68 $this->assertSame( 'category', bbp_get_forum_type( $c ) ); 69 $this->assertTrue( bbp_is_forum( $c ) ); 70 $this->assertTrue( bbp_is_forum_category( $c ) ); 71 $this->assertTrue( bbp_is_forum_open( $c ) ); 72 $this->assertTrue( bbp_is_forum_public( $c ) ); 73 $this->assertFalse( bbp_is_forum_closed( $c ) ); 74 $this->assertFalse( bbp_is_forum_hidden( $c ) ); 75 $this->assertFalse( bbp_is_forum_private( $c ) ); 76 $this->assertSame( 0, bbp_get_forum_parent_id( $c ) ); 77 $this->assertEquals( 'http://' . WP_TESTS_DOMAIN . '/?forum=' . $category->post_name, $category->guid ); 78 79 // Forum post. 80 $this->assertSame( 'Forum 1', bbp_get_forum_title( $f ) ); 81 $this->assertSame( 'Content of Forum 1', bbp_get_forum_content( $f ) ); 82 $this->assertSame( 'open', bbp_get_forum_status( $f ) ); 83 $this->assertSame( 'forum', bbp_get_forum_type( $f ) ); 84 $this->assertTrue( bbp_is_forum( $f ) ); 85 $this->assertTrue( bbp_is_forum_open( $f ) ); 86 $this->assertTrue( bbp_is_forum_public( $f ) ); 87 $this->assertFalse( bbp_is_forum_closed( $f ) ); 88 $this->assertFalse( bbp_is_forum_hidden( $f ) ); 89 $this->assertFalse( bbp_is_forum_private( $f ) ); 90 $this->assertSame( $c, bbp_get_forum_parent_id( $f ) ); 91 $this->assertEquals( 'http://' . WP_TESTS_DOMAIN . '/?forum=' . $category->post_name . '/' . $forum->post_name, $forum->guid ); 92 93 // Category meta. 94 $this->assertSame( 1, bbp_get_forum_subforum_count( $c, true ) ); 95 $this->assertSame( 0, bbp_get_forum_topic_count( $c, false, true ) ); 96 $this->assertSame( 1, bbp_get_forum_topic_count( $c, true, true ) ); 97 $this->assertSame( 0, bbp_get_forum_topic_count_hidden( $c, true ) ); 98 $this->assertSame( 0, bbp_get_forum_reply_count( $c, false, true ) ); 99 $this->assertSame( 1, bbp_get_forum_reply_count( $c, true, true ) ); 100 $this->assertSame( 0, bbp_get_forum_post_count( $c, false, true ) ); 101 $this->assertSame( 2, bbp_get_forum_post_count( $c, true, true ) ); 102 $this->assertSame( $t, bbp_get_forum_last_topic_id( $c ) ); 103 $this->assertSame( $r, bbp_get_forum_last_reply_id( $c ) ); 104 $this->assertSame( $r, bbp_get_forum_last_active_id( $c ) ); 105 $this->assertSame( '4 days, 4 hours ago', bbp_get_forum_last_active_time( $c ) ); 106 107 // Forum meta. 108 $this->assertSame( 0, bbp_get_forum_subforum_count( $f, true ) ); 109 $this->assertSame( 1, bbp_get_forum_topic_count( $f, false, true ) ); 110 $this->assertSame( 1, bbp_get_forum_topic_count( $f, true, true ) ); 111 $this->assertSame( 0, bbp_get_forum_topic_count_hidden( $f, true ) ); 112 $this->assertSame( 1, bbp_get_forum_reply_count( $f, false, true ) ); 113 $this->assertSame( 1, bbp_get_forum_reply_count( $f, true, true ) ); 114 115 $this->assertSame( 2, bbp_get_forum_post_count( $f, false, true ) ); 116 $this->assertSame( 2, bbp_get_forum_post_count( $f, true, true ) ); 117 $this->assertSame( $t, bbp_get_forum_last_topic_id( $f ) ); 118 $this->assertSame( $r, bbp_get_forum_last_reply_id( $f ) ); 119 $this->assertSame( $r, bbp_get_forum_last_active_id( $f ) ); 120 $this->assertSame( '4 days, 4 hours ago', bbp_get_forum_last_active_time( $f ) ); 121 } 122 123 /** 124 * @covers ::bbp_new_forum_handler 125 * @todo Implement test_bbp_new_forum_handler(). 126 */ 127 public function test_bbp_new_forum_handler() { 128 // Remove the following lines when you implement this test. 129 $this->markTestIncomplete( 130 'This test has not been implemented yet.' 131 ); 132 } 133 134 /** 135 * @covers ::bbp_edit_forum_handler 136 * @todo Implement test_bbp_edit_forum_handler(). 137 */ 138 public function test_bbp_edit_forum_handler() { 139 // Remove the following lines when you implement this test. 140 $this->markTestIncomplete( 141 'This test has not been implemented yet.' 142 ); 143 } 144 145 /** 146 * @covers ::bbp_save_forum_extras 147 * @todo Implement test_bbp_save_forum_extras(). 148 */ 149 public function test_bbp_save_forum_extras() { 150 // Remove the following lines when you implement this test. 151 $this->markTestIncomplete( 152 'This test has not been implemented yet.' 153 ); 154 } 155 156 /** 157 * @covers ::bbp_remove_forum_from_all_subscriptions 158 * @todo Implement test_bbp_remove_forum_from_all_subscriptions(). 159 */ 160 public function test_bbp_remove_forum_from_all_subscriptions() { 161 // Remove the following lines when you implement this test. 162 $this->markTestIncomplete( 163 'This test has not been implemented yet.' 164 ); 165 } 166 167 /** 168 * @covers ::bbp_update_forum 169 * @todo Implement test_bbp_update_forum(). 170 */ 171 public function test_bbp_update_forum() { 172 // Remove the following lines when you implement this test. 173 $this->markTestIncomplete( 174 'This test has not been implemented yet.' 175 ); 176 } 177 178 /** 179 * @covers ::bbp_check_forum_edit 180 * @todo Implement test_bbp_check_forum_edit(). 181 */ 182 public function test_bbp_check_forum_edit() { 183 // Remove the following lines when you implement this test. 184 $this->markTestIncomplete( 185 'This test has not been implemented yet.' 186 ); 187 } 188 /** 189 * @covers ::bbp_delete_forum_topics 190 * @todo Implement test_bbp_delete_forum_topics(). 191 */ 192 public function test_bbp_delete_forum_topics() { 193 // Remove the following lines when you implement this test. 194 $this->markTestIncomplete( 195 'This test has not been implemented yet.' 196 ); 197 } 198 199 /** 200 * @covers ::bbp_trash_forum_topics 201 * @todo Implement test_bbp_trash_forum_topics(). 202 */ 203 public function test_bbp_trash_forum_topics() { 204 // Remove the following lines when you implement this test. 205 $this->markTestIncomplete( 206 'This test has not been implemented yet.' 207 ); 208 } 209 210 /** 211 * @covers ::bbp_untrash_forum_topics 212 * @todo Implement test_bbp_untrash_forum_topics(). 213 */ 214 public function test_bbp_untrash_forum_topics() { 215 // Remove the following lines when you implement this test. 216 $this->markTestIncomplete( 217 'This test has not been implemented yet.' 218 ); 219 } 220 221 /** 222 * @covers ::bbp_delete_forum 223 * @todo Implement test_bbp_delete_forum(). 224 */ 225 public function test_bbp_delete_forum() { 226 // Remove the following lines when you implement this test. 227 $this->markTestIncomplete( 228 'This test has not been implemented yet.' 229 ); 230 } 231 232 /** 233 * @covers ::bbp_trash_forum 234 * @todo Implement test_bbp_trash_forum(). 235 */ 236 public function test_bbp_trash_forum() { 237 // Remove the following lines when you implement this test. 238 $this->markTestIncomplete( 239 'This test has not been implemented yet.' 240 ); 241 } 242 243 /** 244 * @covers ::bbp_untrash_forum 245 * @todo Implement test_bbp_untrash_forum(). 246 */ 247 public function test_bbp_untrash_forum() { 248 // Remove the following lines when you implement this test. 249 $this->markTestIncomplete( 250 'This test has not been implemented yet.' 251 ); 252 } 253 254 /** 255 * @covers ::bbp_deleted_forum 256 * @todo Implement test_bbp_deleted_forum(). 257 */ 258 public function test_bbp_deleted_forum() { 259 // Remove the following lines when you implement this test. 260 $this->markTestIncomplete( 261 'This test has not been implemented yet.' 262 ); 263 } 264 265 /** 266 * @covers ::bbp_trashed_forum 267 * @todo Implement test_bbp_trashed_forum(). 268 */ 269 public function test_bbp_trashed_forum() { 270 // Remove the following lines when you implement this test. 271 $this->markTestIncomplete( 272 'This test has not been implemented yet.' 273 ); 274 } 275 276 /** 277 * @covers ::bbp_untrashed_forum 278 * @todo Implement test_bbp_untrashed_forum(). 279 */ 280 public function test_bbp_untrashed_forum() { 281 // Remove the following lines when you implement this test. 282 $this->markTestIncomplete( 283 'This test has not been implemented yet.' 284 ); 285 } 286 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Oct 8 01:00:48 2024 | Cross-referenced by PHPXref 0.7.1 |