WordPress.org

Make WordPress Core

Changeset 199 in tests


Ignore:
Timestamp:
04/03/08 22:28:36 (7 years ago)
Author:
tellyworth
Message:

stop fatal error in user caps test (thanks jacob)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_user_capabilities.php

    r169 r199  
    1212        $this->_flush_roles(); 
    1313 
     14        $this->orig_users = get_users_of_blog(); 
    1415    } 
    1516 
     
    2627        // this will flush everything and reload it from the db 
    2728        unset($GLOBALS['wp_user_roles']); 
    28         $GLOBALS['wp_roles'] = new WP_Roles(); 
     29        #$GLOBALS['wp_roles'] = new WP_Roles(); 
    2930    } 
    3031 
     
    489490         
    490491        global $wpdb; 
    491         $wpdb->query("DELETE FROM {$wpdb->user_role} WHERE user_id = {$id}"); 
     492        if (!empty($wpdb->user_role)) 
     493            $wpdb->query("DELETE FROM {$wpdb->user_role} WHERE user_id = {$id}"); 
    492494         
    493495        update_usermeta($id, $user->cap_key, array('editor' => true)); 
     
    513515        $this->knownWPBug(5540); 
    514516         
     517        if ( !is_callable('upgrade_user_roles') ) 
     518            $this->markTestSkipped('depends on patch #5540'); 
     519         
    515520        global $wpdb, $blog_id; 
    516  
     521         
    517522        // make some users with old style usermeta roles and caps 
    518523        $id = array(); 
     
    598603        $this->assertEquals( array('edit_posts' => true, 'upload_files' => true), $old_caps ); 
    599604         
    600          
    601     } 
    602  
     605        // quick test for get_users_of_blog 
     606        $users = get_users_of_blog(); 
     607        #dmp('orig users', $this->orig_users); 
     608        #dmp('now users', $users); 
     609        $this->assertEquals( 5, count($users) - count($this->orig_users) ); 
     610         
     611        #dmp('get_roles_with_cap edit_posts', get_roles_with_cap('edit_posts')); 
     612        #dmp('get_users_of_blog', get_users_of_blog()); 
     613        #dmp('get_users_with_cap edit_posts', get_users_with_cap('edit_posts')); 
     614    } 
     615 
     616    function _test_generate_role_thingy() { 
     617        global $wp_roles; 
     618        foreach (array_keys($wp_roles->roles) as $role) { 
     619            $obj = $wp_roles->role_objects[$role]; 
     620             
     621            echo "\nadd_role('{$role}', '{$obj->name}', ".var_export($obj->capabilities, true)."\n"; 
     622            echo ")\n"; 
     623        } 
     624    } 
    603625} 
    604626 
Note: See TracChangeset for help on using the changeset viewer.