Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions tests/phpunit/tests/xmlrpc/mw/editPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function test_capable_reassign_author() {
$this->assertTrue( $result );

$out = get_post( $post_id );
$this->assertEquals( $author_id, $out->post_author );
$this->assertSame( (string) $author_id, $out->post_author );
}

public function test_incapable_reassign_author() {
Expand All @@ -107,7 +107,7 @@ public function test_incapable_reassign_author() {
$this->assertSame( 401, $result->code );

$out = get_post( $post_id );
$this->assertEquals( $contributor_id, $out->post_author );
$this->assertSame( (string) $contributor_id, $out->post_author );
}

/**
Expand All @@ -129,7 +129,7 @@ public function test_capable_reassign_author_to_self() {
$this->assertTrue( $result );

$out = get_post( $post_id );
$this->assertEquals( $editor_id, $out->post_author );
$this->assertSame( (string) $editor_id, $out->post_author );
}

/**
Expand All @@ -156,13 +156,13 @@ public function test_post_thumbnail() {
$post2 = array( 'wp_post_thumbnail' => $attachment_id );
$result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post2 ) );
$this->assertNotIXRError( $result );
$this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) );
$this->assertSame( (string) $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) );

// Edit the post without supplying a post_thumbnail and check that it didn't change.
$post3 = array( 'post_content' => 'Updated post' );
$result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post3 ) );
$this->assertNotIXRError( $result );
$this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) );
$this->assertSame( (string) $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) );

// Create another attachment.
$attachment2_id = self::factory()->attachment->create_upload_object( $filename, $post_id );
Expand All @@ -171,7 +171,7 @@ public function test_post_thumbnail() {
$post4 = array( 'wp_post_thumbnail' => $attachment2_id );
$result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post4 ) );
$this->assertNotIXRError( $result );
$this->assertEquals( $attachment2_id, get_post_meta( $post_id, '_thumbnail_id', true ) );
$this->assertSame( (string) $attachment2_id, get_post_meta( $post_id, '_thumbnail_id', true ) );

// Unset the post's post_thumbnail.
$post5 = array( 'wp_post_thumbnail' => '' );
Expand Down
7 changes: 4 additions & 3 deletions tests/phpunit/tests/xmlrpc/mw/newPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public function test_ignore_id() {
);
$result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) );
$this->assertNotIXRError( $result );
$this->assertNotEquals( '103948', $result );
$this->assertIsString( $result );
$this->assertNotSame( '103948', $result );
Comment thread
haritpanchal marked this conversation as resolved.
}

public function test_capable_publish() {
Expand Down Expand Up @@ -124,7 +125,7 @@ public function test_empty_author() {
$this->assertStringMatchesFormat( '%d', $result );

$out = get_post( $result );
$this->assertEquals( $my_author_id, $out->post_author );
$this->assertSame( (string) $my_author_id, $out->post_author );
$this->assertSame( 'Test', $out->post_title );
}

Expand All @@ -146,7 +147,7 @@ public function test_post_thumbnail() {
);
$result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) );
$this->assertNotIXRError( $result );
$this->assertEquals( $attachment_id, get_post_meta( $result, '_thumbnail_id', true ) );
$this->assertSame( (string) $attachment_id, get_post_meta( $result, '_thumbnail_id', true ) );

remove_theme_support( 'post-thumbnails' );
}
Expand Down
14 changes: 7 additions & 7 deletions tests/phpunit/tests/xmlrpc/wp/editPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function test_capable_reassign_author() {
$this->assertTrue( $result );

$out = get_post( $post_id );
$this->assertEquals( $author_id, $out->post_author );
$this->assertSame( (string) $author_id, $out->post_author );
}

public function test_incapable_reassign_author() {
Expand All @@ -107,7 +107,7 @@ public function test_incapable_reassign_author() {
$this->assertSame( 401, $result->code );

$out = get_post( $post_id );
$this->assertEquals( $contributor_id, $out->post_author );
$this->assertSame( (string) $contributor_id, $out->post_author );
}

/**
Expand All @@ -129,7 +129,7 @@ public function test_capable_reassign_author_to_self() {
$this->assertTrue( $result );

$out = get_post( $post_id );
$this->assertEquals( $editor_id, $out->post_author );
$this->assertSame( (string) $editor_id, $out->post_author );
}

/**
Expand All @@ -156,20 +156,20 @@ public function test_post_thumbnail() {
$post2 = array( 'post_thumbnail' => $attachment_id );
$result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post2 ) );
$this->assertNotIXRError( $result );
$this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) );
$this->assertSame( (string) $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) );

// Fetch the post to verify that it appears.
$result = $this->myxmlrpcserver->wp_getPost( array( 1, 'author', 'author', $post_id ) );
$this->assertNotIXRError( $result );
$this->assertArrayHasKey( 'post_thumbnail', $result );
$this->assertIsArray( $result['post_thumbnail'] );
$this->assertEquals( $attachment_id, $result['post_thumbnail']['attachment_id'] );
$this->assertSame( (string) $attachment_id, $result['post_thumbnail']['attachment_id'] );

// Edit the post without supplying a post_thumbnail and check that it didn't change.
$post3 = array( 'post_content' => 'Updated post' );
$result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post3 ) );
$this->assertNotIXRError( $result );
$this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) );
$this->assertSame( (string) $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) );

// Create another attachment.
$attachment2_id = self::factory()->attachment->create_upload_object( $filename, $post_id );
Expand All @@ -178,7 +178,7 @@ public function test_post_thumbnail() {
$post4 = array( 'post_thumbnail' => $attachment2_id );
$result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post4 ) );
$this->assertNotIXRError( $result );
$this->assertEquals( $attachment2_id, get_post_meta( $post_id, '_thumbnail_id', true ) );
$this->assertSame( (string) $attachment2_id, get_post_meta( $post_id, '_thumbnail_id', true ) );

// Unset the post's post_thumbnail.
$post5 = array( 'post_thumbnail' => '' );
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/xmlrpc/wp/editProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ public function test_ignore_email_change() {
$this->assertTrue( $result );

$user_data = get_userdata( $editor_id );
$this->assertNotEquals( $new_email, $user_data->email );
$this->assertNotSame( $new_email, $user_data->user_email );
}
}
2 changes: 1 addition & 1 deletion tests/phpunit/tests/xmlrpc/wp/editTerm.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function test_parent_null() {
$this->assertIsBool( $result );

$term = get_term( self::$child_term, 'category' );
$this->assertEquals( '0', $term->parent );
$this->assertSame( 0, $term->parent );
}

public function test_parent_invalid() {
Expand Down
10 changes: 5 additions & 5 deletions tests/phpunit/tests/xmlrpc/wp/getComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ public function test_valid_comment() {
$this->assertStringMatchesFormat( '%d', $result['comment_id'] );
$this->assertStringMatchesFormat( '%d', $result['parent'] );
$this->assertStringMatchesFormat( '%d', $result['post_id'] );
$this->assertEquals( self::$parent_comment_id, $result['comment_id'] );
$this->assertEquals( 0, $result['parent'] );
$this->assertSame( (string) self::$parent_comment_id, $result['comment_id'] );
$this->assertSame( '0', $result['parent'] );
$this->assertSame( self::$parent_comment_data['comment_content'], $result['content'] );
$this->assertEquals( self::$post_id, $result['post_id'] );
$this->assertSame( (string) self::$post_id, $result['post_id'] );
$this->assertSame( self::$parent_comment_data['comment_author'], $result['author'] );
$this->assertSame( self::$parent_comment_data['comment_author_url'], $result['author_url'] );
$this->assertSame( self::$parent_comment_data['comment_author_email'], $result['author_email'] );
Expand All @@ -89,8 +89,8 @@ public function test_valid_child_comment() {
$result = $this->myxmlrpcserver->wp_getComment( array( 1, 'editor', 'editor', self::$child_comment_id ) );
$this->assertNotIXRError( $result );

$this->assertEquals( self::$child_comment_id, $result['comment_id'] );
$this->assertEquals( self::$parent_comment_id, $result['parent'] );
$this->assertSame( (string) self::$child_comment_id, $result['comment_id'] );
$this->assertSame( (string) self::$parent_comment_id, $result['parent'] );
}

public function test_invalid_id() {
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/xmlrpc/wp/getComments.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function test_post_filter() {
$this->assertNotEmpty( $results );

foreach ( $results as $result ) {
$this->assertEquals( $this->post_id, $result['post_id'] );
$this->assertSame( (string) $this->post_id, $result['post_id'] );
}
}

Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/tests/xmlrpc/wp/getPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ public function test_valid_post() {
$this->assertSame( $this->post_data['post_excerpt'], $result['post_excerpt'] );
$this->assertSame( $this->post_data['post_content'], $result['post_content'] );
$this->assertSame( url_to_postid( $result['link'] ), $this->post_id );
$this->assertEquals( $this->post_custom_field['id'], $result['custom_fields'][0]['id'] );
$this->assertSame( (string) $this->post_custom_field['id'], $result['custom_fields'][0]['id'] );
$this->assertSame( $this->post_custom_field['key'], $result['custom_fields'][0]['key'] );
$this->assertEquals( $this->post_custom_field['value'], $result['custom_fields'][0]['value'] );
$this->assertSame( (string) $this->post_custom_field['value'], $result['custom_fields'][0]['value'] );

remove_theme_support( 'post-thumbnails' );
}
Expand Down Expand Up @@ -144,7 +144,7 @@ public function test_valid_page() {
$this->assertIsString( $result['post_mime_type'] );

$this->assertSame( 'page', $result['post_type'] );
$this->assertEquals( $parent_page_id, $result['post_parent'] );
$this->assertSame( (string) $parent_page_id, $result['post_parent'] );
$this->assertSame( 2, $result['menu_order'] );
}

Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/xmlrpc/wp/getPosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function test_filters() {
$results3 = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter3 ) );
$this->assertNotIXRError( $results3 );
$this->assertCount( 1, $results3 );
$this->assertEquals( $post->ID, $results3[0]['post_id'] );
$this->assertSame( (string) $post->ID, $results3[0]['post_id'] );

_unregister_post_type( $cpt_name );
}
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/tests/xmlrpc/wp/getProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function test_subscriber() {

$result = $this->myxmlrpcserver->wp_getProfile( array( 1, 'subscriber', 'subscriber' ) );
$this->assertNotIXRError( $result );
$this->assertEquals( $subscriber_id, $result['user_id'] );
$this->assertSame( (string) $subscriber_id, $result['user_id'] );
$this->assertContains( 'subscriber', $result['roles'] );
}

Expand All @@ -26,7 +26,7 @@ public function test_administrator() {

$result = $this->myxmlrpcserver->wp_getProfile( array( 1, 'administrator', 'administrator' ) );
$this->assertNotIXRError( $result );
$this->assertEquals( $administrator_id, $result['user_id'] );
$this->assertSame( (string) $administrator_id, $result['user_id'] );
$this->assertContains( 'administrator', $result['roles'] );
}

Expand All @@ -37,7 +37,7 @@ public function test_arbitrary_fields() {

$result = $this->myxmlrpcserver->wp_getProfile( array( 1, 'editor', 'editor', $fields ) );
$this->assertNotIXRError( $result );
$this->assertEquals( $editor_id, $result['user_id'] );
$this->assertSame( (string) $editor_id, $result['user_id'] );

$expected_fields = array( 'user_id', 'email', 'bio' );
$keys = array_keys( $result );
Expand Down
11 changes: 10 additions & 1 deletion tests/phpunit/tests/xmlrpc/wp/getTerm.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ public function test_valid_term() {
$result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'editor', 'editor', 'category', self::$term_id ) );

$this->assertNotIXRError( $result );
$this->assertEquals( $result, $term );
/*
* This comparison stays loose: wp.getTerm returns the IDs as strings so that they
* cannot exceed what an XML-RPC integer can describe, while get_term() returns them
* as integers. The individual types are asserted below.
Comment thread
haritpanchal marked this conversation as resolved.
*/
$this->assertEquals( $term, $result );

// Check data types.
$this->assertIsString( $result['name'] );
Expand All @@ -86,6 +91,10 @@ public function test_valid_term() {
$this->assertIsInt( $result['count'] );

// We expect all ID's to be strings not integers so we don't return something larger than an XMLRPC integer can describe.
$this->assertIsString( $result['term_id'] );
$this->assertIsString( $result['term_group'] );
$this->assertIsString( $result['term_taxonomy_id'] );
$this->assertIsString( $result['parent'] );
$this->assertStringMatchesFormat( '%d', $result['term_id'] );
$this->assertStringMatchesFormat( '%d', $result['term_group'] );
$this->assertStringMatchesFormat( '%d', $result['term_taxonomy_id'] );
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/tests/xmlrpc/wp/getTerms.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@ public function test_terms_search() {
$this->assertNotIXRError( $results );
$this->assertCount( 1, $results );
$this->assertSame( $name, $results[0]['name'] );
$this->assertEquals( $name_id, $results[0]['term_id'] );
$this->assertSame( (string) $name_id, $results[0]['term_id'] );

// Search by partial name.
$filter = array( 'search' => substr( $name, 0, 10 ) );
$results2 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) );
$this->assertNotIXRError( $results2 );
$this->assertCount( 1, $results2 );
$this->assertSame( $name, $results2[0]['name'] );
$this->assertEquals( $name_id, $results2[0]['term_id'] );
$this->assertSame( (string) $name_id, $results2[0]['term_id'] );
}
}
10 changes: 5 additions & 5 deletions tests/phpunit/tests/xmlrpc/wp/getUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function test_subscriber_self() {

$result = $this->myxmlrpcserver->wp_getUser( array( 1, 'subscriber', 'subscriber', $subscriber_id ) );
$this->assertNotIXRError( $result );
$this->assertEquals( $subscriber_id, $result['user_id'] );
$this->assertSame( (string) $subscriber_id, $result['user_id'] );
}

