PluginProbe
WP Discourse / trunk
WP Discourse vtrunk
2.6.4 2.6.3 1.2.1 1.2.2 1.2.5 1.2.6 1.2.7 1.2.8 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.85 1.4.0 1.4.15 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 All 150 releases
wp-discourse / tests / phpunit / multisite / test-sync-discourse-topic-multisite.php

test-sync-discourse-topic-multisite.php in WP Discourse trunk, at tests/phpunit/multisite/test-sync-discourse-topic-multisite.php

51 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class SyncDiscourseTopicMultisiteTest
4 *
5 * @package WPDiscourse
6 */
7
8 use WPDiscourse\Test\Multisite;
9 use WPDiscourse\Test\SyncDiscourseTopicTest;
10 use WPDiscourse\DiscoursePublish\DiscoursePublish;
11
12 /**
13 * SyncDiscourseTopicMultisiteTest test case.
14 */
15 class SyncDiscourseTopicMultisiteTest extends SyncDiscourseTopicTest {
16 use Multisite;
17
18 /**
19 * update_topic_content handles webhook results correctly in multisite.
20 */
21 public function test_update_topic_content() {
22 // Set as multisite.
23 self::$plugin_options['multisite-configuration-enabled'] = 1;
24 $this->sync_topic->setup_options( self::$plugin_options );
25
26 // Setup the posts
27 $post_id = wp_insert_post( self::$post_atts, false, false );
28 $discourse_post = json_decode( $this->payload )->post;
29
30 // Setup the post meta
31 $discourse_topic_id = $discourse_post->topic_id;
32 update_post_meta( $post_id, 'discourse_topic_id', $discourse_topic_id );
33
34 // Setup multisite data
35 $blog_id = intval( get_current_blog_id() );
36 $this->sync_topic->save_topic_blog_id( $discourse_topic_id, $blog_id );
37
38 // Perform update
39 $this->sync_topic->update_topic_content( $this->request );
40
41 // Ensure the post meta is updated correctly on the right site.
42 $this->switch_to_blog_for_topic( $discourse_topic_id );
43 $this->assertEquals( get_post_meta( $post_id, 'wpdc_sync_post_comments', true ), 1 );
44 $this->assertEquals( get_post_meta( $post_id, 'discourse_comments_count', true ), '2' );
45
46 // Cleanup
47 wp_delete_post( $post_id );
48 restore_current_blog();
49 }
50 }
51