Changeset 42343 for trunk/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php
r40417 r42343 8 8 9 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 ) ); 10 self::$post_id = $factory->post->create( 11 array( 12 'post_type' => 'page', 13 'post_author' => $factory->user->create( 14 array( 15 'user_login' => 'author', 16 'user_pass' => 'author', 17 'role' => 'author', 18 ) 19 ), 20 'post_date' => strftime( '%Y-%m-%d %H:%M:%S', strtotime( '+1 day' ) ), 21 ) 22 ); 19 23 } 20 24 … … 47 51 add_theme_support( 'post-thumbnails' ); 48 52 49 $fields = array( 'post' );53 $fields = array( 'post' ); 50 54 $results = $this->myxmlrpcserver->mw_getRecentPosts( array( 1, 'author', 'author' ) ); 51 55 $this->assertNotIXRError( $results ); 52 56 53 foreach ( $results as $result ) {57 foreach ( $results as $result ) { 54 58 $post = get_post( $result['postid'] ); 55 59 … … 61 65 $this->assertInternalType( 'string', $result['link'] ); 62 66 $this->assertInternalType( 'string', $result['permaLink'] ); 63 $this->assertInternalType( 'array', 67 $this->assertInternalType( 'array', $result['categories'] ); 64 68 $this->assertInternalType( 'string', $result['mt_excerpt'] ); 65 69 $this->assertInternalType( 'string', $result['mt_text_more'] ); … … 95 99 96 100 // create attachment 97 $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' );101 $filename = ( DIR_TESTDATA . '/images/a2-small.jpg' ); 98 102 $attachment_id = self::factory()->attachment->create_upload_object( $filename, self::$post_id ); 99 103 set_post_thumbnail( self::$post_id, $attachment_id ); … … 102 106 $this->assertNotIXRError( $results ); 103 107 104 foreach ( $results as $result ) {108 foreach ( $results as $result ) { 105 109 $this->assertInternalType( 'string', $result['wp_post_thumbnail'] ); 106 110 $this->assertStringMatchesFormat( '%d', $result['wp_post_thumbnail'] ); 107 111 108 if ( ! empty( $result['wp_post_thumbnail'] ) || $result['postid'] == self::$post_id ) {112 if ( ! empty( $result['wp_post_thumbnail'] ) || $result['postid'] == self::$post_id ) { 109 113 $attachment_id = get_post_meta( $result['postid'], '_thumbnail_id', true ); 110 114 … … 122 126 $this->assertNotIXRError( $results ); 123 127 124 foreach ( $results as $result ) {125 $post = get_post( $result['postid'] );126 $date_gmt = strtotime( get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $post->post_date, false ), 'Ymd\TH:i:s' ) );128 foreach ( $results as $result ) { 129 $post = get_post( $result['postid'] ); 130 $date_gmt = strtotime( get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $post->post_date, false ), 'Ymd\TH:i:s' ) ); 127 131 $date_modified_gmt = strtotime( get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $post->post_modified, false ), 'Ymd\TH:i:s' ) ); 128 132
Note: See TracChangeset
for help on using the changeset viewer.