Make WordPress Core


Ignore:
Timestamp:
06/30/2012 05:48:18 PM (14 years ago)
Author:
maxcutler
Message:

Port the XML-RPC test suite.

Fixes #45.

File:
1 edited

Legend:

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

    r735 r768  
    11<?php
    22
    3 class TestXMLRPCServer_wp_editTerm extends WPXMLRPCServerTestCase {
     3class TestXMLRPCServer_wp_editTerm extends WP_XMLRPC_UnitTestCase {
    44        var $parent_term;
    55        var $child_term;
    … …  
    1414        }
    1515
    16         function tearDown() {
    17                 parent::tearDown();
    18 
    19                 wp_delete_term( $this->parent_term['term_id'], 'category' );
    20                 wp_delete_term( $this->child_term['term_id'], 'category' );
    21                 wp_delete_term( $this->post_tag['term_id'], 'post_tag' );
    22         }
    23 
    2416        function test_invalid_username_password() {
    2517                $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'username', 'password', 'category', 1 ) );
    … …  
    2921
    3022        function test_empty_taxonomy() {
     23                $this->make_user_by_role( 'subscriber' );
     24
    3125                $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'subscriber', 'subscriber', '', array( 'taxonomy' => '' ) ) );
    3226                $this->assertInstanceOf( 'IXR_Error', $result );
    … …  
    3630
    3731        function test_invalid_taxonomy() {
     32                $this->make_user_by_role( 'subscriber' );
     33
    3834                $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'subscriber', 'subscriber', $this->parent_term['term_id'], array( 'taxonomy' => 'not_existing' ) ) );
    3935                $this->assertInstanceOf( 'IXR_Error', $result );
    … …  
    4339
    4440        function test_incapable_user() {
     41                $this->make_user_by_role( 'subscriber' );
     42
    4543                $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'subscriber', 'subscriber', $this->parent_term['term_id'], array( 'taxonomy' => 'category' ) ) );
    4644                $this->assertInstanceOf( 'IXR_Error', $result );
    … …  
    5048
    5149        function test_term_not_exists() {
     50                $this->make_user_by_role( 'editor' );
     51
    5252                $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', 9999, array( 'taxonomy' => 'category' ) ) );
    5353                $this->assertInstanceOf( 'IXR_Error', $result );
    … …  
    5757
    5858        function test_empty_term() {
     59                $this->make_user_by_role( 'editor' );
     60
    5961                $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', '', array( 'taxonomy' => 'category' ) ) );
    6062                $this->assertInstanceOf( 'IXR_Error', $result );
    … …  
    6466
    6567        function test_empty_term_name() {
     68                $this->make_user_by_role( 'editor' );
     69
    6670                $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', $this->parent_term['term_id'], array( 'taxonomy' => 'category', 'name' => '' ) ) );
    6771                $this->assertInstanceOf( 'IXR_Error', $result );
    … …  
    7175
    7276        function test_parent_for_nonhierarchical() {
     77                $this->make_user_by_role( 'editor' );
     78
    7379                $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', $this->post_tag['term_id'], array( 'taxonomy' => 'post_tag', 'parent' => $this->parent_term['term_id'] ) ) );
    7480                $this->assertInstanceOf( 'IXR_Error', $result );
    … …  
    7884
    7985        function test_parent_empty() {
     86                $this->make_user_by_role( 'editor' );
     87
    8088                $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', $this->child_term['term_id'], array( 'taxonomy' => 'category', 'parent' => '', 'name' => 'test' ) ) );
    8189                $this->assertInstanceOf( 'IXR_Error', $result );
    … …  
    8593
    8694        function test_parent_invalid() {
     95                $this->make_user_by_role( 'editor' );
     96
    8797                $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', $this->child_term['term_id'], array( 'taxonomy' => 'category', 'parent' => 'dasda', 'name' => 'test' ) ) );
    8898                $this->assertInstanceOf( 'IXR_Error', $result );
    … …  
    91101
    92102        function test_parent_not_existing() {
     103                $this->make_user_by_role( 'editor' );
     104
    93105                $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', $this->child_term['term_id'], array( 'taxonomy' => 'category', 'parent' => 9999, 'name' => 'test' ) ) );
    94106                $this->assertInstanceOf( 'IXR_Error', $result );
    … …  
    98110
    99111        function test_parent_duplicate_slug() {
     112                $this->make_user_by_role( 'editor' );
     113
    100114                $parent_term = get_term_by( 'id', $this->parent_term['term_id'], 'category' );
    101115                $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', $this->child_term['term_id'], array( 'taxonomy' => 'category', 'slug' => $parent_term->slug ) ) );
    … …  
    106120
    107121        function test_edit_all_fields() {
     122                $this->make_user_by_role( 'editor' );
     123
    108124                $fields = array( 'taxonomy' => 'category', 'name' => 'Child 2', 'parent' => $this->parent_term['term_id'], 'description' => 'Child term', 'slug' => 'child_2' );
    109125                $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', $this->child_term['term_id'], $fields ) );
Note: See TracChangeset for help on using the changeset viewer.