[ Index ]

PHP Cross Reference of BBPress

title

Body

[close]

/tests/phpunit/testcases/forums/template/ -> get-last-thing.php (source)

   1  <?php
   2  
   3  /**
   4   * Tests for the `bbp_get_forum_last_*()` template functions.
   5   *
   6   * @group forums
   7   * @group template
   8   * @group get_last_thing
   9   */
  10  class BBP_Tests_Forums_Template_Forum_Last_Thing extends BBP_UnitTestCase {
  11  
  12      /**
  13       * @covers ::bbp_forum_last_active_id
  14       * @covers ::bbp_get_forum_last_active_id
  15       */
  16  	public function test_bbp_get_forum_last_active_id() {
  17          $c = $this->factory->forum->create( array(
  18              'forum_meta' => array(
  19                  'forum_type' => 'category',
  20                  'status'     => 'open',
  21              ),
  22          ) );
  23  
  24          $f = $this->factory->forum->create( array(
  25              'post_parent' => $c,
  26              'forum_meta' => array(
  27                  'forum_id'   => $c,
  28                  'forum_type' => 'forum',
  29                  'status'     => 'open',
  30              ),
  31          ) );
  32  
  33          // Get the forums last active id.
  34          $last_id = bbp_get_forum_last_active_id( $f );
  35          $this->assertSame( 0, $last_id );
  36  
  37          // Get the categories last active id.
  38          $last_id = bbp_get_forum_last_active_id( $c );
  39          $this->assertSame( 0, $last_id );
  40  
  41          bbp_update_forum_last_active_id( $f );
  42  
  43          // Get the forums last active id.
  44          $last_id = bbp_get_forum_last_active_id( $f );
  45          $this->assertSame( 0, $last_id );
  46  
  47          // Get the categories last active id.
  48          $last_id = bbp_get_forum_last_active_id( $c );
  49          $this->assertSame( 0, $last_id );
  50  
  51          $t = $this->factory->topic->create( array(
  52              'post_parent' => $f,
  53              'topic_meta' => array(
  54                  'forum_id' => $f,
  55              ),
  56          ) );
  57  
  58          bbp_update_forum_last_active_id( $f );
  59  
  60          // Get the forums last active id.
  61          $last_id = bbp_get_forum_last_active_id( $f );
  62          $this->assertSame( $t, $last_id );
  63  
  64          // Get the categories last active id.
  65          $last_id = bbp_get_forum_last_active_id( $c );
  66          $this->assertSame( $t, $last_id );
  67  
  68          $r = $this->factory->reply->create( array(
  69              'post_parent' => $t,
  70              'reply_meta' => array(
  71                  'forum_id' => $f,
  72                  'topic_id' => $t,
  73              ),
  74          ) );
  75  
  76          bbp_update_forum_last_active_id( $f );
  77  
  78          // Get the forums last active id.
  79          $last_id = bbp_get_forum_last_active_id( $f );
  80          $this->assertSame( $r, $last_id );
  81  
  82          // Get the categories last active id.
  83          $last_id = bbp_get_forum_last_active_id( $c );
  84          $this->assertSame( $r, $last_id );
  85      }
  86  
  87      /**
  88       * @covers ::bbp_forum_last_active_id
  89       * @covers ::bbp_get_forum_last_active_id
  90       */
  91      public function test_bbp_get_forum_last_active_id_with_pending_reply() {
  92          $u = $this->factory->user->create_many( 2 );
  93  
  94          $c = $this->factory->forum->create( array(
  95              'forum_meta' => array(
  96                  'forum_type' => 'category',
  97                  'status'     => 'open',
  98              ),
  99          ) );
 100  
 101  
 102          $f = $this->factory->forum->create( array(
 103              'post_parent' => $c,
 104              'forum_meta' => array(
 105                  'forum_id'   => $c,
 106                  'forum_type' => 'forum',
 107                  'status'     => 'open',
 108              ),
 109          ) );
 110  
 111          // Get the forums last active id.
 112          $last_id = bbp_get_forum_last_active_id( $f );
 113          $this->assertSame( 0, $last_id );
 114  
 115          // Get the categories last active id.
 116          $last_id = bbp_get_forum_last_active_id( $c );
 117          $this->assertSame( 0, $last_id );
 118  
 119          bbp_update_forum_last_active_id( $f );
 120  
 121          // Get the forums last active id.
 122          $last_id = bbp_get_forum_last_active_id( $f );
 123          $this->assertSame( 0, $last_id );
 124  
 125          // Get the categories last active id.
 126          $last_id = bbp_get_forum_last_active_id( $c );
 127          $this->assertSame( 0, $last_id );
 128  
 129          $t = $this->factory->topic->create( array(
 130              'post_parent' => $f,
 131              'topic_meta' => array(
 132                  'forum_id' => $f,
 133              ),
 134          ) );
 135  
 136          bbp_update_forum_last_active_id( $f );
 137  
 138          // Get the forums last active id.
 139          $last_id = bbp_get_forum_last_active_id( $f );
 140          $this->assertSame( $t, $last_id );
 141  
 142          // Get the categories last active id.
 143          $last_id = bbp_get_forum_last_active_id( $c );
 144          $this->assertSame( $t, $last_id );
 145  
 146          $r1 = $this->factory->reply->create( array(
 147              'post_parent' => $t,
 148              'reply_meta' => array(
 149                  'forum_id' => $f,
 150                  'topic_id' => $t,
 151              ),
 152          ) );
 153  
 154          bbp_update_forum_last_active_id( $f );
 155  
 156          // Get the forums last active id.
 157          $last_id = bbp_get_forum_last_active_id( $f );
 158          $this->assertSame( $r1, $last_id );
 159  
 160          // Get the categories last active id.
 161          $last_id = bbp_get_forum_last_active_id( $c );
 162  
 163          $this->assertSame( $r1, $last_id );
 164  
 165          $r2 = $this->factory->reply->create( array(
 166              'post_parent' => $t,
 167              'post_author' => $u[1],
 168              'post_status' => bbp_get_pending_status_id(),
 169              'reply_meta' => array(
 170                  'forum_id' => $f,
 171                  'topic_id' => $t,
 172              )
 173          ) );
 174  
 175          // Get the forums last active id.
 176          $last_id = bbp_get_forum_last_active_id( $f );
 177          $this->assertSame( $r1, $last_id );
 178  
 179          // Get the categories last active id.
 180          $last_id = bbp_get_forum_last_active_id( $c );
 181          $this->assertSame( $r1, $last_id );
 182  
 183          bbp_approve_reply( $r2 );
 184  
 185          // Get the forums last active id.
 186          $last_id = bbp_get_forum_last_active_id( $f );
 187          $this->assertSame( $r2, $last_id );
 188  
 189          // Get the categories last active id.
 190          $last_id = bbp_get_forum_last_active_id( $c );
 191          $this->assertSame( $r2, $last_id );
 192      }
 193  
 194      /**
 195       * @covers ::bbp_forum_last_active_time
 196       * @covers ::bbp_get_forum_last_active_time
 197       */
 198  	public function test_bbp_get_forum_last_active_time() {
 199          $c = $this->factory->forum->create( array(
 200              'forum_meta' => array(
 201                  'forum_type' => 'category',
 202                  'status'     => 'open',
 203              ),
 204          ) );
 205  
 206  
 207          $f = $this->factory->forum->create( array(
 208              'post_parent' => $c,
 209              'forum_meta' => array(
 210                  'forum_id'   => $c,
 211                  'forum_type' => 'forum',
 212                  'status'     => 'open',
 213              ),
 214          ) );
 215  
 216          $now = time();
 217          $post_date = date( 'Y-m-d H:i:s', $now - 60 * 60 * 100 );
 218  
 219          // Get the forums last active time.
 220          $last_time = bbp_get_forum_last_active_time( $f );
 221          $this->assertSame( '', $last_time );
 222  
 223          // Get the categories last active time.
 224          $last_time = bbp_get_forum_last_active_time( $c );
 225          $this->assertSame( '', $last_time );
 226  
 227          $t = $this->factory->topic->create( array(
 228              'post_parent' => $f,
 229              'post_date' => $post_date,
 230              'topic_meta' => array(
 231                  'forum_id' => $f,
 232              ),
 233          ) );
 234  
 235          bbp_update_forum_last_active_time( $f );
 236  
 237          // Get the forums last active time.
 238          $last_time = bbp_get_forum_last_active_time( $f );
 239          $this->assertSame( '4 days, 4 hours ago', $last_time );
 240  
 241          // Get the categories last active time.
 242          $last_time = bbp_get_forum_last_active_time( $c );
 243          $this->assertSame( '4 days, 4 hours ago', $last_time );
 244  
 245          $this->factory->reply->create( array(
 246              'post_parent' => $t,
 247              'post_date' => $post_date,
 248              'reply_meta' => array(
 249                  'forum_id' => $f,
 250                  'topic_id' => $t,
 251              ),
 252          ) );
 253  
 254          bbp_update_forum_last_active_time( $f );
 255  
 256          // Get the forums last active time.
 257          $last_time = bbp_get_forum_last_active_time( $f );
 258          $this->assertSame( '4 days, 4 hours ago', $last_time );
 259  
 260          // Get the categories last active time.
 261          $last_time = bbp_get_forum_last_active_time( $c );
 262          $this->assertSame( '4 days, 4 hours ago', $last_time );
 263      }
 264  
 265      /**
 266       * @covers ::bbp_forum_last_topic_id
 267       * @covers ::bbp_get_forum_last_topic_id
 268       */
 269  	public function test_bbp_get_forum_last_topic_id() {
 270          $c = $this->factory->forum->create( array(
 271              'forum_meta' => array(
 272                  'forum_type' => 'category',
 273                  'status'     => 'open',
 274              ),
 275          ) );
 276  
 277  
 278          $f = $this->factory->forum->create( array(
 279              'post_parent' => $c,
 280              'forum_meta' => array(
 281                  'forum_id'        => $c,
 282                  'forum_type' => 'forum',
 283                  'status'     => 'open',
 284              ),
 285          ) );
 286  
 287          // Get the forums last topic id.
 288          $last_id = bbp_get_forum_last_topic_id( $f );
 289          $this->assertSame( 0, $last_id );
 290  
 291          // Get the categories last topic id.
 292          $last_id = bbp_get_forum_last_topic_id( $c );
 293          $this->assertSame( 0, $last_id );
 294  
 295          bbp_update_forum_last_topic_id( $f );
 296  
 297          // Get the forums last topic id.
 298          $last_id = bbp_get_forum_last_topic_id( $f );
 299          $this->assertSame( 0, $last_id );
 300  
 301          // Get the categories last topic id.
 302          $last_id = bbp_get_forum_last_topic_id( $c );
 303          $this->assertSame( 0, $last_id );
 304  
 305          $t = $this->factory->topic->create( array(
 306              'post_parent' => $f,
 307              'topic_meta' => array(
 308                  'forum_id' => $f,
 309              ),
 310          ) );
 311  
 312          bbp_update_forum_last_topic_id( $f );
 313  
 314          // Get the forums last topic id.
 315          $last_id = bbp_get_forum_last_topic_id( $f );
 316          $this->assertSame( $t, $last_id );
 317  
 318          // Get the categories last topic id.
 319          $last_id = bbp_get_forum_last_topic_id( $c );
 320          $this->assertSame( $t, $last_id );
 321      }
 322  
 323      /**
 324       * @covers ::bbp_forum_last_topic_title
 325       * @covers ::bbp_get_forum_last_topic_title
 326       */
 327  	public function test_bbp_get_forum_last_topic_title() {
 328          $c = $this->factory->forum->create( array(
 329              'forum_meta' => array(
 330                  'forum_type' => 'category',
 331                  'status'     => 'open',
 332              ),
 333          ) );
 334  
 335  
 336          $f = $this->factory->forum->create( array(
 337              'post_parent' => $c,
 338              'forum_meta' => array(
 339                  'forum_id'        => $c,
 340                  'forum_type' => 'forum',
 341                  'status'     => 'open',
 342              ),
 343          ) );
 344  
 345          $t = $this->factory->topic->create( array(
 346              'post_title' => 'Topic 1',
 347              'post_parent' => $f,
 348              'topic_meta' => array(
 349                  'forum_id' => $f,
 350              ),
 351          ) );
 352  
 353          $this->factory->reply->create( array(
 354              'post_parent' => $t,
 355              'reply_meta' => array(
 356                  'forum_id' => $f,
 357                  'topic_id' => $t,
 358              ),
 359          ) );
 360  
 361          // Get the forums last topic title.
 362          $forum = bbp_get_forum_last_topic_title( $f );
 363          $this->assertSame( 'Topic 1', $forum );
 364  
 365          // Get the categories last topic title.
 366          $category = bbp_get_forum_last_topic_title( $c );
 367          $this->assertSame( 'Topic 1', $category );
 368      }
 369  
 370      /**
 371       * @covers ::bbp_forum_last_topic_permalink
 372       * @covers ::bbp_get_forum_last_topic_permalink
 373       */
 374  	public function test_bbp_get_forum_last_topic_permalink() {
 375          if ( is_multisite() ) {
 376              $this->markTestSkipped( 'Skipping URL tests in multisite for now.' );
 377          }
 378  
 379          $c = $this->factory->forum->create( array(
 380              'forum_meta' => array(
 381                  'forum_type' => 'category',
 382                  'status'     => 'open',
 383              ),
 384          ) );
 385  
 386  
 387          $f = $this->factory->forum->create( array(
 388              'post_parent' => $c,
 389              'forum_meta' => array(
 390                  'forum_id'   => $c,
 391                  'forum_type' => 'forum',
 392                  'status'     => 'open',
 393              ),
 394          ) );
 395  
 396          $t = $this->factory->topic->create( array(
 397              'post_parent' => $f,
 398              'topic_meta' => array(
 399                  'forum_id' => $f,
 400              )
 401          ) );
 402  
 403          // Get the forums last topic permalink.
 404          $forum_last_topic_permalink = bbp_get_forum_last_topic_permalink( $f );
 405          $this->assertSame( bbp_get_topic_permalink( $t ), $forum_last_topic_permalink );
 406  
 407          // Get the categories last topic permalink.
 408          $forum_last_topic_permalink = bbp_get_forum_last_topic_permalink( $c );
 409          $this->assertSame( bbp_get_topic_permalink( $t ), $forum_last_topic_permalink );
 410      }
 411  
 412      /**
 413       * @covers ::bbp_get_forum_last_topic_author_id
 414       */
 415  	public function test_bbp_get_forum_last_topic_author_id() {
 416          $u = $this->factory->user->create();
 417  
 418          $c = $this->factory->forum->create( array(
 419              'forum_meta' => array(
 420                  'forum_type' => 'category',
 421                  'status'     => 'open',
 422              ),
 423          ) );
 424  
 425  
 426          $f = $this->factory->forum->create( array(
 427              'post_author' => $u,
 428              'post_parent' => $c,
 429              'forum_meta' => array(
 430                  'forum_id'   => $c,
 431                  'forum_type' => 'forum',
 432                  'status'     => 'open',
 433              ),
 434          ) );
 435  
 436          $t = $this->factory->topic->create( array(
 437              'post_parent' => $f,
 438              'post_author' => $u,
 439              'topic_meta' => array(
 440                  'forum_id' => $f,
 441              ),
 442          ) );
 443  
 444          $this->factory->reply->create( array(
 445              'post_parent' => $t,
 446              'post_author' => $u,
 447              'reply_meta' => array(
 448                  'forum_id' => $f,
 449                  'topic_id' => $t,
 450              ),
 451          ) );
 452  
 453          // Get the forums last author id.
 454          $forum = bbp_get_forum_last_topic_author_id( $f );
 455          $this->assertSame( $u, $forum );
 456  
 457          // Get the categories last author id.
 458          $forum = bbp_get_forum_last_topic_author_id( $c );
 459          $this->assertSame( $u, $forum );
 460      }
 461  
 462      /**
 463       * @covers ::bbp_forum_last_topic_author_link
 464       * @covers ::bbp_get_forum_last_topic_author_link     */
 465  	public function test_bbp_get_forum_last_topic_author_link() {
 466          if ( is_multisite() ) {
 467              $this->markTestSkipped( 'Skipping URL tests in multisite for now.' );
 468          }
 469  
 470          $u = $this->factory->user->create();
 471  
 472          $c = $this->factory->forum->create( array(
 473              'forum_meta' => array(
 474                  'forum_type' => 'category',
 475                  'status'     => 'open',
 476              ),
 477          ) );
 478  
 479  
 480          $f = $this->factory->forum->create( array(
 481              'post_parent' => $c,
 482              'forum_meta' => array(
 483                  'forum_id'   => $c,
 484                  'forum_type' => 'forum',
 485                  'status'     => 'open',
 486              ),
 487          ) );
 488  
 489          $t = $this->factory->topic->create( array(
 490              'post_parent' => $f,
 491              'post_author' => $u,
 492              'topic_meta' => array(
 493                  'forum_id' => $f,
 494              )
 495          ) );
 496  
 497          // Get the forums last topic author link.
 498          $last_topic_author_link = bbp_get_forum_last_topic_author_link( $f );
 499          $this->assertSame( bbp_get_user_profile_link( $u ), $last_topic_author_link );
 500  
 501          // Get the categories last topic author link.
 502          $last_topic_author_link = bbp_get_forum_last_topic_author_link( $c );
 503          $this->assertSame( bbp_get_user_profile_link( $u ), $last_topic_author_link );
 504      }
 505  
 506      /**
 507       * @covers ::bbp_forum_last_reply_id
 508       * @covers ::bbp_get_forum_last_reply_id
 509       */
 510  	public function test_bbp_get_forum_last_reply_id() {
 511          $c = $this->factory->forum->create( array(
 512              'forum_meta' => array(
 513                  'forum_type' => 'category',
 514                  'status'     => 'open',
 515              ),
 516          ) );
 517  
 518          $f = $this->factory->forum->create( array(
 519              'post_parent' => $c,
 520              'forum_meta' => array(
 521                  'forum_id'   => $c,
 522                  'forum_type' => 'forum',
 523                  'status'     => 'open',
 524              ),
 525          ) );
 526  
 527          $t = $this->factory->topic->create( array(
 528              'post_parent' => $f,
 529              'topic_meta' => array(
 530                  'forum_id' => $f,
 531              ),
 532          ) );
 533  
 534          $r1 = $this->factory->reply->create( array(
 535              'post_parent' => $t,
 536              'reply_meta' => array(
 537                  'forum_id' => $f,
 538                  'topic_id' => $t,
 539              ),
 540          ) );
 541  
 542          // Get the forums last reply id.
 543          $last_reply_id_f = bbp_get_forum_last_reply_id( $f );
 544          $this->assertSame( $r1, $last_reply_id_f );
 545  
 546          // Get the categories last reply id.
 547          $last_reply_id_c = bbp_get_forum_last_reply_id( $c );
 548          $this->assertSame( $r1, $last_reply_id_c );
 549  
 550          $r2 = $this->factory->reply->create( array(
 551              'post_parent' => $t,
 552              'reply_meta' => array(
 553                  'forum_id' => $f,
 554                  'topic_id' => $t,
 555              ),
 556          ) );
 557  
 558          // Get the forums last reply id.
 559          $last_reply_id_f = bbp_get_forum_last_reply_id( $f );
 560          $this->assertSame( $r2, $last_reply_id_f );
 561  
 562          // Get the categories last reply id.
 563          $last_reply_id_c = bbp_get_forum_last_reply_id( $c );
 564          $this->assertSame( $r2, $last_reply_id_c );
 565      }
 566  
 567      /**
 568       * @covers ::bbp_forum_last_reply_title
 569       * @covers ::bbp_get_forum_last_reply_title
 570       */
 571  	public function test_bbp_get_forum_last_reply_title() {
 572          $c = $this->factory->forum->create( array(
 573              'forum_meta' => array(
 574                  'forum_type' => 'category',
 575                  'status'     => 'open',
 576              ),
 577          ) );
 578  
 579  
 580          $f = $this->factory->forum->create( array(
 581              'post_parent' => $c,
 582              'forum_meta' => array(
 583                  'forum_id'   => $c,
 584                  'forum_type' => 'forum',
 585                  'status'     => 'open',
 586              ),
 587          ) );
 588  
 589          $t = $this->factory->topic->create( array(
 590              'post_parent' => $f,
 591              'topic_meta' => array(
 592                  'forum_id' => $f,
 593              ),
 594          ) );
 595  
 596          $this->factory->reply->create( array(
 597              'post_title' => 'Reply To: Topic 1',
 598              'post_parent' => $t,
 599              'reply_meta' => array(
 600                  'forum_id' => $f,
 601                  'topic_id' => $t,
 602              ),
 603          ) );
 604  
 605          // Get the forums last reply title.
 606          $forum = bbp_get_forum_last_reply_title( $f );
 607          $this->assertSame( 'Reply To: Topic 1', $forum );
 608  
 609          // Get the categories last reply title.
 610          $category = bbp_get_forum_last_reply_title( $c );
 611          $this->assertSame( 'Reply To: Topic 1', $category );
 612      }
 613  
 614      /**
 615       * @covers ::bbp_forum_last_reply_permalink
 616       * @covers ::bbp_get_forum_last_reply_permalink
 617       * @todo   Implement test_bbp_get_forum_last_reply_permalink().
 618       */
 619  	public function test_bbp_get_forum_last_reply_permalink() {
 620          // Remove the following lines when you implement this test.
 621          $this->markTestIncomplete(
 622              'This test has not been implemented yet.'
 623          );
 624      }
 625  
 626      /**
 627       * @covers ::bbp_forum_last_reply_url
 628       * @covers ::bbp_get_forum_last_reply_url
 629       * @todo   Implement test_bbp_get_forum_last_reply_url().
 630       */
 631  	public function test_bbp_get_forum_last_reply_url() {
 632          // Remove the following lines when you implement this test.
 633          $this->markTestIncomplete(
 634              'This test has not been implemented yet.'
 635          );
 636      }
 637  
 638      /**
 639       * @covers ::bbp_forum_last_reply_author_id
 640       * @covers ::bbp_get_forum_last_reply_author_id
 641       */
 642  	public function test_bbp_get_forum_last_reply_author_id() {
 643          $u = $this->factory->user->create();
 644  
 645          $c = $this->factory->forum->create( array(
 646              'forum_meta' => array(
 647                  'forum_type' => 'category',
 648                  'status'     => 'open',
 649              ),
 650          ) );
 651  
 652  
 653          $f = $this->factory->forum->create( array(
 654              'post_author' => $u,
 655              'post_parent' => $c,
 656              'forum_meta' => array(
 657                  'forum_id'   => $c,
 658                  'forum_type' => 'forum',
 659                  'status'     => 'open',
 660              ),
 661          ) );
 662  
 663          $t = $this->factory->topic->create( array(
 664              'post_parent' => $f,
 665              'post_author' => $u,
 666              'topic_meta' => array(
 667                  'forum_id' => $f,
 668              ),
 669          ) );
 670  
 671          $r = $this->factory->reply->create( array(
 672              'post_parent' => $t,
 673              'post_author' => $u,
 674              'reply_meta' => array(
 675                  'forum_id' => $f,
 676                  'topic_id' => $t,
 677              ),
 678          ) );
 679  
 680          // Get the forums last reply author id.
 681          $forum = bbp_get_forum_last_reply_author_id( $f );
 682          $this->assertSame( $u, $forum );
 683  
 684          // Get the categories last reply author id.
 685          $category = bbp_get_forum_last_reply_author_id( $c );
 686          $this->assertSame( $u, $category );
 687      }
 688  
 689      /**
 690       * @covers ::bbp_forum_last_reply_author_link
 691       * @covers ::bbp_get_forum_last_reply_author_link
 692       */
 693  	public function test_bbp_get_forum_last_reply_author_link() {
 694          if ( is_multisite() ) {
 695              $this->markTestSkipped( 'Skipping URL tests in multisite for now.' );
 696          }
 697  
 698          $u = $this->factory->user->create();
 699  
 700          $c = $this->factory->forum->create( array(
 701              'forum_meta' => array(
 702                  'forum_type' => 'category',
 703                  'status'     => 'open',
 704              ),
 705          ) );
 706  
 707  
 708          $f = $this->factory->forum->create( array(
 709              'post_author' => $u,
 710              'post_parent' => $c,
 711              'forum_meta' => array(
 712                  'forum_id'   => $c,
 713                  'forum_type' => 'forum',
 714                  'status'     => 'open',
 715              ),
 716          ) );
 717  
 718          $t = $this->factory->topic->create( array(
 719              'post_parent' => $f,
 720              'post_author' => $u,
 721              'topic_meta' => array(
 722                  'forum_id' => $f,
 723              )
 724          ) );
 725  
 726          $r = $this->factory->reply->create( array(
 727              'post_parent' => $t,
 728              'post_author' => $u,
 729              'reply_meta' => array(
 730                  'forum_id' => $f,
 731                  'topic_id' => $t,
 732              ),
 733          ) );
 734  
 735          // Get the forums last reply author link.
 736          $last_reply_author_link = bbp_get_forum_last_reply_author_link( $f );
 737          $this->assertSame( bbp_get_user_profile_link( $u ), $last_reply_author_link );
 738  
 739          // Get the categories last reply author link.
 740          $last_reply_author_link = bbp_get_forum_last_reply_author_link( $c );
 741          $this->assertSame( bbp_get_user_profile_link( $u ), $last_reply_author_link );
 742      }
 743  
 744      /**
 745       * @covers ::bbp_forum_last_topic_id
 746       * @covers ::bbp_get_forum_last_topic_id
 747       * @covers ::bbp_forum_last_reply_id
 748       * @covers ::bbp_get_forum_last_reply_id
 749       * @covers ::bbp_topic_last_reply_id
 750       * @covers ::bbp_get_topic_last_reply_id
 751       */
 752      public function test_bbp_get_forum_and_topic_last_topic_id_and_last_reply_id() {
 753          $c = $this->factory->forum->create( array(
 754              'forum_meta' => array(
 755                  'forum_type' => 'category',
 756                  'status'     => 'open',
 757              ),
 758          ) );
 759  
 760  
 761          $f = $this->factory->forum->create( array(
 762              'post_parent' => $c,
 763              'forum_meta' => array(
 764                  'forum_id'   => $c,
 765                  'forum_type' => 'forum',
 766                  'status'     => 'open',
 767              ),
 768          ) );
 769  
 770          // Get the forums last topic id _bbp_last_topic_id.
 771          $this->assertSame( 0, bbp_get_forum_last_topic_id( $f ) );
 772  
 773          // Get the category last topic id _bbp_last_topic_id.
 774          $this->assertSame( 0, bbp_get_forum_last_topic_id( $c ) );
 775  
 776          // Get the forums last reply id _bbp_last_reply_id.
 777          $this->assertSame( 0, bbp_get_forum_last_reply_id( $f ) );
 778  
 779          // Get the category last reply id _bbp_last_reply_id.
 780          $this->assertSame( 0, bbp_get_forum_last_reply_id( $c ) );
 781  
 782          $t = $this->factory->topic->create( array(
 783              'post_parent' => $f,
 784              'topic_meta' => array(
 785                  'forum_id' => $f,
 786              )
 787          ) );
 788  
 789          // Get the forums last topic id _bbp_last_topic_id.
 790          $this->assertSame( $t, bbp_get_forum_last_topic_id( $f ) );
 791  
 792          // Get the category last topic id _bbp_last_topic_id.
 793          $this->assertSame( $t, bbp_get_forum_last_topic_id( $c ) );
 794  
 795          // Create another reply.
 796          $r = $this->factory->reply->create( array(
 797              'post_parent' => $t,
 798              'reply_meta' => array(
 799                  'forum_id' => $f,
 800                  'topic_id' => $t,
 801              )
 802          ) );
 803  
 804          // Get the forums last reply id _bbp_last_reply_id.
 805          $this->assertSame( $r, bbp_get_forum_last_reply_id( $f ) );
 806  
 807          // Get the category last reply id _bbp_last_reply_id.
 808          $this->assertSame( $r, bbp_get_forum_last_reply_id( $c ) );
 809  
 810          // Get the topics last reply id _bbp_last_reply_id.
 811          $this->assertSame( $r, bbp_get_topic_last_reply_id( $t ) );
 812      }
 813  }


Generated: Fri Oct 18 01:01:25 2019 Cross-referenced by PHPXref 0.7.1