Changeset 39189 for trunk/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php
- Timestamp:
- 11/10/2016 01:53:08 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php
r35244 r39189 5 5 */ 6 6 class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase { 7 var $post_data; 8 var $post_id; 9 var $post_date_ts; 7 protected static $post_id; 10 8 11 function setUp() { 12 parent::setUp(); 13 14 $author_id = $this->make_user_by_role( 'author' ); 15 $this->post_date_ts = strtotime( '+1 day' ); 16 $this->post_data = array( 17 'post_title' => rand_str(), 18 'post_content' => rand_str( 2000 ), 19 'post_excerpt' => rand_str( 100 ), 20 'post_author' => $author_id, 21 'post_date' => strftime( "%Y-%m-%d %H:%M:%S", $this->post_date_ts ), 22 ); 23 $this->post_id = wp_insert_post( $this->post_data ); 9 public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { 10 self::$post_id = $factory->post->create( array( 11 'post_type' => 'page', 12 'post_author' => $factory->user->create( array( 13 'user_login' => 'author', 14 'user_pass' => 'author', 15 'role' => 'author' 16 ) ), 17 'post_date' => strftime( "%Y-%m-%d %H:%M:%S", strtotime( '+1 day' ) ), 18 ) ); 24 19 } 25 20 … … 42 37 43 38 function test_no_editable_posts() { 44 wp_delete_post( $this->post_id, true );39 wp_delete_post( self::$post_id, true ); 45 40 46 41 $result = $this->myxmlrpcserver->mw_getRecentPosts( array( 1, 'author', 'author' ) ); … … 101 96 // create attachment 102 97 $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' ); 103 $attachment_id = self::factory()->attachment->create_upload_object( $filename, $this->post_id );104 set_post_thumbnail( $this->post_id, $attachment_id );98 $attachment_id = self::factory()->attachment->create_upload_object( $filename, self::$post_id ); 99 set_post_thumbnail( self::$post_id, $attachment_id ); 105 100 106 $results = $this->myxmlrpcserver->mw_getRecentPosts( array( $this->post_id, 'author', 'author' ) );101 $results = $this->myxmlrpcserver->mw_getRecentPosts( array( self::$post_id, 'author', 'author' ) ); 107 102 $this->assertNotInstanceOf( 'IXR_Error', $results ); 108 103 … … 111 106 $this->assertStringMatchesFormat( '%d', $result['wp_post_thumbnail'] ); 112 107 113 if( ! empty( $result['wp_post_thumbnail'] ) || $result['postid'] == $this->post_id ) {108 if( ! empty( $result['wp_post_thumbnail'] ) || $result['postid'] == self::$post_id ) { 114 109 $attachment_id = get_post_meta( $result['postid'], '_thumbnail_id', true ); 115 110
Note: See TracChangeset
for help on using the changeset viewer.