[ Index ]

PHP Cross Reference of BBPress

title

Body

[close]

/tests/phpunit/testcases/admin/ -> tools.php (source)

   1  <?php
   2  
   3  /**
   4   * Tests for the admin tools functions.
   5   *
   6   * @group tools
   7   */
   8  class BBP_Tests_Admin_Tools extends BBP_UnitTestCase {
   9      protected $old_current_user = 0;
  10  
  11  	public function setUp() {
  12          parent::setUp();
  13          $this->old_current_user = get_current_user_id();
  14          $this->set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
  15          $this->keymaster_id = get_current_user_id();
  16  
  17          bbp_set_user_role( $this->keymaster_id, bbp_get_keymaster_role() );
  18  
  19          if ( ! function_exists( 'bbp_admin_repair_page' ) ) {
  20              require_once BBP_PLUGIN_DIR . 'includes/admin/tools/repair.php';
  21              require_once BBP_PLUGIN_DIR . 'includes/admin/tools/upgrade.php';
  22          }
  23      }
  24  
  25  	public function tearDown() {
  26          parent::tearDown();
  27          $this->set_current_user( $this->old_current_user );
  28      }
  29  
  30      /**
  31       * @covers ::bbp_admin_repair
  32       * @todo   Implement test_bbp_admin_repair().
  33       */
  34  	public function test_bbp_admin_repair() {
  35          // Remove the following lines when you implement this test.
  36          $this->markTestIncomplete(
  37              'This test has not been implemented yet.'
  38          );
  39      }
  40  
  41      /**
  42       * @covers ::bbp_admin_repair_handler
  43       * @todo   Implement test_bbp_admin_repair_handler().
  44       */
  45  	public function test_bbp_admin_repair_handler() {
  46          // Remove the following lines when you implement this test.
  47          $this->markTestIncomplete(
  48              'This test has not been implemented yet.'
  49          );
  50      }
  51  
  52      /**
  53       * @covers ::bbp_admin_tools_repair_help
  54       * @todo   Implement test_bbp_admin_tools_repair_help().
  55       */
  56  	public function test_bbp_admin_tools_repair_help() {
  57          // Remove the following lines when you implement this test.
  58          $this->markTestIncomplete(
  59              'This test has not been implemented yet.'
  60          );
  61      }
  62  
  63      /**
  64       * @covers ::bbp_admin_tools_reset_help
  65       * @todo   Implement test_bbp_admin_tools_reset_help().
  66       */
  67  	public function test_bbp_admin_tools_reset_help() {
  68          // Remove the following lines when you implement this test.
  69          $this->markTestIncomplete(
  70              'This test has not been implemented yet.'
  71          );
  72      }
  73  
  74      /**
  75       * @covers ::bbp_admin_tools_converter_help
  76       * @todo   Implement test_bbp_admin_tools_converter_help().
  77       */
  78  	public function test_bbp_admin_tools_converter_help() {
  79          // Remove the following lines when you implement this test.
  80          $this->markTestIncomplete(
  81              'This test has not been implemented yet.'
  82          );
  83      }
  84  
  85      /**
  86       * @covers ::bbp_admin_tools_feedback
  87       * @todo   Implement test_bbp_admin_tools_feedback().
  88       */
  89  	public function test_bbp_admin_tools_feedback() {
  90          // Remove the following lines when you implement this test.
  91          $this->markTestIncomplete(
  92              'This test has not been implemented yet.'
  93          );
  94      }
  95  
  96      /**
  97       * @covers ::bbp_admin_repair_list
  98       * @todo   Implement test_bbp_admin_repair_list().
  99       */
 100  	public function test_bbp_admin_repair_list() {
 101          // Remove the following lines when you implement this test.
 102          $this->markTestIncomplete(
 103              'This test has not been implemented yet.'
 104          );
 105      }
 106  
 107      /**
 108       * @covers ::bbp_admin_repair_topic_reply_count
 109       * @todo   Implement test_bbp_admin_repair_topic_reply_count().
 110       */
 111  	public function test_bbp_admin_repair_topic_reply_count() {
 112          // Remove the following lines when you implement this test.
 113          $this->markTestIncomplete(
 114              'This test has not been implemented yet.'
 115          );
 116      }
 117  
 118      /**
 119       * @covers ::bbp_admin_repair_topic_voice_count
 120       */
 121  	public function test_bbp_admin_repair_topic_voice_count() {
 122          $u = $this->factory->user->create_many( 2 );
 123  
 124          $f = $this->factory->forum->create();
 125  
 126          $t = $this->factory->topic->create( array(
 127              'post_parent' => $f,
 128              'topic_meta' => array(
 129                  'forum_id' => $f,
 130              ),
 131          ) );
 132  
 133          $r = $this->factory->reply->create( array(
 134              'post_author' => $u[0],
 135              'post_parent' => $t,
 136              'reply_meta' => array(
 137                  'forum_id' => $f,
 138                  'topic_id' => $t,
 139              ),
 140          ) );
 141  
 142          $r = $this->factory->reply->create( array(
 143              'post_author' => $u[1],
 144              'post_parent' => $t,
 145              'reply_meta' => array(
 146                  'forum_id' => $f,
 147                  'topic_id' => $t,
 148              ),
 149          ) );
 150  
 151          $count = bbp_get_topic_voice_count( $t );
 152          $this->assertSame( '3', $count );
 153  
 154          // Delete the topic _bbp_voice_count meta key.
 155          $this->assertTrue( delete_post_meta_by_key( '_bbp_voice_count' ) );
 156  
 157          $count = bbp_get_topic_voice_count( $t );
 158          $this->assertSame( '0', $count );
 159  
 160          // Repair the topic voice count meta.
 161          bbp_admin_repair_topic_voice_count();
 162  
 163          clean_post_cache( $t );
 164  
 165          $count = bbp_get_topic_voice_count( $t );
 166          $this->assertSame( '3', $count );
 167      }
 168  
 169      /**
 170       * @covers ::bbp_admin_repair_topic_hidden_reply_count
 171       */
 172      public function test_bbp_admin_repair_topic_hidden_reply_count() {
 173  
 174          $f = $this->factory->forum->create();
 175  
 176          $t = $this->factory->topic->create( array(
 177              'post_parent' => $f,
 178              'topic_meta' => array(
 179                  'forum_id' => $f,
 180              ),
 181          ) );
 182  
 183          $r = $this->factory->reply->create( array(
 184              'post_parent' => $t,
 185              'reply_meta' => array(
 186                  'forum_id' => $f,
 187                  'topic_id' => $t,
 188              ),
 189          ) );
 190  
 191          $count = bbp_get_topic_reply_count( $t, true );
 192          $this->assertSame( 1, $count );
 193  
 194          $r = $this->factory->reply->create_many( 3, array(
 195              'post_parent' => $t,
 196              'reply_meta' => array(
 197                  'forum_id' => $f,
 198                  'topic_id' => $t,
 199              ),
 200          ) );
 201  
 202          bbp_spam_reply( $r[0] );
 203          bbp_unapprove_reply( $r[2] );
 204  
 205          $count = bbp_get_topic_reply_count_hidden( $t, true );
 206          $this->assertSame( 2, $count );
 207  
 208          // Delete the topic _bbp_reply_count_hidden meta key.
 209          $this->assertTrue( delete_post_meta_by_key( '_bbp_reply_count_hidden' ) );
 210  
 211          $count = bbp_get_topic_reply_count_hidden( $t, true );
 212          $this->assertSame( 0, $count );
 213  
 214          // Repair the topic hidden reply count meta.
 215          bbp_admin_repair_topic_hidden_reply_count();
 216  
 217          clean_post_cache( $t );
 218  
 219          $count = bbp_get_topic_reply_count_hidden( $t, true );
 220          $this->assertSame( 2, $count );
 221      }
 222  
 223      /**
 224       * @covers ::bbp_admin_repair_group_forum_relationship
 225       * @todo   Implement test_bbp_admin_repair_group_forum_relationship().
 226       */
 227      public function test_bbp_admin_repair_group_forum_relationship() {
 228          // Remove the following lines when you implement this test.
 229          $this->markTestIncomplete(
 230              'This test has not been implemented yet.'
 231          );
 232      }
 233  
 234      /**
 235       * @covers ::bbp_admin_repair_forum_topic_count
 236       */
 237  	public function test_bbp_admin_repair_forum_topic_count() {
 238          $c = $this->factory->forum->create( array(
 239              'forum_meta' => array(
 240                  'forum_type' => 'category',
 241                  'status'     => 'open',
 242              ),
 243          ) );
 244  
 245          $f = $this->factory->forum->create( array(
 246              'post_parent' => $c,
 247              'forum_meta' => array(
 248                  'forum_id'   => $c,
 249                  'forum_type' => 'forum',
 250                  'status'     => 'open',
 251              ),
 252          ) );
 253  
 254          $t = $this->factory->topic->create( array(
 255              'post_parent' => $f,
 256              'topic_meta' => array(
 257                  'forum_id' => $f,
 258              ),
 259          ) );
 260  
 261          $count = bbp_get_forum_topic_count( $f, true, true );
 262          $this->assertSame( 1, $count );
 263  
 264          $t = $this->factory->topic->create_many( 3, array(
 265              'post_parent' => $f,
 266              'topic_meta' => array(
 267                  'forum_id' => $f,
 268              ),
 269          ) );
 270  
 271          bbp_update_forum_topic_count( $c );
 272          bbp_update_forum_topic_count( $f );
 273  
 274          // Category topic count.
 275          $count = bbp_get_forum_topic_count( $c, false, true );
 276          $this->assertSame( 0, $count );
 277  
 278          // Category total topic count.
 279          $count = bbp_get_forum_topic_count( $c, true, true );
 280          $this->assertSame( 4, $count );
 281  
 282          // Category topic count hidden.
 283          $count = bbp_get_forum_topic_count_hidden( $c, true );
 284          $this->assertSame( 0, $count );
 285  
 286          // Forum topic count.
 287          $count = bbp_get_forum_topic_count( $f, false, true );
 288          $this->assertSame( 4, $count );
 289  
 290          // Forum total topic count.
 291          $count = bbp_get_forum_topic_count( $f, true, true );
 292          $this->assertSame( 4, $count );
 293  
 294          // Forum topic count hidden.
 295          $count = bbp_get_forum_topic_count_hidden( $f, true );
 296          $this->assertSame( 0, $count );
 297  
 298          bbp_spam_topic( $t[0] );
 299          bbp_unapprove_topic( $t[2] );
 300  
 301          // Category topic count.
 302          $count = bbp_get_forum_topic_count( $c, false, true );
 303          $this->assertSame( 0, $count );
 304  
 305          // Category total topic count.
 306          $count = bbp_get_forum_topic_count( $c, true, true );
 307          $this->assertSame( 2, $count );
 308  
 309          // Category topic count hidden.
 310          $count = bbp_get_forum_topic_count_hidden( $c, true );
 311          $this->assertSame( 0, $count );
 312  
 313          // Forum topic count.
 314          $count = bbp_get_forum_topic_count( $f, false, true );
 315          $this->assertSame( 2, $count );
 316  
 317          // Forum total topic count.
 318          $count = bbp_get_forum_topic_count( $f, true, true );
 319          $this->assertSame( 2, $count );
 320  
 321          // Forum topic count hidden.
 322          $count = bbp_get_forum_topic_count_hidden( $f, true );
 323          $this->assertSame( 2, $count );
 324  
 325          // Delete the _bbp_total_topic_count meta key.
 326          $this->assertTrue( delete_post_meta_by_key( '_bbp_topic_count_hidden' ) );
 327  
 328          // Delete the _bbp_total_topic_count meta key.
 329          $this->assertTrue( delete_post_meta_by_key( '_bbp_total_topic_count' ) );
 330  
 331          // Delete the  _bbp_topic_count meta key.
 332          $this->assertTrue( delete_post_meta_by_key( '_bbp_topic_count' ) );
 333  
 334          // Category topic count.
 335          $count = bbp_get_forum_topic_count( $c, false, true );
 336          $this->assertSame( 0, $count );
 337  
 338          // Category total topic count.
 339          $count = bbp_get_forum_topic_count( $c, true, true );
 340          $this->assertSame( 0, $count );
 341  
 342          // Category topic count hidden.
 343          $count = bbp_get_forum_topic_count_hidden( $c, true );
 344          $this->assertSame( 0, $count );
 345  
 346          // Forum topic count.
 347          $count = bbp_get_forum_topic_count( $f, false, true );
 348          $this->assertSame( 0, $count );
 349  
 350          // Forum total topic count.
 351          $count = bbp_get_forum_topic_count( $f, true, true );
 352          $this->assertSame( 0, $count );
 353  
 354          // Forum topic count hidden.
 355          $count = bbp_get_forum_topic_count_hidden( $f, true );
 356          $this->assertSame( 0, $count );
 357  
 358          // Repair the forum topic count meta.
 359          bbp_admin_repair_forum_topic_count();
 360  
 361          // Category topic count.
 362          $count = bbp_get_forum_topic_count( $c, false, true );
 363          $this->assertSame( 0, $count );
 364  
 365          // Category total topic count.
 366          $count = bbp_get_forum_topic_count( $c, true, true );
 367          $this->assertSame( 2, $count );
 368  
 369          // Category topic count hidden.
 370          $count = bbp_get_forum_topic_count_hidden( $c, true );
 371          $this->assertSame( 0, $count );
 372  
 373          // Forum topic count.
 374          $count = bbp_get_forum_topic_count( $f, false, true );
 375          $this->assertSame( 2, $count );
 376  
 377          // Forum total topic count.
 378          $count = bbp_get_forum_topic_count( $f, true, true );
 379          $this->assertSame( 2, $count );
 380  
 381          // Forum topic count hidden.
 382          $count = bbp_get_forum_topic_count_hidden( $f, true );
 383          $this->assertSame( 2, $count );
 384      }
 385  
 386      /**
 387       * @covers ::bbp_admin_repair_forum_reply_count
 388       */
 389  	public function test_bbp_admin_repair_forum_reply_count() {
 390          $c = $this->factory->forum->create( array(
 391              'forum_meta' => array(
 392                  'forum_type' => 'category',
 393                  'status'     => 'open',
 394              ),
 395          ) );
 396  
 397          $f = $this->factory->forum->create( array(
 398              'post_parent' => $c,
 399              'forum_meta' => array(
 400                  'forum_id'   => $c,
 401                  'forum_type' => 'forum',
 402                  'status'     => 'open',
 403              ),
 404          ) );
 405  
 406          $t = $this->factory->topic->create( array(
 407              'post_parent' => $f,
 408              'topic_meta' => array(
 409                  'forum_id' => $f,
 410              ),
 411          ) );
 412  
 413          $r = $this->factory->reply->create( array(
 414              'post_parent' => $t,
 415              'reply_meta' => array(
 416                  'forum_id' => $f,
 417                  'topic_id' => $t,
 418              ),
 419          ) );
 420  
 421          $count = bbp_get_forum_reply_count( $f, true, true );
 422          $this->assertSame( 1, $count );
 423  
 424          $r = $this->factory->reply->create_many( 3, array(
 425              'post_parent' => $t,
 426              'reply_meta' => array(
 427                  'forum_id' => $f,
 428                  'topic_id' => $t,
 429              ),
 430          ) );
 431  
 432          bbp_update_forum_reply_count( $c );
 433          bbp_update_forum_reply_count( $f );
 434  
 435          // Category reply count.
 436          $count = bbp_get_forum_reply_count( $c, false, true );
 437          $this->assertSame( 0, $count );
 438  
 439          // Category total reply count.
 440          $count = bbp_get_forum_reply_count( $c, true, true );
 441          $this->assertSame( 4, $count );
 442  
 443          // Forum reply count.
 444          $count = bbp_get_forum_reply_count( $f, false, true );
 445          $this->assertSame( 4, $count );
 446  
 447          // Forum total reply count.
 448          $count = bbp_get_forum_reply_count( $f, true, true );
 449          $this->assertSame( 4, $count );
 450  
 451          bbp_spam_reply( $r[0] );
 452          bbp_unapprove_reply( $r[2] );
 453  
 454          // Category reply count.
 455          $count = bbp_get_forum_reply_count( $c, false, true );
 456          $this->assertSame( 0, $count );
 457  
 458          // Category total reply count.
 459          $count = bbp_get_forum_reply_count( $c, true, true );
 460          $this->assertSame( 2, $count );
 461  
 462          // Forum reply count.
 463          $count = bbp_get_forum_reply_count( $f, false, true );
 464          $this->assertSame( 2, $count );
 465  
 466          // Forum total reply count.
 467          $count = bbp_get_forum_reply_count( $f, true, true );
 468          $this->assertSame( 2, $count );
 469  
 470          // Delete the _bbp_total_reply_count meta key.
 471          $this->assertTrue( delete_post_meta_by_key( '_bbp_total_reply_count' ) );
 472  
 473          // Delete the _bbp_reply_count meta key.
 474          $this->assertTrue( delete_post_meta_by_key( '_bbp_reply_count' ) );
 475  
 476          // Category reply count.
 477          $count = bbp_get_forum_reply_count( $c, false, true );
 478          $this->assertSame( 0, $count );
 479  
 480          // Category total reply count.
 481          $count = bbp_get_forum_reply_count( $c, true, true );
 482          $this->assertSame( 0, $count );
 483  
 484          // Forum reply count.
 485          $count = bbp_get_forum_reply_count( $f, false, true );
 486          $this->assertSame( 0, $count );
 487  
 488          // Forum total reply count.
 489          $count = bbp_get_forum_reply_count( $f, true, true );
 490          $this->assertSame( 0, $count );
 491  
 492          // Repair the forum reply count meta.
 493          bbp_admin_repair_forum_reply_count();
 494  
 495          // Category reply count.
 496          $count = bbp_get_forum_reply_count( $c, false, true );
 497          $this->assertSame( 0, $count );
 498  
 499          // Category total reply count.
 500          $count = bbp_get_forum_reply_count( $c, true, true );
 501          $this->assertSame( 2, $count );
 502  
 503          // Forum reply count.
 504          $count = bbp_get_forum_reply_count( $f, false, true );
 505          $this->assertSame( 2, $count );
 506  
 507          // Forum total reply count.
 508          $count = bbp_get_forum_reply_count( $f, true, true );
 509          $this->assertSame( 2, $count );
 510      }
 511  
 512      /**
 513       * @covers ::bbp_admin_repair_user_topic_count
 514       * @todo   Implement test_bbp_admin_repair_user_topic_count().
 515       */
 516  	public function test_bbp_admin_repair_user_topic_count() {
 517          // Remove the following lines when you implement this test.
 518          $this->markTestIncomplete(
 519              'This test has not been implemented yet.'
 520          );
 521      }
 522  
 523      /**
 524       * @covers ::bbp_admin_repair_user_reply_count
 525       * @todo   Implement test_bbp_admin_repair_user_reply_count().
 526       */
 527  	public function test_bbp_admin_repair_user_reply_count() {
 528          // Remove the following lines when you implement this test.
 529          $this->markTestIncomplete(
 530              'This test has not been implemented yet.'
 531          );
 532      }
 533  
 534      /**
 535       * @covers ::bbp_admin_repair_user_favorites
 536       * @todo   Implement test_bbp_admin_repair_user_favorites().
 537       */
 538  	public function test_bbp_admin_repair_user_favorites() {
 539          // Remove the following lines when you implement this test.
 540          $this->markTestIncomplete(
 541              'This test has not been implemented yet.'
 542          );
 543      }
 544  
 545      /**
 546       * @covers ::bbp_admin_repair_user_topic_subscriptions
 547       * @todo   Implement test_bbp_admin_repair_user_topic_subscriptions().
 548       */
 549      public function test_bbp_admin_repair_user_topic_subscriptions() {
 550          // Remove the following lines when you implement this test.
 551          $this->markTestIncomplete(
 552              'This test has not been implemented yet.'
 553          );
 554      }
 555  
 556      /**
 557       * @covers ::bbp_admin_repair_user_forum_subscriptions
 558       * @todo   Implement test_bbp_admin_repair_user_forum_subscriptions().
 559       */
 560      public function test_bbp_admin_repair_user_forum_subscriptions() {
 561          // Remove the following lines when you implement this test.
 562          $this->markTestIncomplete(
 563              'This test has not been implemented yet.'
 564          );
 565      }
 566  
 567      /**
 568       * @covers ::bbp_admin_repair_user_roles
 569       * @todo   Implement test_bbp_admin_repair_user_roles().
 570       */
 571  	public function test_bbp_admin_repair_user_roles() {
 572          // Remove the following lines when you implement this test.
 573          $this->markTestIncomplete(
 574              'This test has not been implemented yet.'
 575          );
 576      }
 577  
 578      /**
 579       * @covers ::bbp_admin_repair_freshness
 580       * @todo   Implement test_bbp_admin_repair_freshness().
 581       */
 582  	public function test_bbp_admin_repair_freshness() {
 583          // Remove the following lines when you implement this test.
 584          $this->markTestIncomplete(
 585              'This test has not been implemented yet.'
 586          );
 587      }
 588  
 589      /**
 590       * @covers ::bbp_admin_repair_sticky
 591       * @todo   Implement test_bbp_admin_repair_sticky().
 592       */
 593  	public function test_bbp_admin_repair_sticky() {
 594          // Remove the following lines when you implement this test.
 595          $this->markTestIncomplete(
 596              'This test has not been implemented yet.'
 597          );
 598      }
 599  
 600      /**
 601       * @covers ::bbp_admin_repair_closed_topics
 602       * @todo   Implement test_bbp_admin_repair_closed_topics().
 603       */
 604  	public function test_bbp_admin_repair_closed_topics() {
 605          // Remove the following lines when you implement this test.
 606          $this->markTestIncomplete(
 607              'This test has not been implemented yet.'
 608          );
 609      }
 610  
 611      /**
 612       * @covers ::bbp_admin_repair_forum_visibility
 613       * @todo   Implement test_bbp_admin_repair_forum_visibility().
 614       */
 615  	public function test_bbp_admin_repair_forum_visibility() {
 616          // Remove the following lines when you implement this test.
 617          $this->markTestIncomplete(
 618              'This test has not been implemented yet.'
 619          );
 620      }
 621  
 622      /**
 623       * @covers ::bbp_admin_repair_forum_meta
 624       */
 625  	public function test_bbp_admin_repair_forum_meta() {
 626  
 627          $f = $this->factory->forum->create();
 628  
 629          $t = $this->factory->topic->create( array(
 630              'post_parent' => $f,
 631              'topic_meta' => array(
 632                  'forum_id' => $f,
 633              ),
 634          ) );
 635  
 636          $r = $this->factory->reply->create( array(
 637              'post_parent' => $t,
 638              'reply_meta' => array(
 639                  'forum_id' => $f,
 640                  'topic_id' => $t,
 641              ),
 642          ) );
 643  
 644          // Forums should have an empty _bbp_forum_id meta key
 645          $this->assertEquals( array( 0 => '0' ), get_post_meta( $f, '_bbp_forum_id', false ) );
 646  
 647          // Topics should have a _bbp_forum_id meta key
 648          $this->assertSame( $f, bbp_get_topic_forum_id( $t ) );
 649  
 650          // Replies should have a _bbp_forum_id meta key
 651          $this->assertSame( $f, bbp_get_reply_forum_id( $r ) );
 652  
 653          // Delete the topic and reply _bbp_forum_id meta key
 654          $this->assertTrue( delete_post_meta_by_key( '_bbp_forum_id' ) );
 655  
 656          // Check the _bbp_forum_id meta key is deleted
 657          $this->assertEquals( array(), get_post_meta( $f, '_bbp_forum_id', false ) );
 658          $this->assertEquals( array(), get_post_meta( $t, '_bbp_forum_id', false ) );
 659          $this->assertEquals( array(), get_post_meta( $r, '_bbp_forum_id', false ) );
 660  
 661          // Repair the forum meta
 662          bbp_admin_repair_forum_meta();
 663  
 664          clean_post_cache( $f );
 665          clean_post_cache( $t );
 666          clean_post_cache( $r );
 667  
 668          // Forums should NOT have a _bbp_forum_id meta key
 669          $this->assertEquals( array(), get_post_meta( $f, '_bbp_forum_id', false ) );
 670  
 671          // Topics should have a _bbp_forum_id meta key
 672          $this->assertEquals( array( $f ), get_post_meta( $t, '_bbp_forum_id', false ) );
 673          $this->assertSame( $f, bbp_get_topic_forum_id( $t ) );
 674  
 675          // Replies should have a _bbp_forum_id meta key
 676          $this->assertEquals( array( $f ), get_post_meta( $r, '_bbp_forum_id', false ) );
 677          $this->assertSame( $f, bbp_get_reply_forum_id( $r ) );
 678      }
 679  
 680      /**
 681       * @covers ::bbp_admin_repair_topic_meta
 682       * @todo   Implement test_bbp_admin_repair_topic_meta().
 683       */
 684  	public function test_bbp_admin_repair_topic_meta() {
 685          // Remove the following lines when you implement this test.
 686          $this->markTestIncomplete(
 687              'This test has not been implemented yet.'
 688          );
 689      }
 690  
 691      /**
 692       * @covers ::bbp_admin_repair_reply_menu_order
 693       * @todo   Implement test_bbp_admin_repair_reply_menu_order().
 694       */
 695  	public function test_bbp_admin_repair_reply_menu_order() {
 696          // Remove the following lines when you implement this test.
 697          $this->markTestIncomplete(
 698              'This test has not been implemented yet.'
 699          );
 700      }
 701  
 702      /**
 703       * @covers ::bbp_admin_upgrade_user_favorites
 704       */
 705  	public function test_bbp_admin_upgrade_user_favorites() {
 706  
 707          $u = $this->factory->user->create_many( 2 );
 708          $t = $this->factory->topic->create();
 709  
 710          // Create 2.5.x user meta favorites
 711          update_user_option( $u[0], '_bbp_favorites', $t );
 712          update_user_option( $u[1], '_bbp_favorites', $t );
 713  
 714          // Upgrade the user favorites.
 715          bbp_admin_upgrade_user_favorites();
 716  
 717          $expected            = array( $u[0], $u[1] );
 718          $favoriters          = bbp_get_topic_favoriters( $t );
 719          $post_meta_favorites = get_post_meta( $t, '_bbp_favorite', false );
 720  
 721          $this->assertEqualSets( $expected, $favoriters );
 722          $this->assertEqualSets( $expected, $post_meta_favorites );
 723      }
 724  
 725      /**
 726       * @covers ::bbp_admin_upgrade_user_topic_subscriptions
 727       */
 728      public function test_bbp_admin_upgrade_user_topic_subscriptions() {
 729  
 730          $u = $this->factory->user->create_many( 2 );
 731  
 732          $f = $this->factory->forum->create();
 733  
 734          $t = $this->factory->topic->create( array(
 735              'post_parent' => $f,
 736              'topic_meta' => array(
 737                  'forum_id' => $f,
 738              ),
 739          ) );
 740  
 741          // Create 2.5.x user meta topic subscriptions.
 742          update_user_option( $u[0], '_bbp_subscriptions', $t );
 743          update_user_option( $u[1], '_bbp_subscriptions', $t );
 744  
 745          // Upgrade the user topic subscriptions.
 746          bbp_admin_upgrade_user_topic_subscriptions();
 747  
 748          $expected            = array( $u[0], $u[1] );
 749          $topic_subscribers   = bbp_get_topic_subscribers( $t );
 750          $post_meta_topic_sub = get_post_meta( $t, '_bbp_subscription', false );
 751  
 752          $this->assertEqualSets( $expected, $topic_subscribers );
 753          $this->assertEqualSets( $expected, $post_meta_topic_sub );
 754      }
 755  
 756      /**
 757       * @covers ::bbp_admin_upgrade_user_forum_subscriptions
 758       */
 759      public function test_bbp_admin_upgrade_user_forum_subscriptions() {
 760  
 761          $u = $this->factory->user->create_many( 2 );
 762  
 763          $f = $this->factory->forum->create();
 764  
 765          // Create 2.5.x user meta forum subscriptions.
 766          update_user_option( $u[0], '_bbp_forum_subscriptions', $f );
 767          update_user_option( $u[1], '_bbp_forum_subscriptions', $f );
 768  
 769          // Upgrade the user forum subscriptions.
 770          bbp_admin_upgrade_user_forum_subscriptions();
 771  
 772          $expected            = array( $u[0], $u[1] );
 773          $forum_subscribers   = bbp_get_forum_subscribers( $f );
 774          $post_meta_forum_sub = get_post_meta( $f, '_bbp_subscription', false );
 775  
 776          $this->assertEqualSets( $expected, $forum_subscribers );
 777          $this->assertEqualSets( $expected, $post_meta_forum_sub );
 778      }
 779  
 780      /**
 781       * @covers ::bbp_admin_reset
 782       * @todo   Implement test_bbp_admin_reset().
 783       */
 784  	public function test_bbp_admin_reset() {
 785          // Remove the following lines when you implement this test.
 786          $this->markTestIncomplete(
 787              'This test has not been implemented yet.'
 788          );
 789      }
 790  
 791      /**
 792       * @covers ::bbp_admin_reset_handler
 793       * @todo   Implement test_bbp_admin_reset_handler().
 794       */
 795  	public function test_bbp_admin_reset_handler() {
 796          // Remove the following lines when you implement this test.
 797          $this->markTestIncomplete(
 798              'This test has not been implemented yet.'
 799          );
 800      }
 801  }


Generated: Mon Oct 21 01:01:24 2019 Cross-referenced by PHPXref 0.7.1