[ Index ]

PHP Cross Reference of BBPress

title

Body

[close]

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

   1  <?php
   2  /**
   3   * Tests for the common functions.
   4   *
   5   * @group common
   6   * @group functions
   7   */
   8  
   9  class BBP_Tests_Common_Functions extends BBP_UnitTestCase {
  10  
  11      /**
  12       * @covers ::bbp_number_format
  13       * @todo   Implement test_bbp_number_format().
  14       */
  15  	public function test_bbp_number_format() {
  16          // Remove the following lines when you implement this test.
  17          $this->markTestIncomplete(
  18              'This test has not been implemented yet.'
  19          );
  20      }
  21  
  22      /**
  23       * @covers ::bbp_number_format_i18n
  24       * @todo   Implement test_bbp_number_format_i18n().
  25       */
  26  	public function test_bbp_number_format_i18n() {
  27          // Remove the following lines when you implement this test.
  28          $this->markTestIncomplete(
  29              'This test has not been implemented yet.'
  30          );
  31      }
  32  
  33      /**
  34       * @covers ::bbp_convert_date
  35       * @todo   Implement test_bbp_convert_date().
  36       */
  37  	public function test_bbp_convert_date() {
  38          // Remove the following lines when you implement this test.
  39          $this->markTestIncomplete(
  40              'This test has not been implemented yet.'
  41          );
  42      }
  43  
  44      /**
  45       * @covers ::bbp_time_since
  46       * @covers ::bbp_get_time_since
  47       */
  48  	public function test_bbp_time_since_years_months() {
  49          $now = time();
  50          $then = $now - ( 3 * YEAR_IN_SECONDS ) - ( 3 * 30 * DAY_IN_SECONDS );
  51          $since = '3 years, 3 months ago';
  52  
  53          // Output.
  54          $this->expectOutputString( $since );
  55          bbp_time_since( $then, $now );
  56  
  57          // Formatted.
  58          $this->assertEquals( $since, bbp_get_time_since( $then, $now ) );
  59      }
  60  
  61      /**
  62       * @covers ::bbp_time_since
  63       * @covers ::bbp_get_time_since
  64       */
  65  	public function test_bbp_time_since_year_month() {
  66          $now = time();
  67          $then = $now - YEAR_IN_SECONDS - ( 1 * 30 * DAY_IN_SECONDS );
  68          $since = '1 year, 1 month ago';
  69  
  70          // Output.
  71          $this->expectOutputString( $since );
  72          bbp_time_since( $then, $now );
  73  
  74          // Formatted.
  75          $this->assertEquals( $since, bbp_get_time_since( $then, $now ) );
  76      }
  77  
  78      /**
  79       * @covers ::bbp_time_since
  80       * @covers ::bbp_get_time_since
  81       */
  82  	public function test_bbp_time_since_years_nomonths() {
  83          $now = time();
  84          $then = $now - ( 3 * YEAR_IN_SECONDS );
  85          $since = '3 years ago';
  86  
  87          // Output.
  88          $this->expectOutputString( $since );
  89          bbp_time_since( $then, $now );
  90  
  91          // Formatted.
  92          $this->assertEquals( $since, bbp_get_time_since( $then, $now ) );
  93      }
  94  
  95      /**
  96       * @covers ::bbp_time_since
  97       * @covers ::bbp_get_time_since
  98       */
  99  	public function test_bbp_time_since_year_nomonths() {
 100          $now = time();
 101          $then = $now - YEAR_IN_SECONDS ;
 102          $since = '1 year ago';
 103  
 104          // Output.
 105          $this->expectOutputString( $since );
 106          bbp_time_since( $then, $now );
 107  
 108          // Formatted.
 109          $this->assertEquals( $since, bbp_get_time_since( $then, $now ) );
 110      }
 111  
 112      /**
 113       * @covers ::bbp_time_since
 114       * @covers ::bbp_get_time_since
 115       */
 116  	public function test_bbp_time_since_months_weeks() {
 117          $now = time();
 118          $then = $now - ( 3 * 30 * DAY_IN_SECONDS ) - ( 3 * WEEK_IN_SECONDS );
 119          $since = '3 months, 3 weeks ago';
 120  
 121          // Output.
 122          $this->expectOutputString( $since );
 123          bbp_time_since( $then, $now );
 124  
 125          // Formatted.
 126          $this->assertEquals( $since, bbp_get_time_since( $then, $now ) );
 127      }
 128  
 129      /**
 130       * @covers ::bbp_time_since
 131       * @covers ::bbp_get_time_since
 132       */
 133  	public function test_bbp_time_since_month_week() {
 134          $now = time();
 135          $then = $now - ( 1 * 30 * DAY_IN_SECONDS ) - ( 1 * WEEK_IN_SECONDS );
 136          $since = '1 month, 1 week ago';
 137  
 138          // Output.
 139          $this->expectOutputString( $since );
 140          bbp_time_since( $then, $now );
 141  
 142          // Formatted.
 143          $this->assertEquals( $since, bbp_get_time_since( $then, $now ) );
 144      }
 145  
 146      /**
 147       * @covers ::bbp_time_since
 148       * @covers ::bbp_get_time_since
 149       */
 150  	public function test_bbp_time_since_months_noweeks() {
 151          $now = time();
 152          $then = $now - ( 3 * 30 * DAY_IN_SECONDS );
 153          $since = '3 months ago';
 154  
 155          // Output.
 156          $this->expectOutputString( $since );
 157          bbp_time_since( $then, $now );
 158  
 159          // Formatted.
 160          $this->assertEquals( $since, bbp_get_time_since( $then, $now ) );
 161      }
 162  
 163      /**
 164       * @covers ::bbp_time_since
 165       * @covers ::bbp_get_time_since
 166       */
 167  	public function test_bbp_time_since_month_noweeks() {
 168          $now = time();
 169          $then = $now - ( 1 * 30 * DAY_IN_SECONDS );
 170          $since = '1 month ago';
 171  
 172          // Output.
 173          $this->expectOutputString( $since );
 174          bbp_time_since( $then, $now );
 175  
 176          // Formatted.
 177          $this->assertEquals( $since, bbp_get_time_since( $then, $now ) );
 178      }
 179  
 180      /**
 181       * @covers ::bbp_time_since
 182       * @covers ::bbp_get_time_since
 183       */
 184  	public function test_bbp_time_since_weeks_days() {
 185          $now = time();
 186          $then = $now - ( 3 * WEEK_IN_SECONDS ) - ( 3 * DAY_IN_SECONDS );
 187          $since = '3 weeks, 3 days ago';
 188  
 189          // Output.
 190          $this->expectOutputString( $since );
 191          bbp_time_since( $then, $now );
 192  
 193          // Formatted.
 194          $this->assertEquals( $since, bbp_get_time_since( $then, $now ) );
 195      }
 196  
 197      /**
 198       * @covers ::bbp_time_since
 199       * @covers ::bbp_get_time_since
 200       */
 201  	public function test_bbp_time_since_week_day() {
 202          $now = time();
 203          $then = $now - ( 1 * WEEK_IN_SECONDS ) - ( 1 * DAY_IN_SECONDS );
 204          $since = '1 week, 1 day ago';
 205  
 206          // Output.
 207          $this->expectOutputString( $since );
 208          bbp_time_since( $then, $now );
 209  
 210          // Formatted.
 211          $this->assertEquals( $since, bbp_get_time_since( $then, $now ) );
 212      }
 213  
 214      /**
 215       * @covers ::bbp_time_since
 216       * @covers ::bbp_get_time_since
 217       */
 218  	public function test_bbp_time_since_weeks_nodays() {
 219          $now = time();
 220          $then = $now - ( 3 * WEEK_IN_SECONDS );
 221          $since = '3 weeks ago';
 222  
 223          // Output.
 224          $this->expectOutputString( $since );
 225          bbp_time_since( $then, $now );
 226  
 227          // Formatted.
 228          $this->assertEquals( $since, bbp_get_time_since( $then, $now ) );
 229      }
 230  
 231      /**
 232       * @covers ::bbp_time_since
 233       * @covers ::bbp_get_time_since
 234       */
 235  	public function test_bbp_time_since_week_nodays() {
 236          $now = time();
 237          $then = $now - ( 1 * WEEK_IN_SECONDS );
 238          $since = '1 week ago';
 239  
 240          // Output.
 241          $this->expectOutputString( $since );
 242          bbp_time_since( $then, $now );
 243  
 244          // Formatted.
 245          $this->assertEquals( $since, bbp_get_time_since( $then, $now ) );
 246      }
 247  
 248      /**
 249       * @covers ::bbp_time_since
 250       * @covers ::bbp_get_time_since
 251       */
 252  	public function test_bbp_time_since_days_hours() {
 253          $now = time();
 254          $then = $now - ( 3 * DAY_IN_SECONDS ) - ( 3 * HOUR_IN_SECONDS );
 255          $since = '3 days, 3 hours ago';
 256  
 257          // Output.
 258          $this->expectOutputString( $since );
 259          bbp_time_since( $then, $now );
 260  
 261          // Formatted.
 262          $this->assertEquals( $since, bbp_get_time_since( $then, $now ) );
 263      }
 264  
 265      /**
 266       * @covers ::bbp_time_since
 267       * @covers ::bbp_get_time_since
 268       */
 269  	public function test_bbp_time_since_day_hour() {
 270          $now = time();
 271          $then = $now - ( 1 * DAY_IN_SECONDS ) - ( 1 * HOUR_IN_SECONDS );
 272          $since = '1 day, 1 hour ago';
 273  
 274          // Output.
 275          $this->expectOutputString( $since );
 276          bbp_time_since( $then, $now );
 277  
 278          // Formatted.
 279          $this->assertEquals( $since, bbp_get_time_since( $then, $now ) );
 280      }
 281  
 282      /**
 283       * @covers ::bbp_time_since
 284       * @covers ::bbp_get_time_since
 285       */
 286  	public function test_bbp_time_since_days_nohours() {
 287          $now = time();
 288          $then = $now - ( 3 * DAY_IN_SECONDS );
 289          $since = '3 days ago';
 290  
 291          // Output.
 292          $this->expectOutputString( $since );
 293          bbp_time_since( $then, $now );
 294  
 295          // Formatted.
 296          $this->assertEquals( $since, bbp_get_time_since( $then, $now ) );
 297      }
 298  
 299      /**
 300       * @covers ::bbp_time_since
 301       * @covers ::bbp_get_time_since
 302       */
 303  	public function test_bbp_time_since_day_nohours() {
 304          $now = time();
 305          $then = $now - ( 1 * DAY_IN_SECONDS );
 306          $since = '1 day ago';
 307  
 308          // Output.
 309          $this->expectOutputString( $since );
 310          bbp_time_since( $then, $now );
 311  
 312          // Formatted.
 313          $this->assertEquals( $since, bbp_get_time_since( $then, $now ) );
 314      }
 315  
 316      /**
 317       * @covers ::bbp_time_since
 318       * @covers ::bbp_get_time_since
 319       */
 320  	public function test_bbp_time_since_hours_minutes() {
 321          $now = time();
 322          $then = $now - ( 3 * HOUR_IN_SECONDS ) - ( 3 * MINUTE_IN_SECONDS );
 323          $since = '3 hours, 3 minutes ago';
 324  
 325          // Output.
 326          $this->expectOutputString( $since );
 327          bbp_time_since( $then, $now );
 328  
 329          // Formatted.
 330          $this->assertEquals( $since, bbp_get_time_since( $then, $now ) );
 331      }
 332  
 333      /**
 334       * @covers ::bbp_time_since
 335       * @covers ::bbp_get_time_since
 336       */
 337  	public function test_bbp_time_since_hour_minute() {
 338          $now = time();
 339          $then = $now - ( 1 * HOUR_IN_SECONDS ) - ( 1 * MINUTE_IN_SECONDS );
 340          $since = '1 hour, 1 minute ago';
 341  
 342          // Output.
 343          $this->expectOutputString( $since );
 344          bbp_time_since( $then, $now );
 345  
 346          // Formatted.
 347          $this->assertEquals( $since, bbp_get_time_since( $then, $now ) );
 348      }
 349  
 350      /**
 351       * @covers ::bbp_time_since
 352       * @covers ::bbp_get_time_since
 353       */
 354  	public function test_bbp_time_since_hours_nominutes() {
 355          $now = time();
 356          $then = $now - ( 3 * HOUR_IN_SECONDS );
 357          $since = '3 hours ago';
 358  
 359          // Output.
 360          $this->expectOutputString( $since );
 361          bbp_time_since( $then, $now );
 362  
 363          // Formatted.
 364          $this->assertEquals( $since, bbp_get_time_since( $then, $now ) );
 365      }
 366  
 367      /**
 368       * @covers ::bbp_time_since
 369       * @covers ::bbp_get_time_since
 370       */
 371  	public function test_bbp_time_since_hour_nominutes() {
 372          $now = time();
 373          $then = $now - ( 1 * HOUR_IN_SECONDS );
 374          $since = '1 hour ago';
 375  
 376          // Output.
 377          $this->expectOutputString( $since );
 378          bbp_time_since( $then, $now );
 379  
 380          // Formatted.
 381          $this->assertEquals( $since, bbp_get_time_since( $then, $now ) );
 382      }
 383      /**
 384       * @covers ::bbp_time_since
 385       * @covers ::bbp_get_time_since
 386       */
 387  	public function test_bbp_time_since_minutes_seconds() {
 388          $now = time();
 389          $then = $now - ( 3 * MINUTE_IN_SECONDS ) - 3;
 390          $since = '3 minutes ago';
 391  
 392          // Output.
 393          $this->expectOutputString( $since );
 394          bbp_time_since( $then, $now );
 395  
 396          // Formatted.
 397          $this->assertEquals( $since, bbp_get_time_since( $then, $now ) );
 398      }
 399  
 400      /**
 401       * @covers ::bbp_time_since
 402       * @covers ::bbp_get_time_since
 403       */
 404  	public function test_bbp_time_since_minutes_noseconds() {
 405          $now = time();
 406          $then = $now - ( 3 * MINUTE_IN_SECONDS );
 407          $since = '3 minutes ago';
 408  
 409          // Output.
 410          $this->expectOutputString( $since );
 411          bbp_time_since( $then, $now );
 412  
 413          // Formatted.
 414          $this->assertEquals( $since, bbp_get_time_since( $then, $now ) );
 415      }
 416  
 417      /**
 418       * @covers ::bbp_time_since
 419       * @covers ::bbp_get_time_since
 420       */
 421  	public function test_bbp_time_since_minute_noseconds() {
 422          $now = time();
 423          $then = $now - ( 1 * MINUTE_IN_SECONDS );
 424          $since = '1 minute ago';
 425  
 426          // Output.
 427          $this->expectOutputString( $since );
 428          bbp_time_since( $then, $now );
 429  
 430          // Formatted.
 431          $this->assertEquals( $since, bbp_get_time_since( $then, $now ) );
 432      }
 433  
 434      /**
 435       * @covers ::bbp_time_since
 436       * @covers ::bbp_get_time_since
 437       */
 438  	public function test_bbp_time_since_seconds() {
 439          $now = time();
 440          $then = $now - 3;
 441          $since = '3 seconds ago';
 442  
 443          // Output.
 444          $this->expectOutputString( $since );
 445          bbp_time_since( $then, $now );
 446  
 447          // Formatted.
 448          $this->assertEquals( $since, bbp_get_time_since( $then, $now ) );
 449      }
 450  
 451      /**
 452       * @covers ::bbp_time_since
 453       * @covers ::bbp_get_time_since
 454       */
 455  	public function test_bbp_time_since_second() {
 456          $now = time();
 457          $then = $now - 1;
 458          $since = '1 second ago';
 459  
 460          // Output.
 461          $this->expectOutputString( $since );
 462          bbp_time_since( $then, $now );
 463  
 464          // Formatted.
 465          $this->assertEquals( $since, bbp_get_time_since( $then, $now ) );
 466      }
 467  
 468      /**
 469       * @covers ::bbp_time_since
 470       * @covers ::bbp_get_time_since
 471       */
 472  	public function test_bbp_time_since_rightnow() {
 473          $now = time();
 474          $then = $now;
 475          $since = 'right now';
 476  
 477          // Output.
 478          $this->expectOutputString( $since );
 479          bbp_time_since( $then, $now );
 480  
 481          // Formatted.
 482          $this->assertEquals( $since, bbp_get_time_since( $then, $now ) );
 483      }
 484  
 485      /**
 486       * @covers ::bbp_time_since
 487       * @covers ::bbp_get_time_since
 488       */
 489  	public function test_bbp_time_since_future() {
 490          $now = time();
 491          $then = $now + 100;
 492          $since = 'sometime ago';
 493  
 494          // Output.
 495          $this->expectOutputString( $since );
 496          bbp_time_since( $then, $now );
 497  
 498          // Formatted.
 499          $this->assertEquals( $since, bbp_get_time_since( $then, $now ) );
 500      }
 501  
 502      /**
 503       * @covers ::bbp_time_since
 504       * @covers ::bbp_get_time_since
 505       */
 506  	public function test_bbp_time_since_timezone_minute_ago() {
 507          $now = time();
 508          $then = $now - ( 1 * MINUTE_IN_SECONDS );
 509          $since = '1 minute ago';
 510  
 511          // Backup timezone.
 512          $tz_backup = date_default_timezone_get();
 513  
 514          // Set timezone to something other than UTC.
 515          date_default_timezone_set( 'Europe/Paris' );
 516  
 517          // Output.
 518          $this->expectOutputString( $since );
 519          bbp_time_since( $then, $now );
 520  
 521          // Formatted.
 522          $this->assertSame( $since, bbp_get_time_since( $then, $now, $gmt = false ) );
 523  
 524          // Revert timezone back to normal.
 525          if ( $tz_backup ) {
 526              date_default_timezone_set( $tz_backup );
 527          }
 528      }
 529  
 530      /**
 531       * @covers ::bbp_time_since
 532       * @covers ::bbp_get_time_since
 533       */
 534  	public function test_bbp_time_since_timezone() {
 535          $now = time();
 536          $then = $now - ( 1 * HOUR_IN_SECONDS );
 537          $since = '1 hour ago';
 538  
 539          // Backup timezone.
 540          $tz_backup = date_default_timezone_get();
 541  
 542          // Set timezone to something other than UTC.
 543          date_default_timezone_set( 'Europe/Paris' );
 544  
 545          // Output.
 546          $this->expectOutputString( $since );
 547          bbp_time_since( $then, $now );
 548  
 549          // Formatted.
 550          $this->assertSame( $since, bbp_get_time_since( $then, $now, true ) );
 551  
 552          // Revert timezone back to normal.
 553          if ( $tz_backup ) {
 554              date_default_timezone_set( $tz_backup );
 555          }
 556      }
 557  
 558      /**
 559       * @covers ::bbp_format_revision_reason
 560       * @todo   Implement test_bbp_format_revision_reason().
 561       */
 562  	public function test_bbp_format_revision_reason() {
 563          // Remove the following lines when you implement this test.
 564          $this->markTestIncomplete(
 565              'This test has not been implemented yet.'
 566          );
 567      }
 568  
 569      /**
 570       * @covers ::bbp_get_redirect_to
 571       * @todo   Implement test_bbp_get_redirect_to().
 572       */
 573  	public function test_bbp_get_redirect_to() {
 574          // Remove the following lines when you implement this test.
 575          $this->markTestIncomplete(
 576              'This test has not been implemented yet.'
 577          );
 578      }
 579  
 580      /**
 581       * @covers ::bbp_add_view_all
 582       * @todo   Implement test_bbp_add_view_all().
 583       */
 584  	public function test_bbp_add_view_all() {
 585          // Remove the following lines when you implement this test.
 586          $this->markTestIncomplete(
 587              'This test has not been implemented yet.'
 588          );
 589      }
 590  
 591      /**
 592       * @covers ::bbp_remove_view_all
 593       * @todo   Implement test_bbp_remove_view_all().
 594       */
 595  	public function test_bbp_remove_view_all() {
 596          // Remove the following lines when you implement this test.
 597          $this->markTestIncomplete(
 598              'This test has not been implemented yet.'
 599          );
 600      }
 601  
 602      /**
 603       * @covers ::bbp_get_view_all
 604       * @todo   Implement test_bbp_get_view_all().
 605       */
 606  	public function test_bbp_get_view_all() {
 607          // Remove the following lines when you implement this test.
 608          $this->markTestIncomplete(
 609              'This test has not been implemented yet.'
 610          );
 611      }
 612  
 613      /**
 614       * @covers ::bbp_get_paged
 615       * @todo   Implement test_bbp_get_paged().
 616       */
 617  	public function test_bbp_get_paged() {
 618          // Remove the following lines when you implement this test.
 619          $this->markTestIncomplete(
 620              'This test has not been implemented yet.'
 621          );
 622      }
 623  
 624      /**
 625       * @covers ::bbp_fix_post_author
 626       * @todo   Implement test_bbp_fix_post_author().
 627       */
 628  	public function test_bbp_fix_post_author() {
 629          // Remove the following lines when you implement this test.
 630          $this->markTestIncomplete(
 631              'This test has not been implemented yet.'
 632          );
 633      }
 634  
 635      /**
 636       * @group  locking
 637       * @covers ::bbp_past_edit_lock
 638       */
 639  	public function test_bbp_past_edit_lock_before_5_minutes() {
 640          update_option( '_bbp_edit_lock', 5 );
 641          update_option( '_bbp_allow_content_edit', true );
 642  
 643          // Before
 644          $result = bbp_past_edit_lock( '4 minutes 59 seconds ago UTC' );
 645          $this->assertFalse( $result );
 646      }
 647  
 648      /**
 649       * @group  locking
 650       * @covers ::bbp_past_edit_lock
 651       */
 652  	public function test_bbp_past_edit_lock_on_5_minutes() {
 653          update_option( '_bbp_edit_lock', 5 );
 654          update_option( '_bbp_allow_content_edit', true );
 655  
 656          // On
 657          $result = bbp_past_edit_lock( '5 minutes ago UTC' );
 658          $this->assertTrue( $result );
 659      }
 660  
 661      /**
 662       * @group  locking
 663       * @covers ::bbp_past_edit_lock
 664       */
 665  	public function test_bbp_past_edit_lock_after_5_minutes() {
 666          update_option( '_bbp_edit_lock', 5 );
 667          update_option( '_bbp_allow_content_edit', true );
 668  
 669          // After
 670          $result = bbp_past_edit_lock( '5 minutes 1 second ago UTC' );
 671          $this->assertTrue( $result );
 672      }
 673  
 674      /**
 675       * @group  locking
 676       * @covers ::bbp_past_edit_lock
 677       */
 678  	public function test_bbp_past_edit_lock_before_0_minutes() {
 679          update_option( '_bbp_edit_lock', 0 );
 680          update_option( '_bbp_allow_content_edit', true );
 681  
 682          // Before
 683          $result = bbp_past_edit_lock( '4 minutes 59 seconds ago UTC' );
 684          $this->assertFalse( $result );
 685      }
 686  
 687      /**
 688       * @group  locking
 689       * @covers ::bbp_past_edit_lock
 690       */
 691  	public function test_bbp_past_edit_lock_on_0_minutes() {
 692          update_option( '_bbp_edit_lock', 0 );
 693          update_option( '_bbp_allow_content_edit', true );
 694  
 695          // On
 696          $result = bbp_past_edit_lock( '5 minutes ago UTC' );
 697          $this->assertFalse( $result );
 698      }
 699  
 700      /**
 701       * @group  locking
 702       * @covers ::bbp_past_edit_lock
 703       */
 704  	public function test_bbp_past_edit_lock_after_0_minutes() {
 705          update_option( '_bbp_edit_lock', 0 );
 706          update_option( '_bbp_allow_content_edit', true );
 707  
 708          // After
 709          $result = bbp_past_edit_lock( '5 minutes 1 second ago UTC' );
 710          $this->assertFalse( $result );
 711      }
 712  
 713      /**
 714       * @covers ::bbp_get_statistics
 715       * @todo   Implement test_bbp_get_statistics().
 716       */
 717  	public function test_bbp_get_statistics() {
 718          // Remove the following lines when you implement this test.
 719          $this->markTestIncomplete(
 720              'This test has not been implemented yet.'
 721          );
 722      }
 723  
 724      /**
 725       * @covers ::bbp_filter_anonymous_post_data
 726       * @todo   Implement test_bbp_filter_anonymous_post_data().
 727       */
 728  	public function test_bbp_filter_anonymous_post_data() {
 729          // Remove the following lines when you implement this test.
 730          $this->markTestIncomplete(
 731              'This test has not been implemented yet.'
 732          );
 733      }
 734  
 735      /**
 736       * @covers ::bbp_check_for_duplicate
 737       * @todo   Implement test_bbp_check_for_duplicate().
 738       */
 739  	public function test_bbp_check_for_duplicate() {
 740          // Remove the following lines when you implement this test.
 741          $this->markTestIncomplete(
 742              'This test has not been implemented yet.'
 743          );
 744      }
 745  
 746      /**
 747       * @covers ::bbp_check_for_flood
 748       * @todo   Implement test_bbp_check_for_flood().
 749       */
 750  	public function test_bbp_check_for_flood() {
 751          // Remove the following lines when you implement this test.
 752          $this->markTestIncomplete(
 753              'This test has not been implemented yet.'
 754          );
 755      }
 756  
 757      /**
 758       * @covers ::bbp_check_for_moderation
 759       */
 760  	public function test_bbp_check_for_moderation() {
 761          $anonymous_data = false;
 762          $author_id      = 0;
 763          $title          = 'Sting';
 764          $content        = 'Beware, there maybe bees hibernating.';
 765  
 766          update_option( 'moderation_keys',"hibernating\nfoo" );
 767  
 768          $result = bbp_check_for_moderation( $anonymous_data, $author_id, $title, $content );
 769  
 770          $this->assertFalse( $result );
 771  
 772          update_option( 'moderation_keys',"foo\nbar" );
 773  
 774          $result = bbp_check_for_moderation( $anonymous_data, $author_id, $title, $content );
 775  
 776          $this->assertTrue( $result );
 777      }
 778  
 779      /**
 780       * @covers ::bbp_check_for_moderation
 781       */
 782      public function test_should_return_false_for_user_url_moderation_check() {
 783          $u = $this->factory->user->create( array(
 784              'user_url'   => 'http://example.net/banned',
 785          ) );
 786  
 787          $t = $this->factory->topic->create( array(
 788              'post_author' => $u,
 789              'post_title' => 'Sting',
 790              'post_content' => 'Beware, there maybe bees hibernating.',
 791          ) );
 792  
 793          $anonymous_data = false;
 794          $author_id      = bbp_get_topic_author_id( $t );
 795          $title          = bbp_get_topic_title( $t );
 796          $content        = bbp_get_topic_content( $t );
 797  
 798          update_option( 'moderation_keys',"http://example.net/banned\nfoo" );
 799  
 800          $result = bbp_check_for_moderation( $anonymous_data, $author_id, $title, $content );
 801  
 802          $this->assertFalse( $result );
 803      }
 804  
 805      /**
 806       * @covers ::bbp_check_for_moderation
 807       */
 808      public function test_should_return_false_for_user_email_moderation_check() {
 809          $u = $this->factory->user->create( array(
 810              'user_email' => 'banned@example.net',
 811          ) );
 812  
 813          $t = $this->factory->topic->create( array(
 814              'post_author' => $u,
 815              'post_title' => 'Sting',
 816              'post_content' => 'Beware, there maybe bees hibernating.',
 817          ) );
 818  
 819          $anonymous_data = false;
 820          $author_id      = bbp_get_topic_author_id( $t );
 821          $title          = bbp_get_topic_title( $t );
 822          $content        = bbp_get_topic_content( $t );
 823  
 824          update_option( 'moderation_keys',"banned@example.net\nfoo" );
 825  
 826          $result = bbp_check_for_moderation( $anonymous_data, $author_id, $title, $content );
 827  
 828          $this->assertFalse( $result );
 829      }
 830  
 831      /**
 832       * @covers ::bbp_check_for_moderation
 833       */
 834      public function test_should_return_false_for_user_ip_moderation_check() {
 835          $u = $this->factory->user->create();
 836  
 837          $t = $this->factory->topic->create( array(
 838              'post_author' => $u,
 839              'post_title' => 'Sting',
 840              'post_content' => 'Beware, there maybe bees hibernating.',
 841          ) );
 842  
 843          $anonymous_data = false;
 844          $author_id      = bbp_get_topic_author_id( $t );
 845          $title          = bbp_get_topic_title( $t );
 846          $content        = bbp_get_topic_content( $t );
 847  
 848          update_option( 'moderation_keys',"127.0.0.1\nfoo" );
 849  
 850          $result = bbp_check_for_moderation( $anonymous_data, $author_id, $title, $content );
 851  
 852          $this->assertFalse( $result );
 853      }
 854  
 855      /**
 856       * @covers ::bbp_check_for_moderation
 857       */
 858      public function test_should_return_true_for_moderators_to_bypass_moderation_check() {
 859          // Create a moderator user.
 860          $this->old_current_user = get_current_user_id();
 861          $this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
 862          $this->moderator_id = get_current_user_id();
 863          bbp_set_user_role( $this->moderator_id, bbp_get_moderator_role() );
 864  
 865          $t = $this->factory->topic->create( array(
 866              'post_author' => bbp_get_current_user_id(),
 867              'post_title' => 'Sting',
 868              'post_content' => 'Beware, there maybe bees hibernating.',
 869          ) );
 870  
 871          $anonymous_data = false;
 872          $author_id      = bbp_get_topic_author_id( $t );
 873          $title          = bbp_get_topic_title( $t );
 874          $content        = bbp_get_topic_content( $t );
 875  
 876          update_option( 'moderation_keys',"hibernating\nfoo" );
 877  
 878          $result = bbp_check_for_moderation( $anonymous_data, $author_id, $title, $content );
 879  
 880          $this->assertTrue( $result );
 881  
 882          // Retore the original user.
 883          $this->set_current_user( $this->old_current_user );
 884      }
 885  
 886      /**
 887       * @covers ::bbp_check_for_moderation
 888       */
 889      public function test_should_return_false_when_link_count_exceeds_comment_max_links_setting() {
 890          $anonymous_data = false;
 891          $author_id      = 0;
 892          $title          = 'Sting';
 893          $content        = 'This is a post with <a href="http://example.com">multiple</a> <a href="http://bob.example.com">links</a>.';
 894  
 895          update_option( 'comment_max_links', 2 );
 896          $results = bbp_check_for_moderation( $anonymous_data, $author_id, $title, $content );
 897          $this->assertFalse( $results );
 898      }
 899  
 900      /**
 901       * @covers ::bbp_check_for_moderation
 902       */
 903      public function test_should_return_true_when_link_count_does_not_exceed_comment_max_links_setting() {
 904          $anonymous_data = false;
 905          $author_id      = 0;
 906          $title          = 'Sting';
 907          $content        = 'This is a post with <a href="http://example.com">multiple</a> <a href="http://bob.example.com">links</a>.';
 908  
 909          update_option( 'comment_max_links', 3 );
 910          $results = bbp_check_for_moderation( $anonymous_data, $author_id, $title, $content );
 911          $this->assertTrue( $results );
 912      }
 913  
 914      /**
 915       * @covers ::bbp_check_for_moderation
 916       */
 917      public function test_should_return_false_when_link_matches_moderation_keys() {
 918          $anonymous_data = false;
 919          $author_id      = 0;
 920          $title          = 'Sting';
 921          $content        = 'Beware, there maybe bees <a href="http://example.com/hibernating/>buzzing</a>, buzzing.';
 922  
 923          update_option( 'moderation_keys',"hibernating\nfoo" );
 924  
 925          $result = bbp_check_for_moderation( $anonymous_data, $author_id, $title, $content );
 926  
 927          $this->assertFalse( $result );
 928      }
 929  
 930      /**
 931       * @covers ::bbp_check_for_moderation
 932       */
 933      public function test_should_return_false_when_html_wrapped_content_matches_moderation_keys() {
 934          $u = $this->factory->user->create();
 935  
 936          $t = $this->factory->topic->create( array(
 937              'post_author' => $u,
 938              'post_title' => 'Sting',
 939              'post_content' => 'Beware, there maybe bees <strong>hiber</strong><em>nating</em>.',
 940          ) );
 941  
 942          $anonymous_data = false;
 943          $author_id      = bbp_get_topic_author_id( $t );
 944          $title          = bbp_get_topic_title( $t );
 945          $content        = bbp_get_topic_content( $t );
 946  
 947          update_option( 'moderation_keys',"hibernating\nfoo" );
 948  
 949          $result = bbp_check_for_moderation( $anonymous_data, $author_id, $title, $content );
 950  
 951          $this->assertFalse( $result );
 952      }
 953  
 954      /**
 955       * @covers ::bbp_check_for_moderation
 956       */
 957  	public function test_bbp_check_for_moderation_strict() {
 958          $anonymous_data = false;
 959          $author_id      = 0;
 960          $title          = 'Sting';
 961          $content        = 'Beware, they maybe bees hibernating.';
 962  
 963          update_option( 'blacklist_keys',"hibernating\nfoo" );
 964  
 965          $result = bbp_check_for_moderation( $anonymous_data, $author_id, $title, $content, true );
 966  
 967          $this->assertFalse( $result );
 968  
 969          update_option( 'blacklist_keys',"foo\nbar" );
 970  
 971          $result = bbp_check_for_moderation( $anonymous_data, $author_id, $title, $content, true );
 972  
 973          $this->assertTrue( $result );
 974      }
 975  
 976      /**
 977       * @covers ::bbp_check_for_moderation
 978       */
 979      public function test_should_return_false_for_user_url_strict_moderation_check() {
 980          $u = $this->factory->user->create( array(
 981              'user_url'   => 'http://example.net/banned',
 982          ) );
 983  
 984          $t = $this->factory->topic->create( array(
 985              'post_author' => $u,
 986              'post_title' => 'Sting',
 987              'post_content' => 'Beware, there maybe bees hibernating.',
 988          ) );
 989  
 990          $anonymous_data = false;
 991          $author_id      = bbp_get_topic_author_id( $t );
 992          $title          = bbp_get_topic_title( $t );
 993          $content        = bbp_get_topic_content( $t );
 994  
 995          update_option( 'blacklist_keys',"http://example.net/banned\nfoo" );
 996  
 997          $result = bbp_check_for_moderation( $anonymous_data, $author_id, $title, $content, true );
 998  
 999          $this->assertFalse( $result );
1000      }
1001  
1002      /**
1003       * @covers ::bbp_check_for_moderation
1004       */
1005      public function test_should_return_false_for_user_email_strict_moderation_check() {
1006          $u = $this->factory->user->create( array(
1007              'user_email' => 'banned@example.net',
1008          ) );
1009  
1010          $t = $this->factory->topic->create( array(
1011              'post_author' => $u,
1012              'post_title' => 'Sting',
1013              'post_content' => 'Beware, there maybe bees hibernating.',
1014          ) );
1015  
1016          $anonymous_data = false;
1017          $author_id      = bbp_get_topic_author_id( $t );
1018          $title          = bbp_get_topic_title( $t );
1019          $content        = bbp_get_topic_content( $t );
1020  
1021          update_option( 'blacklist_keys',"banned@example.net\nfoo" );
1022  
1023          $result = bbp_check_for_moderation( $anonymous_data, $author_id, $title, $content, true );
1024  
1025          $this->assertFalse( $result );
1026      }
1027  
1028      /**
1029       * @covers ::bbp_check_for_moderation
1030       */
1031      public function test_should_return_false_for_user_ip_strict_moderation_check() {
1032          $u = $this->factory->user->create();
1033  
1034          $t = $this->factory->topic->create( array(
1035              'post_author' => $u,
1036              'post_title' => 'Sting',
1037              'post_content' => 'Beware, there maybe bees hibernating.',
1038          ) );
1039  
1040          $anonymous_data = false;
1041          $author_id      = bbp_get_topic_author_id( $t );
1042          $title          = bbp_get_topic_title( $t );
1043          $content        = bbp_get_topic_content( $t );
1044  
1045          update_option( 'blacklist_keys',"127.0.0.1\nfoo" );
1046  
1047          $result = bbp_check_for_moderation( $anonymous_data, $author_id, $title, $content, true );
1048  
1049          $this->assertFalse( $result );
1050      }
1051  
1052      /**
1053       * @covers ::bbp_check_for_moderation
1054       */
1055      public function test_should_return_false_for_moderators_to_bypass_strict_moderation_check() {
1056          // Create a moderator user.
1057          $this->old_current_user = get_current_user_id();
1058          $this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
1059          $this->moderator_id = get_current_user_id();
1060          bbp_set_user_role( $this->moderator_id, bbp_get_moderator_role() );
1061  
1062          $t = $this->factory->topic->create( array(
1063              'post_author' => bbp_get_current_user_id(),
1064              'post_title' => 'Sting',
1065              'post_content' => 'Beware, there maybe bees hibernating.',
1066          ) );
1067  
1068          $anonymous_data = false;
1069          $author_id      = bbp_get_topic_author_id( $t );
1070          $title          = bbp_get_topic_title( $t );
1071          $content        = bbp_get_topic_content( $t );
1072  
1073          update_option( 'blacklist_keys',"hibernating\nfoo" );
1074  
1075          $result = bbp_check_for_moderation( $anonymous_data, $author_id, $title, $content, true );
1076  
1077          $this->assertFalse( $result );
1078  
1079          // Retore the original user.
1080          $this->set_current_user( $this->old_current_user );
1081      }
1082  
1083      /**
1084       * @covers ::bbp_check_for_moderation
1085       */
1086      public function test_should_return_true_for_keymasterss_to_bypass_strict_moderation_check() {
1087          // Create a keymaster user.
1088          $this->old_current_user = get_current_user_id();
1089          $this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
1090          $this->keymaster_id = get_current_user_id();
1091          bbp_set_user_role( $this->keymaster_id, bbp_get_keymaster_role() );
1092  
1093          $t = $this->factory->topic->create( array(
1094              'post_author' => bbp_get_current_user_id(),
1095              'post_title' => 'Sting',
1096              'post_content' => 'Beware, there maybe bees hibernating.',
1097          ) );
1098  
1099          $anonymous_data = false;
1100          $author_id      = bbp_get_topic_author_id( $t );
1101          $title          = bbp_get_topic_title( $t );
1102          $content        = bbp_get_topic_content( $t );
1103  
1104          update_option( 'blacklist_keys',"hibernating\nfoo" );
1105  
1106          $result = bbp_check_for_moderation( $anonymous_data, $author_id, $title, $content, true );
1107  
1108          $this->assertTrue( $result );
1109  
1110          // Retore the original user.
1111          $this->set_current_user( $this->old_current_user );
1112      }
1113  
1114      /**
1115       * @covers ::bbp_check_for_moderation
1116       */
1117      public function test_should_return_false_when_link_matches_strict_moderation_keys() {
1118          $anonymous_data = false;
1119          $author_id      = 0;
1120          $title          = 'Sting';
1121          $content        = 'Beware, there maybe bees <a href="http://example.com/hibernating/>buzzing</a>, buzzing.';
1122  
1123          update_option( 'blacklist_keys',"hibernating\nfoo" );
1124  
1125          $result = bbp_check_for_moderation( $anonymous_data, $author_id, $title, $content, true );
1126  
1127          $this->assertFalse( $result );
1128      }
1129  
1130      /**
1131       * @covers ::bbp_check_for_moderation
1132       */
1133      public function test_should_return_false_when_html_wrapped_content_matches_strict_moderation_keys() {
1134          $u = $this->factory->user->create();
1135  
1136          $t = $this->factory->topic->create( array(
1137              'post_author' => $u,
1138              'post_title' => 'Sting',
1139              'post_content' => 'Beware, there maybe bees <strong>hiber</strong><em>nating</em>.',
1140          ) );
1141  
1142          $anonymous_data = false;
1143          $author_id      = bbp_get_topic_author_id( $t );
1144          $title          = bbp_get_topic_title( $t );
1145          $content        = bbp_get_topic_content( $t );
1146  
1147          update_option( 'blacklist_keys',"hibernating\nfoo" );
1148  
1149          $result = bbp_check_for_moderation( $anonymous_data, $author_id, $title, $content, true );
1150  
1151          $this->assertFalse( $result );
1152      }
1153  
1154      /**
1155       * @covers ::bbp_get_do_not_reply_address
1156       */
1157  	public function test_bbp_get_do_not_reply_address() {
1158  
1159          $_SERVER['SERVER_NAME'] = 'example.org';
1160          $address = bbp_get_do_not_reply_address();
1161          $this->assertEquals( 'noreply@example.org', $address );
1162  
1163          $_SERVER['SERVER_NAME'] = 'www.example.org';
1164          $address = bbp_get_do_not_reply_address();
1165          $this->assertEquals( 'noreply@example.org', $address );
1166  
1167          $_SERVER['SERVER_NAME'] = 'subdomain.example.org';
1168          $address = bbp_get_do_not_reply_address();
1169          $this->assertEquals( 'noreply@subdomain.example.org', $address );
1170  
1171          $_SERVER['SERVER_NAME'] = 'www.subdomain.example.org';
1172          $address = bbp_get_do_not_reply_address();
1173          $this->assertEquals( 'noreply@subdomain.example.org', $address );
1174  
1175          // Reset server name.
1176          $_SERVER['SERVER_NAME'] = 'example.org';
1177      }
1178  
1179      /**
1180       * @covers ::bbp_notify_topic_subscribers
1181       * @todo   Implement test_bbp_notify_topic_subscribers().
1182       */
1183  	public function test_bbp_notify_topic_subscribers() {
1184          // Remove the following lines when you implement this test.
1185          $this->markTestIncomplete(
1186              'This test has not been implemented yet.'
1187          );
1188      }
1189  
1190      /**
1191       * @covers ::bbp_notify_forum_subscribers
1192       * @todo   Implement test_bbp_notify_forum_subscribers().
1193       */
1194  	public function test_bbp_notify_forum_subscribers() {
1195          // Remove the following lines when you implement this test.
1196          $this->markTestIncomplete(
1197              'This test has not been implemented yet.'
1198          );
1199      }
1200  
1201      /**
1202       * @covers ::bbp_notify_subscribers
1203       * @todo   Implement test_bbp_notify_subscribers().
1204       */
1205  	public function test_bbp_notify_subscribers() {
1206          // Remove the following lines when you implement this test.
1207          $this->markTestIncomplete(
1208              'This test has not been implemented yet.'
1209          );
1210      }
1211  
1212      /**
1213       * @covers ::bbp_logout_url
1214       * @todo   Implement test_bbp_logout_url().
1215       */
1216  	public function test_bbp_logout_url() {
1217          // Remove the following lines when you implement this test.
1218          $this->markTestIncomplete(
1219              'This test has not been implemented yet.'
1220          );
1221      }
1222  
1223      /**
1224       * @covers ::bbp_parse_args
1225       * @todo   Implement test_bbp_parse_args().
1226       */
1227  	public function test_bbp_parse_args() {
1228          // Remove the following lines when you implement this test.
1229          $this->markTestIncomplete(
1230              'This test has not been implemented yet.'
1231          );
1232      }
1233  
1234      /**
1235       * @covers ::bbp_get_global_post_field
1236       * @todo   Implement test_bbp_get_global_post_field().
1237       */
1238  	public function test_bbp_get_global_post_field() {
1239          // Remove the following lines when you implement this test.
1240          $this->markTestIncomplete(
1241              'This test has not been implemented yet.'
1242          );
1243      }
1244  
1245      /**
1246       * @covers ::bbp_verify_nonce_request
1247       * @todo   Implement test_bbp_verify_nonce_request().
1248       */
1249  	public function test_bbp_verify_nonce_request() {
1250          // Remove the following lines when you implement this test.
1251          $this->markTestIncomplete(
1252              'This test has not been implemented yet.'
1253          );
1254      }
1255  
1256      /**
1257       * @covers ::bbp_request_feed_trap
1258       * @todo   Implement test_bbp_request_feed_trap().
1259       */
1260  	public function test_bbp_request_feed_trap() {
1261          // Remove the following lines when you implement this test.
1262          $this->markTestIncomplete(
1263              'This test has not been implemented yet.'
1264          );
1265      }
1266  
1267      /**
1268       * @covers ::bbp_get_page_by_path
1269       * @todo   Implement test_bbp_get_page_by_path().
1270       */
1271  	public function test_bbp_get_page_by_path() {
1272          // Remove the following lines when you implement this test.
1273          $this->markTestIncomplete(
1274              'This test has not been implemented yet.'
1275          );
1276      }
1277  
1278      /**
1279       * @covers ::bbp_set_404
1280       * @todo   Implement test_bbp_set_404().
1281       */
1282  	public function test_bbp_set_404() {
1283          // Remove the following lines when you implement this test.
1284          $this->markTestIncomplete(
1285              'This test has not been implemented yet.'
1286          );
1287      }
1288  }


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