WordPress.org

Make WordPress Core

Changeset 425 in tests


Ignore:
Timestamp:
08/23/11 12:48:23 (3 years ago)
Author:
nacin
Message:

map_meta_cap tests for #WP15779. fixes #11.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_includes_capabilities.php

    r424 r425  
    133133        register_post_type( $this->post_type, array( 
    134134            'capability_type' => 'post', 
     135            'capabilities' => array( 
     136                'edit_post' => 'edit_book', 
     137                'read_post' => 'read_book', 
     138                'delete_post' => 'delete_book', 
     139            ), 
     140        ) ); 
     141 
     142        $post_type_object = get_post_type_object( $this->post_type ); 
     143 
     144        $this->assertFalse( $post_type_object->map_meta_cap ); 
     145 
     146        $this->assertEquals( array( 'edit_book' ), 
     147            map_meta_cap( 'edit_post', $this->user_id, $this->post_id ) ); 
     148        $this->assertEquals( array( 'edit_book' ), 
     149            map_meta_cap( $post_type_object->cap->edit_post, $this->user_id, $this->post_id ) ); 
     150 
     151        $this->assertEquals( array( 'read_book' ), 
     152            map_meta_cap( 'read_post', $this->user_id, $this->post_id ) ); 
     153        $this->assertEquals( array( 'read_book' ), 
     154            map_meta_cap( $post_type_object->cap->read_post, $this->user_id, $this->post_id ) ); 
     155 
     156        $this->assertEquals( array( 'delete_book' ), 
     157            map_meta_cap( 'delete_post', $this->user_id, $this->post_id ) ); 
     158        $this->assertEquals( array( 'delete_book' ), 
     159            map_meta_cap( $post_type_object->cap->delete_post, $this->user_id, $this->post_id ) ); 
     160    } 
     161 
     162    function test_capability_type_post_with_all_meta_caps_renamed_mapped() { 
     163        register_post_type( $this->post_type, array( 
     164            'capability_type' => 'post', 
    135165            'map_meta_cap' => true, 
    136166            'capabilities' => array( 
Note: See TracChangeset for help on using the changeset viewer.