From efd775c3473430810d0c532acd51c76a63271ab7 Mon Sep 17 00:00:00 2001 From: Zane Kolnik Date: Fri, 21 Oct 2016 16:13:22 -0400 Subject: [PATCH] Created new branch per issue. Added unit test for push method, #2 --- tests/php/NetworkSiteConnectionsTest.php | 50 ++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tests/php/NetworkSiteConnectionsTest.php diff --git a/tests/php/NetworkSiteConnectionsTest.php b/tests/php/NetworkSiteConnectionsTest.php new file mode 100644 index 000000000..1af9cab09 --- /dev/null +++ b/tests/php/NetworkSiteConnectionsTest.php @@ -0,0 +1,50 @@ + 1, + 'return' => '' + ] ); + + $connection_obj = new NetworkSiteConnection( $site_obj ); + + \WP_Mock::userFunction( 'get_post', [ + 'return' => (object) [ + 'post_content' => '', + 'post_excerpt' => '', + 'post_type' => '', + ] + ] ); + + \WP_Mock::userFunction( 'get_current_blog_id' ); + \WP_Mock::userFunction( 'get_current_user_id' ); + \WP_Mock::userFunction( 'switch_to_blog' ); + + $connection_obj->site->blog_id = 2; + + \WP_Mock::userFunction( 'wp_insert_post', [ + 'return' => 123 + ] ); + + \WP_Mock::userFunction( 'update_post_meta' ); + \WP_Mock::userFunction( 'get_post_meta', [ + 'return' => [] + ] ); + + \WP_Mock::userFunction( 'restore_current_blog' ); + + $this->assertTrue( is_int( $connection_obj->push( 1 ) ) ); + + } + +} \ No newline at end of file