Skip to:
Content

bbPress.org

Changeset 5879


Ignore:
Timestamp:
07/24/2015 09:46:21 AM (11 years ago)
Author:
netweb
Message:

Tests: Various topic template tests for BBP_Tests_Topics_Template_Topic

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/topics/template/topic.php

    r5811 r5879  
    2323         * @covers ::bbp_topic_id
    2424         * @covers ::bbp_get_topic_id
    25          * @todo   Implement test_bbp_get_topic_id().
    2625         */
    2726        public function test_bbp_get_topic_id() {
    28                 // Remove the following lines when you implement this test.
    29                 $this->markTestIncomplete(
    30                         'This test has not been implemented yet.'
    31                 );
     27                $f = $this->factory->forum->create();
     28                $t = $this->factory->topic->create( array(
     29                        'post_parent' => $f,
     30                        'topic_meta' => array(
     31                                'forum_id' => $f,
     32                        ),
     33                ) );
     34
     35                $topic_id = bbp_get_topic_id( $t );
     36                $this->assertSame( $t, $topic_id );
    3237        }
    3338
     
    4651         * @covers ::bbp_topic_permalink
    4752         * @covers ::bbp_get_topic_permalink
    48          * @todo   Implement test_bbp_get_topic_permalink().
    4953         */
    5054        public function test_bbp_get_topic_permalink() {
    51                 // Remove the following lines when you implement this test.
    52                 $this->markTestIncomplete(
    53                         'This test has not been implemented yet.'
    54                 );
     55                if ( is_multisite() ) {
     56                        $this->markTestSkipped( 'Skipping URL tests in multiste for now.' );
     57                }
     58                $f = $this->factory->forum->create();
     59                $t = $this->factory->topic->create( array(
     60                        'post_parent' => $f,
     61                        'topic_meta' => array(
     62                                'forum_id' => $f,
     63                        ),
     64                ) );
     65
     66                $topic_permalink = bbp_get_topic_permalink( $t );
     67
     68                $this->expectOutputString( $topic_permalink );
     69                bbp_topic_permalink( $t );
     70
     71                $this->assertSame( 'http://' . WP_TESTS_DOMAIN . '/?topic=topic-1', $topic_permalink );
    5572        }
    5673
     
    5875         * @covers ::bbp_topic_title
    5976         * @covers ::bbp_get_topic_title
    60          * @todo   Implement test_bbp_get_topic_title().
    6177         */
    6278        public function test_bbp_get_topic_title() {
    63                 // Remove the following lines when you implement this test.
    64                 $this->markTestIncomplete(
    65                         'This test has not been implemented yet.'
    66                 );
     79                $f = $this->factory->forum->create();
     80                $t = $this->factory->topic->create( array(
     81                        'post_parent' => $f,
     82                        'topic_meta' => array(
     83                                'forum_id' => $f,
     84                        ),
     85                ) );
     86
     87                $topic_title = bbp_get_topic_title( $t );
     88                $this->assertSame( 'Topic 1', $topic_title );
    6789        }
    6890
     
    82104         * @covers ::bbp_topic_content
    83105         * @covers ::bbp_get_topic_content
    84          * @todo   Implement test_bbp_get_topic_content().
    85106         */
    86107        public function test_bbp_get_topic_content() {
    87                 // Remove the following lines when you implement this test.
    88                 $this->markTestIncomplete(
    89                         'This test has not been implemented yet.'
    90                 );
     108                $f = $this->factory->forum->create();
     109                $t = $this->factory->topic->create( array(
     110                        'post_parent' => $f,
     111                        'topic_meta' => array(
     112                                'forum_id' => $f,
     113                        ),
     114                ) );
     115
     116                remove_all_filters( 'bbp_get_topic_content' );
     117                $topic_content = bbp_get_topic_content( $t );
     118                $this->assertSame( 'Content of Topic 1', $topic_content );
    91119        }
    92120
     
    94122         * @covers ::bbp_topic_excerpt
    95123         * @covers ::bbp_get_topic_excerpt
    96          * @todo   Implement test_bbp_get_topic_excerpt().
    97124         */
    98125        public function test_bbp_get_topic_excerpt() {
    99                 // Remove the following lines when you implement this test.
    100                 $this->markTestIncomplete(
    101                         'This test has not been implemented yet.'
    102                 );
     126                $f = $this->factory->forum->create();
     127                $t = $this->factory->topic->create( array(
     128                        'post_parent' => $f,
     129                        'post_content'  => 'Talk about telekinetic activity, look at this mess!',
     130                        'topic_meta' => array(
     131                                'forum_id' => $f,
     132                        ),
     133                ) );
     134
     135                remove_all_filters( 'bbp_get_topic_content' );
     136                $topic_excerpt = bbp_get_topic_excerpt( $t, 23 );
     137                $this->assertSame( 'Talk about telekinetic…', $topic_excerpt );
    103138        }
    104139
     
    159194         * @covers ::bbp_topic_forum_title
    160195         * @covers ::bbp_get_topic_forum_title
    161          * @todo   Implement test_bbp_get_topic_forum_title().
    162196         */
    163197        public function test_bbp_get_topic_forum_title() {
    164                 // Remove the following lines when you implement this test.
    165                 $this->markTestIncomplete(
    166                         'This test has not been implemented yet.'
    167                 );
     198                $f = $this->factory->forum->create();
     199                $t = $this->factory->topic->create( array(
     200                        'post_parent' => $f,
     201                        'topic_meta' => array(
     202                                'forum_id' => $f,
     203                        ),
     204                ) );
     205
     206                $topic_forum_title = bbp_get_topic_forum_title( $t );
     207                $this->assertSame( bbp_get_forum_title( $f ), $topic_forum_title );
    168208        }
    169209
     
    171211         * @covers ::bbp_topic_forum_id
    172212         * @covers ::bbp_get_topic_forum_id
    173          * @todo   Implement test_bbp_get_topic_forum_id().
    174213         */
    175214        public function test_bbp_get_topic_forum_id() {
    176                 // Remove the following lines when you implement this test.
    177                 $this->markTestIncomplete(
    178                         'This test has not been implemented yet.'
    179                 );
     215                $f = $this->factory->forum->create();
     216                $t = $this->factory->topic->create( array(
     217                        'post_parent' => $f,
     218                        'topic_meta' => array(
     219                                'forum_id' => $f,
     220                        ),
     221                ) );
     222
     223                $topic_forum_id = bbp_get_topic_forum_id( $t );
     224                $this->assertSame( $f, $topic_forum_id );
    180225        }
    181226
Note: See TracChangeset for help on using the changeset viewer.