[ Index ]

PHP Cross Reference of BBPress

title

Body

[close]

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

   1  <?php
   2  
   3  /**
   4   * Tests for the `bbp_*_form_forum_*` status template functions.
   5   *
   6   * @group forums
   7   * @group template
   8   * @group status
   9   */
  10  class BBP_Tests_Forums_Template_Status extends BBP_UnitTestCase {
  11  
  12      /**
  13       * @covers ::bbp_forum_status
  14       * @covers ::bbp_get_forum_status
  15       */
  16  	public function test_bbp_get_forum_status() {
  17          $f = $this->factory->forum->create();
  18  
  19          $forum = bbp_get_forum_status( $f );
  20          $this->assertSame( 'open', $forum );
  21  
  22          bbp_normalize_forum( $f );
  23          $this->assertSame( 'open', $forum );
  24      }
  25  
  26      /**
  27       * @covers ::bbp_forum_type
  28       * @covers ::bbp_get_forum_type
  29       */
  30  	public function test_bbp_get_forum_type() {
  31          $f = $this->factory->forum->create();
  32  
  33          $forum = bbp_get_forum_type( $f );
  34          $this->assertSame( 'forum', $forum );
  35      }
  36  
  37      /**
  38       * @covers ::bbp_is_forum_category
  39       */
  40  	public function test_bbp_is_forum_category() {
  41          $f = $this->factory->forum->create_many( 2 );
  42  
  43          bbp_normalize_forum( $f[0] );
  44  
  45          $categorize_meta = get_post_meta( $f[0], '_bbp_forum_type', true );
  46          $this->assertSame( 'forum', $categorize_meta );
  47  
  48          $forum = bbp_is_forum_category( $f[0] );
  49          $this->assertFalse( $forum );
  50  
  51          bbp_categorize_forum( $f[1] );
  52  
  53          $categorize_meta = get_post_meta( $f[1], '_bbp_forum_type', true );
  54          $this->assertSame( 'category', $categorize_meta );
  55  
  56          $forum = bbp_is_forum_category( $f[1] );
  57          $this->assertTrue( $forum );
  58  
  59          $f = $this->factory->forum->create( array(
  60              'forum_meta' => array(
  61                  'forum_type' => 'category',
  62              )
  63          ) );
  64  
  65          $forum = bbp_is_forum_category( $f );
  66          $this->assertTrue( $forum );
  67      }
  68  
  69      /**
  70       * @covers ::bbp_is_forum_open
  71       */
  72  	public function test_bbp_is_forum_open() {
  73          $f = $this->factory->forum->create();
  74  
  75          $forum = bbp_is_forum_open( $f );
  76          $this->assertTrue( $forum );
  77      }
  78  
  79      /**
  80       * @covers ::bbp_is_forum_closed
  81       */
  82  	public function test_bbp_is_forum_closed() {
  83          $f = $this->factory->forum->create();
  84  
  85          $forum = bbp_is_forum_closed( $f );
  86          $this->assertFalse( $forum );
  87  
  88          bbp_close_forum( $f );
  89  
  90          $forum = bbp_is_forum_closed( $f );
  91          $this->assertTrue( $forum );
  92      }
  93  
  94      /**
  95       * @covers ::bbp_is_forum_status
  96       * @todo   Implement test_bbp_is_forum_status().
  97       */
  98  	public function test_bbp_is_forum_status() {
  99          // Remove the following lines when you implement this test.
 100          $this->markTestIncomplete(
 101              'This test has not been implemented yet.'
 102          );
 103      }
 104  
 105      /**
 106       * @covers ::bbp_is_forum_public
 107       */
 108  	public function test_bbp_is_forum_public() {
 109          $f = $this->factory->forum->create();
 110  
 111          $forum = bbp_get_forum_visibility( $f );
 112          $this->assertSame( 'publish', $forum );
 113  
 114          $forum_status_id = bbp_get_public_status_id( $f );
 115          $this->assertSame( 'publish', $forum_status_id );
 116  
 117          $forum = bbp_is_forum_public( $f );
 118          $this->assertTrue( bbp_is_forum_public( $f ) );
 119      }
 120  
 121      /**
 122       * @covers ::bbp_is_forum_private
 123       */
 124  	public function test_bbp_is_forum_private() {
 125          $f = $this->factory->forum->create( array(
 126              'post_status' => 'private',
 127          ) );
 128  
 129          $forum = bbp_get_forum_visibility( $f );
 130          $this->assertSame( 'private', $forum );
 131  
 132          $forum_status_id = bbp_get_private_status_id( $f );
 133          $this->assertSame( 'private', $forum_status_id );
 134  
 135          $this->assertTrue( bbp_is_forum_private( $f ) );
 136      }
 137  
 138      /**
 139       * @covers ::bbp_is_forum_hidden
 140       */
 141  	public function test_bbp_is_forum_hidden() {
 142          $f = $this->factory->forum->create( array(
 143              'post_status' => 'hidden',
 144          ) );
 145  
 146          $forum = bbp_get_forum_visibility( $f );
 147          $this->assertSame( 'hidden', $forum );
 148  
 149          $forum_status_id = bbp_get_hidden_status_id( $f );
 150          $this->assertSame( 'hidden', $forum_status_id );
 151  
 152          $this->assertTrue( bbp_is_forum_hidden( $f ) );
 153      }
 154  }


Generated: Tue Mar 19 01:01:02 2024 Cross-referenced by PHPXref 0.7.1