mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
WordPress' code just... wasn't. This is now dealt with. Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS. Fixes #41057. git-svn-id: https://develop.svn.wordpress.org/trunk@42343 602fd350-edb4-49c9-b593-d223f7449a82
82 lines
2.0 KiB
PHP
82 lines
2.0 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group xmlrpc
|
|
*/
|
|
class Tests_XMLRPC_wp_getRevisions extends WP_XMLRPC_UnitTestCase {
|
|
|
|
function test_invalid_username_password() {
|
|
$result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'username', 'password', 0 ) );
|
|
$this->assertIXRError( $result );
|
|
$this->assertEquals( 403, $result->code );
|
|
}
|
|
|
|
function test_incapable_user() {
|
|
$this->make_user_by_role( 'subscriber' );
|
|
|
|
$post_id = self::factory()->post->create();
|
|
|
|
$result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'subscriber', 'subscriber', $post_id ) );
|
|
$this->assertIXRError( $result );
|
|
$this->assertEquals( 401, $result->code );
|
|
}
|
|
|
|
function test_capable_user() {
|
|
$this->make_user_by_role( 'editor' );
|
|
|
|
$post_id = self::factory()->post->create();
|
|
$result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'editor', 'editor', $post_id ) );
|
|
$this->assertNotIXRError( $result );
|
|
}
|
|
|
|
function test_revision_count() {
|
|
$this->make_user_by_role( 'editor' );
|
|
|
|
$post_id = self::factory()->post->create();
|
|
wp_insert_post(
|
|
array(
|
|
'ID' => $post_id,
|
|
'post_content' => 'Edit 1',
|
|
)
|
|
); // Create the initial revision
|
|
|
|
$result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'editor', 'editor', $post_id ) );
|
|
$this->assertInternalType( 'array', $result );
|
|
$this->assertCount( 1, $result );
|
|
|
|
wp_insert_post(
|
|
array(
|
|
'ID' => $post_id,
|
|
'post_content' => 'Edit 2',
|
|
)
|
|
);
|
|
|
|
$result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'editor', 'editor', $post_id ) );
|
|
$this->assertInternalType( 'array', $result );
|
|
$this->assertCount( 2, $result );
|
|
}
|
|
|
|
/**
|
|
* @ticket 22687
|
|
*/
|
|
function test_revision_count_for_auto_draft_post_creation() {
|
|
$this->make_user_by_role( 'editor' );
|
|
|
|
$post_id = $this->myxmlrpcserver->wp_newPost(
|
|
array(
|
|
1,
|
|
'editor',
|
|
'editor',
|
|
array(
|
|
'post_title' => 'Original title',
|
|
'post_content' => 'Test',
|
|
),
|
|
)
|
|
);
|
|
|
|
$result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'editor', 'editor', $post_id ) );
|
|
$this->assertCount( 1, $result );
|
|
}
|
|
|
|
}
|