[ Index ]

PHP Cross Reference of BBPress

title

Body

[close]

/tests/phpunit/testcases/topics/functions/ -> status.php (source)

   1  <?php
   2  
   3  /**
   4   * Tests for the topic component statuses and types functions.
   5   *
   6   * @group topics
   7   * @group functions
   8   * @group status
   9   */
  10  class BBP_Tests_Topics_Functions_Status extends BBP_UnitTestCase {
  11  
  12      /**
  13       * @covers ::bbp_get_topic_statuses
  14       * @todo   Implement test_bbp_get_topic_statuses().
  15       */
  16  	public function test_bbp_get_topic_statuses() {
  17          // Remove the following lines when you implement this test.
  18          $this->markTestIncomplete(
  19              'This test has not been implemented yet.'
  20          );
  21      }
  22  
  23      /**
  24       * @covers ::bbp_get_topic_types
  25       * @todo   Implement test_bbp_get_topic_types().
  26       */
  27  	public function test_bbp_get_topic_types() {
  28          // Remove the following lines when you implement this test.
  29          $this->markTestIncomplete(
  30              'This test has not been implemented yet.'
  31          );
  32      }
  33  
  34      /**
  35       * @covers ::bbp_get_stickies
  36       * @todo   Implement test_bbp_get_stickies().
  37       */
  38  	public function test_bbp_get_stickies() {
  39          // Remove the following lines when you implement this test.
  40          $this->markTestIncomplete(
  41              'This test has not been implemented yet.'
  42          );
  43      }
  44  
  45      /**
  46       * @covers ::bbp_get_super_stickies
  47       * @todo   Implement test_bbp_get_super_stickies().
  48       */
  49  	public function test_bbp_get_super_stickies() {
  50          // Remove the following lines when you implement this test.
  51          $this->markTestIncomplete(
  52              'This test has not been implemented yet.'
  53          );
  54      }
  55  
  56      /**
  57       * @covers ::bbp_close_topic
  58       * @todo   Implement test_bbp_close_topic().
  59       */
  60  	public function test_bbp_close_topic() {
  61          // Remove the following lines when you implement this test.
  62          $this->markTestIncomplete(
  63              'This test has not been implemented yet.'
  64          );
  65      }
  66  
  67      /**
  68       * @covers ::bbp_open_topic
  69       * @todo   Implement test_bbp_open_topic().
  70       */
  71  	public function test_bbp_open_topic() {
  72          // Remove the following lines when you implement this test.
  73          $this->markTestIncomplete(
  74              'This test has not been implemented yet.'
  75          );
  76      }
  77  
  78      /**
  79       * @covers ::bbp_spam_topic
  80       */
  81  	public function test_bbp_spam_topic() {
  82          $f = $this->factory->forum->create();
  83  
  84          $now = time();
  85          $post_date_topic = date( 'Y-m-d H:i:s', $now - 60 * 60 * 100 );
  86          $post_date_reply = date( 'Y-m-d H:i:s', $now - 60 * 60 * 80 );
  87  
  88          $topic_time = '4 days, 4 hours ago';
  89          $reply_time = '3 days, 8 hours ago';
  90  
  91          $t = $this->factory->topic->create( array(
  92              'post_parent' => $f,
  93              'post_date' => $post_date_topic,
  94              'topic_meta' => array(
  95                  'forum_id' => $f,
  96              ),
  97          ) );
  98          $r = $this->factory->reply->create_many( 2, array(
  99              'post_parent' => $t,
 100              'post_date' => $post_date_reply,
 101              'reply_meta' => array(
 102                  'forum_id' => $f,
 103                  'topic_id' => $t,
 104              ),
 105          ) );
 106  
 107          bbp_spam_topic( $t );
 108  
 109          $count = bbp_get_forum_topic_count( $f, false, true );
 110          $this->assertSame( 0, $count );
 111  
 112          $count = bbp_get_forum_topic_count_hidden( $f, true );
 113          $this->assertSame( 1, $count );
 114  
 115          $count = bbp_get_forum_reply_count( $f, false, true );
 116          $this->assertSame( 0, $count );
 117  
 118          $last_topic_id = bbp_get_forum_last_topic_id( $f );
 119          $this->assertSame( $t, $last_topic_id );
 120  
 121          $last_reply_id = bbp_get_forum_last_reply_id( $f );
 122          $this->assertSame( $t, $last_reply_id );
 123  
 124          $last_active_id = bbp_get_forum_last_active_id( $f );
 125          $this->assertSame( $t, $last_active_id );
 126  
 127          $last_active_time = bbp_get_forum_last_active_time( $f );
 128          $this->assertSame( $topic_time, $last_active_time );
 129  
 130          $count = bbp_get_topic_reply_count( $t, true, true );
 131          $this->assertSame( 0, $count );
 132  
 133          $count = bbp_get_topic_reply_count_hidden( $t, true, true );
 134          $this->assertSame( 2, $count );
 135  
 136          // ToDo: Result should be 0 when a topic has no replies
 137      //    $last_reply_id = bbp_get_topic_last_reply_id( $t );
 138      //    $this->assertSame( $t, $last_reply_id );
 139  
 140          $last_active_id = bbp_get_topic_last_active_id( $t );
 141          $this->assertSame( $t, $last_active_id );
 142  
 143          $last_active_time = bbp_get_topic_last_active_time( $t );
 144          $this->assertSame( $topic_time, $last_active_time );
 145  
 146          $topic_spam_status = get_post_status( $t );
 147          $this->assertSame( bbp_get_spam_status_id(), $topic_spam_status );
 148  
 149          $topic_meta_pre_spammed_replies = get_post_meta( $t, '_bbp_pre_spammed_replies', true );
 150          $this->assertEqualSets( array( $r[1], $r[0] ), $topic_meta_pre_spammed_replies );
 151  
 152          $topic_spam_meta_status = get_post_meta( $t, '_bbp_spam_meta_status', true );
 153          $this->assertSame( bbp_get_public_status_id(), $topic_spam_meta_status );
 154      }
 155  
 156      /**
 157       * @covers ::bbp_spam_topic_replies
 158       */
 159  	public function test_bbp_spam_topic_replies() {
 160          $f = $this->factory->forum->create();
 161  
 162          $now = time();
 163          $post_date_topic = date( 'Y-m-d H:i:s', $now - 60 * 60 * 100 );
 164          $post_date_reply = date( 'Y-m-d H:i:s', $now - 60 * 60 * 80 );
 165  
 166          $topic_time = '4 days, 4 hours ago';
 167          $reply_time = '3 days, 8 hours ago';
 168  
 169          $t = $this->factory->topic->create( array(
 170              'post_parent' => $f,
 171              'post_date' => $post_date_topic,
 172              'topic_meta' => array(
 173                  'forum_id' => $f,
 174              ),
 175          ) );
 176          $r = $this->factory->reply->create_many( 2, array(
 177              'post_parent' => $t,
 178              'post_date' => $post_date_reply,
 179              'reply_meta' => array(
 180                  'forum_id' => $f,
 181                  'topic_id' => $t,
 182              ),
 183          ) );
 184  
 185          bbp_spam_topic_replies( $t );
 186  
 187          $count = bbp_get_forum_reply_count( $f, false, true );
 188          $this->assertSame( 0, $count );
 189  
 190          $last_reply_id = bbp_get_forum_last_reply_id( $f );
 191          $this->assertSame( $t, $last_reply_id );
 192  
 193          $last_active_id = bbp_get_forum_last_active_id( $f );
 194          $this->assertSame( $t, $last_active_id );
 195  
 196          // ToDo: Result should be topic time when a topic has no replies
 197      //    $last_active_time = bbp_get_forum_last_active_time( $f );
 198      //    $this->assertSame( $topic_time, $last_active_time );
 199  
 200          $count = bbp_get_topic_reply_count( $t, true, true );
 201          $this->assertSame( 0, $count );
 202  
 203          $count = bbp_get_topic_reply_count_hidden( $t, true, true );
 204          $this->assertSame( 2, $count );
 205  
 206          // ToDo: Result should be 0 when a topic has no replies
 207      //    $last_reply_id = bbp_get_topic_last_reply_id( $t );
 208      //    $this->assertSame( $t, $last_reply_id );
 209  
 210          $last_active_id = bbp_get_topic_last_active_id( $t );
 211          $this->assertSame( $t, $last_active_id );
 212  
 213          $last_active_time = bbp_get_topic_last_active_time( $t );
 214          $this->assertSame( $topic_time, $last_active_time );
 215  
 216          $topic_meta_pre_spammed_replies = get_post_meta( $t, '_bbp_pre_spammed_replies', true );
 217          $this->assertEqualSets( array( $r[1], $r[0] ), $topic_meta_pre_spammed_replies );
 218  
 219          foreach ( $r as $reply ) {
 220              $reply_status = get_post_status( $reply );
 221              $this->assertSame( bbp_get_trash_status_id(), $reply_status );
 222  
 223              $reply_meta_status = get_post_meta( $reply, '_wp_trash_meta_status', true );
 224              $this->assertSame( bbp_get_public_status_id(), $reply_meta_status );
 225          }
 226      }
 227  
 228      /**
 229       * @covers ::bbp_unspam_topic
 230       */
 231  	public function test_bbp_unspam_topic() {
 232          $f = $this->factory->forum->create();
 233  
 234          $now = time();
 235          $post_date_topic = date( 'Y-m-d H:i:s', $now - 60 * 60 * 100 );
 236          $post_date_reply = date( 'Y-m-d H:i:s', $now - 60 * 60 * 80 );
 237  
 238          $topic_time = '4 days, 4 hours ago';
 239          $reply_time = '3 days, 8 hours ago';
 240  
 241          $t = $this->factory->topic->create( array(
 242              'post_parent' => $f,
 243              'post_date' => $post_date_topic,
 244              'topic_meta' => array(
 245                  'forum_id' => $f,
 246              ),
 247          ) );
 248          $r = $this->factory->reply->create_many( 2, array(
 249              'post_parent' => $t,
 250              'post_date' => $post_date_reply,
 251              'reply_meta' => array(
 252                  'forum_id' => $f,
 253                  'topic_id' => $t,
 254              ),
 255          ) );
 256  
 257          bbp_spam_topic( $t );
 258  
 259          bbp_unspam_topic( $t );
 260  
 261          $topic_status = get_post_status( $t );
 262          $this->assertSame( bbp_get_public_status_id(), $topic_status );
 263  
 264          $this->assertEquals( '', get_post_meta( $t, '_bbp_pre_spammed_replies', true ) );
 265          $this->assertEquals( array(), get_post_meta( $t, '_bbp_pre_spammed_replies', false ) );
 266  
 267          $this->assertEquals( '', get_post_meta( $t, '_bbp_spam_meta_status', true ) );
 268          $this->assertEquals( array(), get_post_meta( $t, '_bbp_spam_meta_status', false ) );
 269  
 270          $count = bbp_get_forum_topic_count( $f, false, true );
 271          $this->assertSame( 1, $count );
 272  
 273          $count = bbp_get_forum_topic_count_hidden( $f, true );
 274          $this->assertSame( 0, $count );
 275  
 276          $count = bbp_get_forum_reply_count( $f, false, true );
 277          $this->assertSame( 2, $count );
 278  
 279          $last_topic_id = bbp_get_forum_last_topic_id( $f );
 280          $this->assertSame( $t, $last_topic_id );
 281  
 282          $last_reply_id = bbp_get_forum_last_reply_id( $f );
 283          $this->assertSame( $r[1], $last_reply_id );
 284  
 285          $last_active_id = bbp_get_forum_last_active_id( $f );
 286          $this->assertSame( $r[1], $last_active_id );
 287  
 288          $last_active_time = bbp_get_forum_last_active_time( $f );
 289          $this->assertSame( $reply_time, $last_active_time );
 290  
 291          $count = bbp_get_topic_reply_count( $t, true, true );
 292          $this->assertSame( 2, $count );
 293  
 294          $count = bbp_get_topic_reply_count_hidden( $t, true, true );
 295          $this->assertSame( 0, $count );
 296  
 297          $last_reply_id = bbp_get_topic_last_reply_id( $t );
 298          $this->assertSame( $r[1], $last_reply_id );
 299  
 300          $last_active_id = bbp_get_topic_last_active_id( $t );
 301          $this->assertSame( $r[1], $last_active_id );
 302  
 303          $last_active_time = bbp_get_topic_last_active_time( $t );
 304          $this->assertSame( $reply_time, $last_active_time );
 305      }
 306  
 307      /**
 308       * @covers ::bbp_unspam_topic_replies
 309       */
 310  	public function test_bbp_unspam_topic_replies() {
 311          $f = $this->factory->forum->create();
 312  
 313          $now = time();
 314          $post_date_topic = date( 'Y-m-d H:i:s', $now - 60 * 60 * 100 );
 315          $post_date_reply = date( 'Y-m-d H:i:s', $now - 60 * 60 * 80 );
 316  
 317          $topic_time = '4 days, 4 hours ago';
 318          $reply_time = '3 days, 8 hours ago';
 319  
 320          $t = $this->factory->topic->create( array(
 321              'post_parent' => $f,
 322              'post_date' => $post_date_topic,
 323              'topic_meta' => array(
 324                  'forum_id' => $f,
 325              ),
 326          ) );
 327          $r = $this->factory->reply->create_many( 2, array(
 328              'post_parent' => $t,
 329              'post_date' => $post_date_reply,
 330              'reply_meta' => array(
 331                  'forum_id' => $f,
 332                  'topic_id' => $t,
 333              ),
 334          ) );
 335  
 336          bbp_spam_topic_replies( $t );
 337  
 338          bbp_unspam_topic_replies( $t );
 339  
 340          $this->assertEquals( '', get_post_meta( $t, '_bbp_pre_spammed_replies', true ) );
 341          $this->assertEquals( array(), get_post_meta( $t, '_bbp_pre_spammed_replies', false ) );
 342  
 343          foreach ( $r as $reply ) {
 344              $reply_status = get_post_status( $reply );
 345              $this->assertSame( bbp_get_public_status_id(), $reply_status );
 346  
 347              $this->assertEquals( '', get_post_meta( $reply, '_wp_trash_meta_status', true ) );
 348              $this->assertEquals( array(), get_post_meta( $reply, '_wp_trash_meta_status', false ) );
 349          }
 350  
 351          $count = bbp_get_forum_reply_count( $f, false, true );
 352          $this->assertSame( 2, $count );
 353  
 354          $last_reply_id = bbp_get_forum_last_reply_id( $f );
 355          $this->assertSame( $r[1], $last_reply_id );
 356  
 357          $last_active_id = bbp_get_forum_last_active_id( $f );
 358          $this->assertSame( $r[1], $last_active_id );
 359  
 360          $last_active_time = bbp_get_forum_last_active_time( $f );
 361          $this->assertSame( $reply_time, $last_active_time );
 362  
 363          $count = bbp_get_topic_reply_count( $t, true, true );
 364          $this->assertSame( 2, $count );
 365  
 366          $count = bbp_get_topic_reply_count_hidden( $t, true, true );
 367          $this->assertSame( 0, $count );
 368  
 369          $last_reply_id = bbp_get_topic_last_reply_id( $t );
 370          $this->assertSame( $r[1], $last_reply_id );
 371  
 372          $last_active_id = bbp_get_topic_last_active_id( $t );
 373          $this->assertSame( $r[1], $last_active_id );
 374  
 375          $last_active_time = bbp_get_topic_last_active_time( $t );
 376          $this->assertSame( $reply_time, $last_active_time );
 377      }
 378  
 379      /**
 380       * @covers ::bbp_stick_topic
 381       * @todo   Implement test_bbp_stick_topic().
 382       */
 383  	public function test_bbp_stick_topic() {
 384          // Remove the following lines when you implement this test.
 385          $this->markTestIncomplete(
 386              'This test has not been implemented yet.'
 387          );
 388      }
 389  
 390      /**
 391       * @covers ::bbp_approve_topic
 392       * @todo   Implement test_bbp_approve_topic().
 393       */
 394  	public function test_bbp_approve_topic() {
 395          // Remove the following lines when you implement this test.
 396          $this->markTestIncomplete(
 397              'This test has not been implemented yet.'
 398          );
 399      }
 400  
 401      /**
 402       * @covers ::bbp_unapprove_topic
 403       * @todo   Implement test_bbp_unapprove_topic().
 404       */
 405  	public function test_bbp_unapprove_topic() {
 406          // Remove the following lines when you implement this test.
 407          $this->markTestIncomplete(
 408              'This test has not been implemented yet.'
 409          );
 410      }
 411  
 412      /**
 413       * @covers ::bbp_unstick_topic
 414       * @todo   Implement test_bbp_unstick_topic().
 415       */
 416  	public function test_bbp_unstick_topic() {
 417          // Remove the following lines when you implement this test.
 418          $this->markTestIncomplete(
 419              'This test has not been implemented yet.'
 420          );
 421      }
 422  }


Generated: Sat Dec 21 01:00:52 2024 Cross-referenced by PHPXref 0.7.1