WordPress.org

Make WordPress Core

Changeset 567 in tests


Ignore:
Timestamp:
03/08/12 12:11:40 (2 years ago)
Author:
westi
Message:

XMLRPC: Add to and adapt the wp.getOptions test cases to take into account the readonly status bug highlighted in #WP20201

wp.getOptions currently returns readonly as false even when the user cannot update the options because they don't have the manage_options cap.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test-xmlrpc-api/test_wp_getOptions.php

    r565 r567  
    1616 
    1717    function test_option_value() { 
    18         $result = $this->myxmlrpcserver->wp_getOptions( array( 1, 'subscriber', 'subscriber', 'default_comment_status' ) ); 
     18        $result = $this->myxmlrpcserver->wp_getOptions( array( 1, 'administrator', 'administrator', 'default_comment_status' ) ); 
    1919        $this->assertInternalType( 'array', $result ); 
    2020 
     
    2323    } 
    2424 
    25     function test_option_values() { 
     25    function test_option_values_subscriber() { 
    2626        global $wp_version; 
    2727 
     28        $this->knownWPBug( 20201 ); 
     29 
    2830        $result = $this->myxmlrpcserver->wp_getOptions( array( 1, 'subscriber', 'subscriber' ) ); 
     31        $this->assertInternalType( 'array', $result ); 
     32 
     33        // Read Only options 
     34        $this->assertEquals( 'WordPress', $result['software_name']['value'] ); 
     35        $this->assertTrue( $result['software_name']['readonly'] ); 
     36 
     37        $this->assertEquals( $wp_version, $result['software_version']['value'] ); 
     38        $this->assertTrue( $result['software_version']['readonly'] ); 
     39 
     40        /* TODO: Gives junk data in Test Environment 
     41        $this->assertEquals( get_site_url(), $result['site-url']['value'] ); 
     42        $this->assertTrue( $result['site-url']['readonly'] ); 
     43        */ 
     44 
     45        $this->assertEquals( get_option( 'image_default_link_type' ), $result['image_default_link_type']['value'] ); 
     46        $this->assertTrue( $result['image_default_link_type']['readonly'] ); 
     47 
     48        $this->assertEquals( get_option( 'image_default_size' ), $result['image_default_size']['value'] ); 
     49        $this->assertTrue( $result['image_default_size']['readonly'] ); 
     50 
     51        $this->assertEquals( get_option( 'image_default_align' ), $result['image_default_align']['value'] ); 
     52        $this->assertTrue( $result['image_default_align']['readonly'] ); 
     53 
     54        $this->assertEquals( get_template(), $result['template']['value'] ); 
     55        $this->assertTrue( $result['template']['readonly'] ); 
     56 
     57        $this->assertEquals( get_stylesheet(), $result['stylesheet']['value'] ); 
     58        $this->assertTrue( $result['stylesheet']['readonly'] ); 
     59 
     60        // Updatable options 
     61        $this->assertEquals( get_option( 'gmt_offset' ), $result['time_zone']['value'] ); 
     62        $this->assertTrue( $result['time_zone']['readonly'] ); 
     63 
     64        $this->assertEquals( get_option( 'blogname' ), $result['blog_title']['value'] ); 
     65        $this->assertTrue( $result['blog_title']['readonly'] ); 
     66 
     67        $this->assertEquals( get_option( 'blogdescription' ), $result['blog_tagline']['value'] ); 
     68        $this->assertTrue( $result['blog_tagline']['readonly'] ); 
     69 
     70        $this->assertEquals( get_option( 'date_format' ), $result['date_format']['value'] ); 
     71        $this->assertTrue( $result['date_format']['readonly'] ); 
     72 
     73        $this->assertEquals( get_option( 'time_format' ), $result['time_format']['value'] ); 
     74        $this->assertTrue( $result['time_format']['readonly'] ); 
     75 
     76        $this->assertEquals( get_option( 'users_can_register' ), $result['users_can_register']['value'] ); 
     77        $this->assertTrue( $result['users_can_register']['readonly'] ); 
     78 
     79        $this->assertEquals( get_option( 'thumbnail_size_w' ), $result['thumbnail_size_w']['value'] ); 
     80        $this->assertTrue( $result['thumbnail_size_w']['readonly'] ); 
     81 
     82        $this->assertEquals( get_option( 'thumbnail_size_h' ), $result['thumbnail_size_h']['value'] ); 
     83        $this->assertTrue( $result['thumbnail_size_h']['readonly'] ); 
     84 
     85        $this->assertEquals( get_option( 'thumbnail_crop' ), $result['thumbnail_crop']['value'] ); 
     86        $this->assertTrue( $result['thumbnail_crop']['readonly'] ); 
     87 
     88        $this->assertEquals( get_option( 'medium_size_w' ), $result['medium_size_w']['value'] ); 
     89        $this->assertTrue( $result['medium_size_w']['readonly'] ); 
     90 
     91        $this->assertEquals( get_option( 'medium_size_h' ), $result['medium_size_h']['value'] ); 
     92        $this->assertTrue( $result['medium_size_h']['readonly'] ); 
     93 
     94        $this->assertEquals( get_option( 'large_size_w' ), $result['large_size_w']['value'] ); 
     95        $this->assertTrue( $result['large_size_w']['readonly'] ); 
     96 
     97        $this->assertEquals( get_option( 'large_size_h' ), $result['large_size_h']['value'] ); 
     98        $this->assertTrue( $result['large_size_h']['readonly'] ); 
     99 
     100        $this->assertEquals( get_option( 'default_comment_status' ), $result['default_comment_status']['value'] ); 
     101        $this->assertTrue( $result['default_comment_status']['readonly'] ); 
     102 
     103        $this->assertEquals( get_option( 'default_ping_status' ), $result['default_ping_status']['value'] ); 
     104        $this->assertTrue( $result['default_ping_status']['readonly'] ); 
     105    } 
     106 
     107    function test_option_values_admin() { 
     108        global $wp_version; 
     109 
     110        $result = $this->myxmlrpcserver->wp_getOptions( array( 1, 'administrator', 'administrator' ) ); 
    29111        $this->assertInternalType( 'array', $result ); 
    30112 
     
    102184        $this->assertFalse( $result['default_ping_status']['readonly'] ); 
    103185    } 
    104  
    105186} 
Note: See TracChangeset for help on using the changeset viewer.