[ Index ]

PHP Cross Reference of BBPress

title

Body

[close]

/tests/phpunit/testcases/replies/template/ -> status.php (source)

   1  <?php
   2  
   3  /**
   4   * Tests for the reply status template functions.
   5   *
   6   * @group replies
   7   * @group template
   8   * @group status
   9   */
  10  class BBP_Tests_Repliess_Template_Status extends BBP_UnitTestCase {
  11      protected $old_current_user = 0;
  12  
  13  	public function setUp() {
  14          parent::setUp();
  15          $this->old_current_user = get_current_user_id();
  16          $this->set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
  17          $this->keymaster_id = get_current_user_id();
  18          bbp_set_user_role( $this->keymaster_id, bbp_get_keymaster_role() );
  19      }
  20  
  21  	public function tearDown() {
  22          parent::tearDown();
  23          $this->set_current_user( $this->old_current_user );
  24      }
  25  
  26      /**
  27       * @covers ::bbp_reply_status
  28       * @covers ::bbp_get_reply_status
  29       * @todo   Implement test_bbp_get_reply_status().
  30       */
  31  	public function test_bbp_get_reply_status() {
  32          // Remove the following lines when you implement this test.
  33          $this->markTestIncomplete(
  34              'This test has not been implemented yet.'
  35          );
  36  
  37      }
  38  
  39      /**
  40       * @covers ::bbp_is_reply_published
  41       */
  42  	public function test_bbp_is_reply_published() {
  43          $forum_id = $this->factory->forum->create();
  44  
  45          $topic_id = $this->factory->topic->create( array(
  46              'post_parent' => $forum_id,
  47              'topic_meta' => array(
  48                  'forum_id' => $forum_id,
  49              ),
  50          ) );
  51  
  52          $reply_id = $this->factory->reply->create( array(
  53              'post_parent' => $topic_id,
  54              'reply_meta' => array(
  55                  'forum_id' => $forum_id,
  56                  'topic_id' => $topic_id,
  57              ),
  58          ) );
  59  
  60          $r = $this->factory->reply->create( array(
  61              'post_parent' => $topic_id,
  62              'reply_meta' => array(
  63                  'forum_id'              => $forum_id,
  64                  'topic_id'              => $topic_id,
  65              )
  66          ) );
  67  
  68          $reply_published = bbp_is_reply_published( $r );
  69          $this->assertTrue( $reply_published );
  70          $reply_published = bbp_is_reply_published( $reply_id );
  71          $this->assertTrue( $reply_published );
  72      }
  73  
  74      /**
  75       * @covers ::bbp_is_reply_spam
  76       */
  77  	public function test_bbp_is_reply_spam() {
  78          $forum_id = $this->factory->forum->create();
  79  
  80          $topic_id = $this->factory->topic->create( array(
  81              'post_parent' => $forum_id,
  82              'topic_meta' => array(
  83                  'forum_id' => $forum_id,
  84              ),
  85          ) );
  86  
  87          $reply_id = $this->factory->reply->create( array(
  88              'post_parent' => $topic_id,
  89              'reply_meta' => array(
  90                  'forum_id' => $forum_id,
  91                  'topic_id' => $topic_id,
  92              ),
  93          ) );
  94  
  95          $r = $this->factory->reply->create( array(
  96              'post_parent' => $topic_id,
  97              'reply_meta' => array(
  98                  'forum_id'              => $forum_id,
  99                  'topic_id'              => $topic_id,
 100              )
 101          ) );
 102  
 103          bbp_spam_reply( $r );
 104  
 105          $reply_spam = bbp_is_reply_spam( $r );
 106          $this->assertTrue( $reply_spam );
 107  
 108          bbp_unspam_reply( $r );
 109  
 110          $reply_spam = bbp_is_reply_spam( $r );
 111          $this->assertFalse( $reply_spam );
 112      }
 113  
 114      /**
 115       * @covers ::bbp_is_reply_trash
 116       * @todo   Implement test_bbp_is_reply_trash().
 117       */
 118  	public function test_bbp_is_reply_trash() {
 119          // Remove the following lines when you implement this test.
 120          $this->markTestIncomplete(
 121              'This test has not been implemented yet.'
 122          );
 123      }
 124  
 125      /**
 126       * @covers ::bbp_is_reply_pending
 127       */
 128  	public function test_bbp_is_reply_pending() {
 129          $forum_id = $this->factory->forum->create();
 130  
 131          $topic_id = $this->factory->topic->create( array(
 132              'post_parent' => $forum_id,
 133              'topic_meta' => array(
 134                  'forum_id' => $forum_id,
 135              ),
 136          ) );
 137  
 138          $reply_id = $this->factory->reply->create( array(
 139              'post_parent' => $topic_id,
 140              'reply_meta' => array(
 141                  'forum_id' => $forum_id,
 142                  'topic_id' => $topic_id,
 143              ),
 144          ) );
 145  
 146          $r = $this->factory->reply->create( array(
 147              'post_parent' => $topic_id,
 148              'reply_meta' => array(
 149                  'forum_id'              => $forum_id,
 150                  'topic_id'              => $topic_id,
 151              )
 152          ) );
 153  
 154          bbp_unapprove_reply( $r );
 155  
 156          $reply_pending = bbp_is_reply_pending( $r );
 157          $this->assertTrue( $reply_pending );
 158  
 159          bbp_approve_reply( $r );
 160  
 161          $reply_pending = bbp_is_reply_pending( $r );
 162          $this->assertFalse( $reply_pending );
 163      }
 164  
 165      /**
 166       * @covers ::bbp_is_reply_private
 167       */
 168  	public function test_bbp_is_reply_private() {
 169          $forum_id = $this->factory->forum->create();
 170  
 171          $topic_id = $this->factory->topic->create( array(
 172              'post_parent' => $forum_id,
 173              'topic_meta' => array(
 174                  'forum_id' => $forum_id,
 175              ),
 176          ) );
 177  
 178          $reply_id = $this->factory->reply->create( array(
 179              'post_parent' => $topic_id,
 180              'reply_meta' => array(
 181                  'forum_id' => $forum_id,
 182                  'topic_id' => $topic_id,
 183              ),
 184          ) );
 185  
 186          $reply_private = bbp_is_reply_private( $reply_id );
 187          $this->assertFalse( $reply_private );
 188  
 189          $r = $this->factory->reply->create( array(
 190              'post_parent' => $topic_id,
 191              'post_status' => bbp_get_private_status_id(),
 192              'reply_meta' => array(
 193                  'forum_id'              => $forum_id,
 194                  'topic_id'              => $topic_id,
 195              )
 196          ) );
 197  
 198          $reply_private = bbp_is_reply_private( $r );
 199          $this->assertTrue( $reply_private );
 200      }
 201  
 202      /**
 203       * @covers ::bbp_is_reply_anonymous
 204       * @todo   Implement test_bbp_is_reply_anonymous().
 205       */
 206  	public function test_bbp_is_reply_anonymous() {
 207          // Remove the following lines when you implement this test.
 208          $this->markTestIncomplete(
 209              'This test has not been implemented yet.'
 210          );
 211      }
 212  }


Generated: Thu Oct 1 01:01:22 2020 Cross-referenced by PHPXref 0.7.1