Changeset 5965
- Timestamp:
- 12/21/2015 08:07:42 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/forums/template/get-last-thing.php
r5947 r5965 15 15 */ 16 16 public function test_bbp_get_forum_last_active_id() { 17 $f = $this->factory->forum->create(); 18 19 $last_id = bbp_get_forum_last_active_id( $f ); 17 $c = $this->factory->forum->create(); 18 19 $f = $this->factory->forum->create( array( 20 'post_parent' => $c, 21 'forum_meta' => array( 22 'forum_id' => $c, 23 '_bbp_forum_type' => 'forum', 24 '_bbp_status' => 'open', 25 ), 26 ) ); 27 28 // Get the forums last active id. 29 $last_id = bbp_get_forum_last_active_id( $f ); 30 $this->assertSame( 0, $last_id ); 31 32 // Get the categories last active id. 33 $last_id = bbp_get_forum_last_active_id( $c ); 20 34 $this->assertSame( 0, $last_id ); 21 35 22 36 bbp_update_forum_last_active_id( $f ); 23 37 24 $last_id = bbp_get_forum_last_active_id( $f ); 38 // Get the forums last active id. 39 $last_id = bbp_get_forum_last_active_id( $f ); 40 $this->assertSame( 0, $last_id ); 41 42 // Get the categories last active id. 43 $last_id = bbp_get_forum_last_active_id( $c ); 25 44 $this->assertSame( 0, $last_id ); 26 45 … … 34 53 bbp_update_forum_last_active_id( $f ); 35 54 55 // Get the forums last active id. 36 56 $last_id = bbp_get_forum_last_active_id( $f ); 37 57 $this->assertSame( $t, $last_id ); 38 58 59 // Get the categories last active id. 60 $last_id = bbp_get_forum_last_active_id( $c ); 61 $this->assertSame( $t, $last_id ); 62 39 63 $r = $this->factory->reply->create( array( 40 64 'post_parent' => $t, … … 47 71 bbp_update_forum_last_active_id( $f ); 48 72 49 $last_id = bbp_get_forum_last_active_id( $f ); 73 // Get the forums last active id. 74 $last_id = bbp_get_forum_last_active_id( $f ); 75 $this->assertSame( $r, $last_id ); 76 77 // Get the categories last active id. 78 $last_id = bbp_get_forum_last_active_id( $c ); 50 79 $this->assertSame( $r, $last_id ); 51 80 } … … 57 86 public function test_bbp_get_forum_last_active_id_with_pending_reply() { 58 87 $u = $this->factory->user->create_many( 2 ); 59 $f = $this->factory->forum->create(); 60 61 $last_id = bbp_get_forum_last_active_id( $f ); 88 89 $c = $this->factory->forum->create(); 90 91 $f = $this->factory->forum->create( array( 92 'post_parent' => $c, 93 'forum_meta' => array( 94 'forum_id' => $c, 95 '_bbp_forum_type' => 'forum', 96 '_bbp_status' => 'open', 97 ), 98 ) ); 99 100 // Get the forums last active id. 101 $last_id = bbp_get_forum_last_active_id( $f ); 102 $this->assertSame( 0, $last_id ); 103 104 // Get the categories last active id. 105 $last_id = bbp_get_forum_last_active_id( $c ); 62 106 $this->assertSame( 0, $last_id ); 63 107 64 108 bbp_update_forum_last_active_id( $f ); 65 109 66 $last_id = bbp_get_forum_last_active_id( $f ); 110 // Get the forums last active id. 111 $last_id = bbp_get_forum_last_active_id( $f ); 112 $this->assertSame( 0, $last_id ); 113 114 // Get the categories last active id. 115 $last_id = bbp_get_forum_last_active_id( $c ); 67 116 $this->assertSame( 0, $last_id ); 68 117 … … 76 125 bbp_update_forum_last_active_id( $f ); 77 126 127 // Get the forums last active id. 78 128 $last_id = bbp_get_forum_last_active_id( $f ); 79 129 $this->assertSame( $t, $last_id ); 80 130 131 // Get the categories last active id. 132 $last_id = bbp_get_forum_last_active_id( $c ); 133 $this->assertSame( $t, $last_id ); 134 81 135 $r1 = $this->factory->reply->create( array( 82 136 'post_parent' => $t, … … 89 143 bbp_update_forum_last_active_id( $f ); 90 144 91 $last_id = bbp_get_forum_last_active_id( $f ); 145 // Get the forums last active id. 146 $last_id = bbp_get_forum_last_active_id( $f ); 147 $this->assertSame( $r1, $last_id ); 148 149 // Get the categories last active id. 150 $last_id = bbp_get_forum_last_active_id( $c ); 151 92 152 $this->assertSame( $r1, $last_id ); 93 153 … … 102 162 ) ); 103 163 164 // Get the forums last active id. 104 165 $last_id = bbp_get_forum_last_active_id( $f ); 105 166 $this->assertSame( $r1, $last_id ); 106 167 168 // Get the categories last active id. 169 $last_id = bbp_get_forum_last_active_id( $c ); 170 $this->assertSame( $r1, $last_id ); 171 107 172 bbp_approve_reply( $r2 ); 108 173 109 $last_id = bbp_get_forum_last_active_id( $f ); 174 // Get the forums last active id. 175 $last_id = bbp_get_forum_last_active_id( $f ); 176 $this->assertSame( $r2, $last_id ); 177 178 // Get the categories last active id. 179 $last_id = bbp_get_forum_last_active_id( $c ); 110 180 $this->assertSame( $r2, $last_id ); 111 181 } … … 116 186 */ 117 187 public function test_bbp_get_forum_last_active_time() { 118 $f = $this->factory->forum->create(); 188 $c = $this->factory->forum->create(); 189 190 $f = $this->factory->forum->create( array( 191 'post_parent' => $c, 192 'forum_meta' => array( 193 'forum_id' => $c, 194 '_bbp_forum_type' => 'forum', 195 '_bbp_status' => 'open', 196 ), 197 ) ); 119 198 120 199 $now = time(); 121 $post_date = date( 'Y-m-d H:i:s', $now - 60*60*100 ); 122 200 $post_date = date( 'Y-m-d H:i:s', $now - 60 * 60 * 100 ); 201 202 // Get the forums last active time. 123 203 $last_time = bbp_get_forum_last_active_time( $f ); 124 204 $this->assertSame( '', $last_time ); 125 205 206 // Get the categories last active time. 207 $last_time = bbp_get_forum_last_active_time( $c ); 208 $this->assertSame( '', $last_time ); 209 126 210 $t = $this->factory->topic->create( array( 127 211 'post_parent' => $f, … … 133 217 134 218 bbp_update_forum_last_active_time( $f ); 219 220 // Get the forums last active time. 135 221 $last_time = bbp_get_forum_last_active_time( $f ); 136 222 $this->assertSame( '4 days, 4 hours ago', $last_time ); 137 223 224 // Get the categories last active time. 225 $last_time = bbp_get_forum_last_active_time( $c ); 226 $this->assertSame( '4 days, 4 hours ago', $last_time ); 227 138 228 $this->factory->reply->create( array( 139 229 'post_parent' => $t, … … 147 237 bbp_update_forum_last_active_time( $f ); 148 238 239 // Get the forums last active time. 149 240 $last_time = bbp_get_forum_last_active_time( $f ); 150 241 $this->assertSame( '4 days, 4 hours ago', $last_time ); 242 243 // Get the categories last active time. 244 $last_time = bbp_get_forum_last_active_time( $c ); 245 $this->assertSame( '4 days, 4 hours ago', $last_time ); 151 246 } 152 247 … … 156 251 */ 157 252 public function test_bbp_get_forum_last_topic_id() { 158 $f = $this->factory->forum->create(); 159 253 $c = $this->factory->forum->create(); 254 255 $f = $this->factory->forum->create( array( 256 'post_parent' => $c, 257 'forum_meta' => array( 258 'forum_id' => $c, 259 '_bbp_forum_type' => 'forum', 260 '_bbp_status' => 'open', 261 ), 262 ) ); 263 264 // Get the forums last topic id. 160 265 $last_id = bbp_get_forum_last_topic_id( $f ); 161 266 $this->assertSame( 0, $last_id ); 162 267 268 // Get the categories last topic id. 269 $last_id = bbp_get_forum_last_topic_id( $c ); 270 $this->assertSame( 0, $last_id ); 271 163 272 bbp_update_forum_last_topic_id( $f ); 164 273 274 // Get the forums last topic id. 165 275 $last_id = bbp_get_forum_last_topic_id( $f ); 166 276 $this->assertSame( 0, $last_id ); 167 277 278 // Get the categories last topic id. 279 $last_id = bbp_get_forum_last_topic_id( $c ); 280 $this->assertSame( 0, $last_id ); 281 168 282 $t = $this->factory->topic->create( array( 169 283 'post_parent' => $f, … … 175 289 bbp_update_forum_last_topic_id( $f ); 176 290 291 // Get the forums last topic id. 177 292 $last_id = bbp_get_forum_last_topic_id( $f ); 178 293 $this->assertSame( $t, $last_id ); 294 295 // Get the categories last topic id. 296 $last_id = bbp_get_forum_last_topic_id( $c ); 297 $this->assertSame( $t, $last_id ); 179 298 } 180 299 … … 184 303 */ 185 304 public function test_bbp_get_forum_last_topic_title() { 186 $f = $this->factory->forum->create(); 305 $c = $this->factory->forum->create(); 306 307 $f = $this->factory->forum->create( array( 308 'post_parent' => $c, 309 'forum_meta' => array( 310 'forum_id' => $c, 311 '_bbp_forum_type' => 'forum', 312 '_bbp_status' => 'open', 313 ), 314 ) ); 187 315 188 316 $t = $this->factory->topic->create( array( … … 202 330 ) ); 203 331 332 // Get the forums last topic title. 204 333 $forum = bbp_get_forum_last_topic_title( $f ); 205 334 $this->assertSame( 'Topic 1', $forum ); 335 336 // Get the categories last topic title. 337 $category = bbp_get_forum_last_topic_title( $c ); 338 $this->assertSame( 'Topic 1', $category ); 206 339 } 207 340 … … 212 345 public function test_bbp_get_forum_last_topic_permalink() { 213 346 if ( is_multisite() ) { 214 $this->markTestSkipped( 'Skipping URL tests in multis te for now.' );347 $this->markTestSkipped( 'Skipping URL tests in multisite for now.' ); 215 348 } 216 349 217 $f = $this->factory->forum->create(); 350 $c = $this->factory->forum->create(); 351 352 $f = $this->factory->forum->create( array( 353 'post_parent' => $c, 354 'forum_meta' => array( 355 'forum_id' => $c, 356 '_bbp_forum_type' => 'forum', 357 '_bbp_status' => 'open', 358 ), 359 ) ); 218 360 219 361 $t = $this->factory->topic->create( array( … … 224 366 ) ); 225 367 368 // Get the forums last topic permalink. 226 369 $forum_last_topic_permalink = bbp_get_forum_last_topic_permalink( $f ); 227 370 $this->assertSame( bbp_get_topic_permalink( $t ), $forum_last_topic_permalink ); 371 372 // Get the categories last topic permalink. 373 $forum_last_topic_permalink = bbp_get_forum_last_topic_permalink( $c ); 374 $this->assertSame( bbp_get_topic_permalink( $t ), $forum_last_topic_permalink ); 228 375 } 229 376 … … 234 381 $u = $this->factory->user->create(); 235 382 236 $f = $this->factory->forum->create( array( 237 'post_author' => $u, 383 $c = $this->factory->forum->create(); 384 385 $f = $this->factory->forum->create( array( 386 'post_author' => $u, 387 'post_parent' => $c, 388 'forum_meta' => array( 389 'forum_id' => $c, 390 '_bbp_forum_type' => 'forum', 391 '_bbp_status' => 'open', 392 ), 238 393 ) ); 239 394 … … 255 410 ) ); 256 411 412 // Get the forums last author id. 257 413 $forum = bbp_get_forum_last_topic_author_id( $f ); 414 $this->assertSame( $u, $forum ); 415 416 // Get the categories last author id. 417 $forum = bbp_get_forum_last_topic_author_id( $c ); 258 418 $this->assertSame( $u, $forum ); 259 419 } … … 264 424 public function test_bbp_get_forum_last_topic_author_link() { 265 425 if ( is_multisite() ) { 266 $this->markTestSkipped( 'Skipping URL tests in multis te for now.' );426 $this->markTestSkipped( 'Skipping URL tests in multisite for now.' ); 267 427 } 268 428 269 429 $u = $this->factory->user->create(); 270 430 271 $f = $this->factory->forum->create(); 431 $c = $this->factory->forum->create(); 432 433 $f = $this->factory->forum->create( array( 434 'post_parent' => $c, 435 'forum_meta' => array( 436 'forum_id' => $c, 437 '_bbp_forum_type' => 'forum', 438 '_bbp_status' => 'open', 439 ), 440 ) ); 272 441 273 442 $t = $this->factory->topic->create( array( … … 279 448 ) ); 280 449 450 // Get the forums last topic author link. 281 451 $last_topic_author_link = bbp_get_forum_last_topic_author_link( $f ); 282 452 $this->assertSame( bbp_get_user_profile_link( $u ), $last_topic_author_link ); 453 454 // Get the categories last topic author link. 455 $last_topic_author_link = bbp_get_forum_last_topic_author_link( $c ); 456 $this->assertSame( bbp_get_user_profile_link( $u ), $last_topic_author_link ); 283 457 } 284 458 … … 288 462 */ 289 463 public function test_bbp_get_forum_last_reply_id() { 290 $f = $this->factory->forum->create(); 464 $c = $this->factory->forum->create(); 465 466 $f = $this->factory->forum->create( array( 467 'post_parent' => $c, 468 'forum_meta' => array( 469 'forum_id' => $c, 470 '_bbp_forum_type' => 'forum', 471 '_bbp_status' => 'open', 472 ), 473 ) ); 291 474 292 475 $t = $this->factory->topic->create( array( … … 305 488 ) ); 306 489 307 $last_reply_id = bbp_get_forum_last_reply_id( $f ); 308 309 $this->assertSame( $last_reply_id, bbp_forum_query_last_reply_id( $f ) ); 310 311 bbp_get_forum_last_reply_id( $f ); 490 // Get the forums last reply id. 491 $last_reply_id_f = bbp_get_forum_last_reply_id( $f ); 492 $this->assertSame( $last_reply_id_f, bbp_forum_query_last_reply_id( $f ) ); 493 494 // Get the categories last reply id. 495 $last_reply_id_c = bbp_get_forum_last_reply_id( $c ); 496 $this->assertSame( $last_reply_id_c, bbp_forum_query_last_reply_id( $c ) ); 312 497 313 498 $this->factory->reply->create( array( … … 319 504 ) ); 320 505 321 $last_reply_id = bbp_get_forum_last_reply_id( $f ); 322 323 bbp_get_forum_last_reply_id( $f ); 324 $this->assertSame( $last_reply_id, bbp_forum_query_last_reply_id( $f ) ); 325 506 // Get the forums last reply id. 507 $last_reply_id_f = bbp_get_forum_last_reply_id( $f ); 508 $this->assertSame( $last_reply_id_f, bbp_forum_query_last_reply_id( $f ) ); 509 510 // Get the categories last reply id. 511 $last_reply_id_c = bbp_get_forum_last_reply_id( $c ); 512 $this->assertSame( $last_reply_id_c, bbp_forum_query_last_reply_id( $c ) ); 326 513 } 327 514 … … 331 518 */ 332 519 public function test_bbp_get_forum_last_reply_title() { 333 $f = $this->factory->forum->create(); 520 $c = $this->factory->forum->create(); 521 522 $f = $this->factory->forum->create( array( 523 'post_parent' => $c, 524 'forum_meta' => array( 525 'forum_id' => $c, 526 '_bbp_forum_type' => 'forum', 527 '_bbp_status' => 'open', 528 ), 529 ) ); 334 530 335 531 $t = $this->factory->topic->create( array( … … 349 545 ) ); 350 546 547 // Get the forums last reply title. 351 548 $forum = bbp_get_forum_last_reply_title( $f ); 352 549 $this->assertSame( 'Reply To: Topic 1', $forum ); 550 551 // Get the categories last reply title. 552 $category = bbp_get_forum_last_reply_title( $c ); 553 $this->assertSame( 'Reply To: Topic 1', $category ); 353 554 } 354 555 … … 384 585 $u = $this->factory->user->create(); 385 586 386 $f = $this->factory->forum->create( array( 387 'post_author' => $u, 587 $c = $this->factory->forum->create(); 588 589 $f = $this->factory->forum->create( array( 590 'post_author' => $u, 591 'post_parent' => $c, 592 'forum_meta' => array( 593 'forum_id' => $c, 594 '_bbp_forum_type' => 'forum', 595 '_bbp_status' => 'open', 596 ), 388 597 ) ); 389 598 … … 405 614 ) ); 406 615 407 $last_reply_id = bbp_get_topic_last_active_id( $f ); 408 $this->assertSame( $r, $last_reply_id ); 409 616 // Get the forums last reply author id. 410 617 $forum = bbp_get_forum_last_reply_author_id( $f ); 411 618 $this->assertSame( $u, $forum ); 619 620 // Get the categories last reply author id. 621 $category = bbp_get_forum_last_reply_author_id( $c ); 622 $this->assertSame( $u, $category ); 412 623 } 413 624 … … 418 629 public function test_bbp_get_forum_last_reply_author_link() { 419 630 if ( is_multisite() ) { 420 $this->markTestSkipped( 'Skipping URL tests in multis te for now.' );631 $this->markTestSkipped( 'Skipping URL tests in multisite for now.' ); 421 632 } 422 633 423 634 $u = $this->factory->user->create(); 424 635 425 $f = $this->factory->forum->create(); 636 $c = $this->factory->forum->create(); 637 638 $f = $this->factory->forum->create( array( 639 'post_author' => $u, 640 'post_parent' => $c, 641 'forum_meta' => array( 642 'forum_id' => $c, 643 '_bbp_forum_type' => 'forum', 644 '_bbp_status' => 'open', 645 ), 646 ) ); 426 647 427 648 $t = $this->factory->topic->create( array( … … 442 663 ) ); 443 664 665 // Get the forums last reply author link. 444 666 $last_reply_author_link = bbp_get_forum_last_reply_author_link( $f ); 667 $this->assertSame( bbp_get_user_profile_link( $u ), $last_reply_author_link ); 668 669 // Get the categories last reply author link. 670 $last_reply_author_link = bbp_get_forum_last_reply_author_link( $c ); 445 671 $this->assertSame( bbp_get_user_profile_link( $u ), $last_reply_author_link ); 446 672 } … … 455 681 */ 456 682 public function test_bbp_get_forum_and_topic_last_topic_id_and_last_reply_id() { 457 458 $f = $this->factory->forum->create(); 459 460 // Get the forums last topic id _bbp_last_topic_id 683 $c = $this->factory->forum->create(); 684 685 $f = $this->factory->forum->create( array( 686 'post_parent' => $c, 687 'forum_meta' => array( 688 'forum_id' => $c, 689 '_bbp_forum_type' => 'forum', 690 '_bbp_status' => 'open', 691 ), 692 ) ); 693 694 // Get the forums last topic id _bbp_last_topic_id. 461 695 $this->assertSame( 0, bbp_get_forum_last_topic_id( $f ) ); 462 696 463 // Get the forums last reply id _bbp_last_reply_id 697 // Get the category last topic id _bbp_last_topic_id. 698 $this->assertSame( 0, bbp_get_forum_last_topic_id( $c ) ); 699 700 // Get the forums last reply id _bbp_last_reply_id. 464 701 $this->assertSame( 0, bbp_get_forum_last_reply_id( $f ) ); 465 702 703 // Get the category last reply id _bbp_last_reply_id. 704 $this->assertSame( 0, bbp_get_forum_last_reply_id( $c ) ); 705 466 706 $t = $this->factory->topic->create( array( 467 707 'post_parent' => $f, … … 471 711 ) ); 472 712 473 // Get the forums last topic id _bbp_last_topic_id 713 // Get the forums last topic id _bbp_last_topic_id. 474 714 $this->assertSame( $t, bbp_get_forum_last_topic_id( $f ) ); 475 715 476 // Get the topics last reply id _bbp_last_reply_id477 $this->assertSame( 0, bbp_get_topic_last_reply_id( $t) );478 479 // Create another reply 716 // Get the category last topic id _bbp_last_topic_id. 717 $this->assertSame( $t, bbp_get_forum_last_topic_id( $c ) ); 718 719 // Create another reply. 480 720 $r = $this->factory->reply->create( array( 481 721 'post_parent' => $t, … … 486 726 ) ); 487 727 488 // Get the forums last reply id _bbp_last_reply_id 728 // Get the forums last reply id _bbp_last_reply_id. 489 729 $this->assertSame( $r, bbp_get_forum_last_reply_id( $f ) ); 490 730 491 // Get the topics last reply id _bbp_last_reply_id 731 // Get the category last reply id _bbp_last_reply_id. 732 $this->assertSame( $r, bbp_get_forum_last_reply_id( $c ) ); 733 734 // Get the topics last reply id _bbp_last_reply_id. 492 735 $this->assertSame( $r, bbp_get_topic_last_reply_id( $t ) ); 493 736 }
Note: See TracChangeset
for help on using the changeset viewer.