-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding unit test for the network site connection push method, #2.
- Loading branch information
Zane Kolnik
committed
Oct 21, 2016
1 parent
e3c19e5
commit 05ad528
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace Syndicate\InternalConnections; | ||
|
||
class NetworkSiteConnectionsTest extends \TestCase { | ||
|
||
/** | ||
* Push returns an post ID on success instance of WP Error on failure. | ||
* | ||
* @since 0.8 | ||
*/ | ||
public function test_push(){ | ||
|
||
$site_obj = \Mockery::mock( '\WP_Site', [ | ||
'args' => 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 ) ) ); | ||
|
||
} | ||
|
||
} |