mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Adds a `public` visibility to test fixtures, tests, data providers, and callbacks methods. Adds a `private` visibility to helper methods within test classes. Renames callbacks and helpers that previously started with a `_` prefix. Why? For consistency and to leverage using the method visibility. Further naming standardizations is beyond the scope of this commit. Props costdev, jrf, hellofromTonya. Fixes #54177. git-svn-id: https://develop.svn.wordpress.org/trunk@52010 602fd350-edb4-49c9-b593-d223f7449a82
49 lines
1.6 KiB
PHP
49 lines
1.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group xmlrpc
|
|
* @group user
|
|
*/
|
|
class Tests_XMLRPC_wp_getProfile extends WP_XMLRPC_UnitTestCase {
|
|
|
|
public function test_invalid_username_password() {
|
|
$result = $this->myxmlrpcserver->wp_getProfile( array( 1, 'username', 'password' ) );
|
|
$this->assertIXRError( $result );
|
|
$this->assertSame( 403, $result->code );
|
|
}
|
|
|
|
public function test_subscriber() {
|
|
$subscriber_id = $this->make_user_by_role( 'subscriber' );
|
|
|
|
$result = $this->myxmlrpcserver->wp_getProfile( array( 1, 'subscriber', 'subscriber' ) );
|
|
$this->assertNotIXRError( $result );
|
|
$this->assertEquals( $subscriber_id, $result['user_id'] );
|
|
$this->assertContains( 'subscriber', $result['roles'] );
|
|
}
|
|
|
|
public function test_administrator() {
|
|
$administrator_id = $this->make_user_by_role( 'administrator' );
|
|
|
|
$result = $this->myxmlrpcserver->wp_getProfile( array( 1, 'administrator', 'administrator' ) );
|
|
$this->assertNotIXRError( $result );
|
|
$this->assertEquals( $administrator_id, $result['user_id'] );
|
|
$this->assertContains( 'administrator', $result['roles'] );
|
|
}
|
|
|
|
public function test_arbitrary_fields() {
|
|
$editor_id = $this->make_user_by_role( 'editor' );
|
|
|
|
$fields = array( 'email', 'bio', 'user_contacts' );
|
|
|
|
$result = $this->myxmlrpcserver->wp_getProfile( array( 1, 'editor', 'editor', $fields ) );
|
|
$this->assertNotIXRError( $result );
|
|
$this->assertEquals( $editor_id, $result['user_id'] );
|
|
|
|
$expected_fields = array( 'user_id', 'email', 'bio' );
|
|
$keys = array_keys( $result );
|
|
sort( $expected_fields );
|
|
sort( $keys );
|
|
$this->assertSameSets( $expected_fields, $keys );
|
|
}
|
|
}
|