Skip to content

Commit

Permalink
Created new branch per issue.
Browse files Browse the repository at this point in the history
Added unit test for push method, #2
  • Loading branch information
Zane Kolnik committed Oct 21, 2016
1 parent 3a9c313 commit efd775c
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tests/php/NetworkSiteConnectionsTest.php
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 ) ) );

}

}

0 comments on commit efd775c

Please sign in to comment.