<?php 
/**
 * @group post
*/

class Tests_WP_Post extends WP_UnitTestCase {

	public function test_get_instance(){
		global $wpdb;

		// Gather post data.
		$this->assertNull(get_post(1));
		$my_post = array(
			'ID' => 1,
			'post_title'    => 'My post',
			'post_content'  => 'This is my post.',
			'post_status'   => 'publish',
			'post_author'   => 1,
			);

		// Insert the post into the database. 
		// using $wpdb-> insert because wp_insert_post doesn't start at id = 1 
		$wpdb->insert( $wpdb->prefix.'posts',$my_post);
		$this->assertTrue(get_post(1) instanceof WP_Post);
		
		$arr =array(1,4,5);
		$post = WP_Post::get_instance($arr);
		$this->assertFalse($post);

		$obj = new stdClass();;
		$post = WP_Post::get_instance($obj);
		$this->assertFalse($post);

		$bool = (bool) 1;
		$post = WP_Post::get_instance($bool);
		$this->assertTrue($post instanceof WP_Post);

		$int = (int) 1;
		$post = WP_Post::get_instance($int);
		$this->assertTrue($post instanceof WP_Post);

		$float = 1.4;
		$post = WP_Post::get_instance($float);
		$this->assertTrue($post instanceof WP_Post);

		$string = "Winter is Coming";
		$post = WP_Post::get_instance($string);
		$this->assertFalse($post);

		$numericstring = '1.4';
		$post = WP_Post::get_instance($numericstring);
		$this->assertTrue($post instanceof WP_Post);

		$post = WP_Post::get_instance(NULL);
		$this->assertFalse($post);
	}
	

}








?>