public function test_valid_user() {
Expand Down Expand Up @@ -83,7 +83,7 @@ public function test_valid_user() {
$this->assertIsArray( $result['roles'] );

// Check expected values.
$this->assertEquals( $user_id, $result['user_id'] );
$this->assertSame( (string) $user_id, $result['user_id'] );
$this->assertSame( $user_data['user_login'], $result['username'] );
$this->assertSame( $user_data['first_name'], $result['first_name'] );
$this->assertSame( $user_data['last_name'], $result['last_name'] );
Expand All @@ -105,7 +105,7 @@ public function test_no_fields() {

$result = $this->myxmlrpcserver->wp_getUser( array( 1, 'administrator', 'administrator', $editor_id, array() ) );
$this->assertNotIXRError( $result );
$this->assertEquals( $editor_id, $result['user_id'] );
$this->assertSame( (string) $editor_id, $result['user_id'] );

$expected_fields = array( 'user_id' );
$this->assertSame( $expected_fields, array_keys( $result ) );
Expand All @@ -116,7 +116,7 @@ public function test_basic_fields() {

$result = $this->myxmlrpcserver->wp_getUser( array( 1, 'administrator', 'administrator', $editor_id, array( 'basic' ) ) );
$this->assertNotIXRError( $result );
$this->assertEquals( $editor_id, $result['user_id'] );
$this->assertSame( (string) $editor_id, $result['user_id'] );

$expected_fields = array( 'user_id', 'username', 'email', 'registered', 'display_name', 'nicename' );
$keys = array_keys( $result );
Expand All @@ -132,7 +132,7 @@ public function test_arbitrary_fields() {

$result = $this->myxmlrpcserver->wp_getUser( array( 1, 'administrator', 'administrator', $editor_id, $fields ) );
$this->assertNotIXRError( $result );
$this->assertEquals( $editor_id, $result['user_id'] );
$this->assertSame( (string) $editor_id, $result['user_id'] );

$expected_fields = array( 'user_id', 'email', 'bio' );
$keys = array_keys( $result );
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/xmlrpc/wp/getUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function test_role_filter() {
$results = $this->myxmlrpcserver->wp_getUsers( array( 1, 'administrator', 'administrator', $filter ) );
$this->assertNotIXRError( $results );
$this->assertCount( 1, $results );
$this->assertEquals( $editor_id, $results[0]['user_id'] );
$this->assertSame( (string) $editor_id, $results[0]['user_id'] );

// Test 'authors', which should return all non-subscribers.
$filter2 = array( 'who' => 'authors' );
Expand Down
7 changes: 4 additions & 3 deletions tests/phpunit/tests/xmlrpc/wp/newPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public function test_ignore_id() {
);
$result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) );
$this->assertNotIXRError( $result );
$this->assertNotEquals( '103948', $result );
$this->assertIsString( $result );
$this->assertNotSame( '103948', $result );
Comment thread
haritpanchal marked this conversation as resolved.
}

public function test_capable_publish() {
Expand Down Expand Up @@ -141,7 +142,7 @@ public function test_empty_author() {
$this->assertStringMatchesFormat( '%d', $result );

$out = get_post( $result );
$this->assertEquals( $my_author_id, $out->post_author );
$this->assertSame( (string) $my_author_id, $out->post_author );
$this->assertSame( 'Test', $out->post_title );
}

Expand All @@ -163,7 +164,7 @@ public function test_post_thumbnail() {
);
$result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) );
$this->assertNotIXRError( $result );
$this->assertEquals( $attachment_id, get_post_meta( $result, '_thumbnail_id', true ) );
$this->assertSame( (string) $attachment_id, get_post_meta( $result, '_thumbnail_id', true ) );

remove_theme_support( 'post-thumbnails' );
}
Expand Down
Loading