Skip to:
Content

bbPress.org

Changeset 7802


Ignore:
Timestamp:
10/04/2026 09:26:15 AM (5 weeks ago)
Author:
johnjamesjacoby
Message:

Tests: Cover topic update metadata paths.

Verify edit lock cleanup and forum/topic identifiers on edits, plus last activity and reply-count metadata on new-topic updates.

In trunk, for 2.7.

See #3695.

File:
1 edited

Legend:

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

    r7801 r7802  
    108108        /**
    109109         * @covers ::bbp_update_topic
    110          * @todo   Implement test_bbp_update_topic().
    111110         */
    112111        public function test_bbp_update_topic() {
    113                 // Remove the following lines when you implement this test.
    114                 $this->markTestIncomplete(
    115                         'This test has not been implemented yet.'
    116                 );
     112                $old_user = get_current_user_id();
     113                $user_id  = $this->factory->user->create();
     114                $forum_id = $this->factory->forum->create();
     115                $topic_id = $this->factory->topic->create( array( 'post_parent' => $forum_id, 'post_author' => $user_id ) );
     116                update_post_meta( $topic_id, '_edit_lock', 'stale' );
     117                delete_post_meta( $topic_id, '_bbp_forum_id' );
     118                delete_post_meta( $topic_id, '_bbp_topic_id' );
     119                $this->set_current_user( $user_id );
     120
     121                try {
     122                        bbp_update_topic( $topic_id, $forum_id, array(), $user_id, true );
     123                        $this->assertSame( (string) $user_id, get_post_meta( $topic_id, '_edit_last', true ) );
     124                        $this->assertFalse( metadata_exists( 'post', $topic_id, '_edit_lock' ) );
     125                        $this->assertSame( (string) $forum_id, get_post_meta( $topic_id, '_bbp_forum_id', true ) );
     126                        $this->assertSame( (string) $topic_id, get_post_meta( $topic_id, '_bbp_topic_id', true ) );
     127                        delete_post_meta( $topic_id, '_bbp_last_active_id' );
     128                        delete_post_meta( $topic_id, '_bbp_reply_count' );
     129                        bbp_update_topic( $topic_id, $forum_id, array(), $user_id, false );
     130                        $this->assertSame( (string) $topic_id, get_post_meta( $topic_id, '_bbp_last_active_id', true ) );
     131                        $this->assertSame( '0', get_post_meta( $topic_id, '_bbp_reply_count', true ) );
     132                } finally {
     133                        $this->set_current_user( $old_user );
     134                }
    117135        }
    118136
Note: See TracChangeset for help on using the changeset viewer.