wordpress-develop/tests/phpunit/tests/xmlrpc/basic.php
Andrew Nacin 8045afd81b Move PHPUnit tests into a tests/phpunit directory.
wp-tests-config.php can/should reside in the root of a develop checkout. `phpunit` should be run from the root.

see #25088.


git-svn-id: https://develop.svn.wordpress.org/trunk@25165 602fd350-edb4-49c9-b593-d223f7449a82
2013-08-29 18:39:34 +00:00

28 lines
961 B
PHP

<?php
require_once ABSPATH . 'wp-admin/includes/admin.php';
require_once ABSPATH . WPINC . '/class-IXR.php';
require_once ABSPATH . WPINC . '/class-wp-xmlrpc-server.php';
/**
* @group xmlrpc
*/
class Tests_XMLRPC_Basic extends WP_XMLRPC_UnitTestCase {
function test_enabled() {
$result = $this->myxmlrpcserver->wp_getOptions( array( 1, 'username', 'password' ) );
$this->assertInstanceOf( 'IXR_Error', $result );
// If disabled, 405 would result.
$this->assertEquals( 403, $result->code );
}
function test_login_pass_ok() {
$user_id = $this->make_user_by_role( 'subscriber' );
$this->assertFalse( $this->myxmlrpcserver->login_pass_ok( 'username', 'password' ) );
$this->assertFalse( $this->myxmlrpcserver->login( 'username', 'password' ) );
$this->assertTrue( $this->myxmlrpcserver->login_pass_ok( 'subscriber', 'subscriber' ) );
$this->assertInstanceOf( 'WP_User', $this->myxmlrpcserver->login( 'subscriber', 'subscriber' ) );
}
}