Changeset 41625 for trunk/tests/phpunit/tests/user/capabilities.php
- Timestamp:
- 09/27/2017 09:43:59 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/user/capabilities.php
r41624 r41625 1940 1940 $this->assertSame( 333, $user->get_site_id() ); 1941 1941 } 1942 1943 /** 1944 * @ticket 38645 1945 * @group ms-required 1946 */ 1947 function test_init_roles_for_different_site() { 1948 global $wpdb; 1949 1950 $site_id = self::factory()->blog->create(); 1951 1952 switch_to_blog( $site_id ); 1953 1954 $role_name = 'uploader'; 1955 add_role( $role_name, 'Uploader', array( 1956 'read' => true, 1957 'upload_files' => true, 1958 ) ); 1959 1960 restore_current_blog(); 1961 1962 $wp_roles = wp_roles(); 1963 $wp_roles->for_site( $site_id ); 1964 1965 $this->assertTrue( isset( $wp_roles->role_objects[ $role_name ] ) ); 1966 } 1967 1968 /** 1969 * @ticket 38645 1970 */ 1971 function test_get_roles_data() { 1972 global $wpdb; 1973 1974 $custom_roles = array( 1975 'test_role' => array( 1976 'name' => 'Test Role', 1977 'capabilities' => array( 1978 'do_foo' => true, 1979 'do_bar' => false, 1980 ), 1981 ), 1982 ); 1983 1984 // Test `WP_Roles::get_roles_data()` by manually setting the roles option. 1985 update_option( $wpdb->get_blog_prefix( get_current_blog_id() ) . 'user_roles', $custom_roles ); 1986 1987 $roles = new WP_Roles(); 1988 $this->assertSame( $custom_roles, $roles->roles ); 1989 } 1990 1991 /** 1992 * @ticket 38645 1993 */ 1994 function test_roles_get_site_id_default() { 1995 $roles = new WP_Roles(); 1996 $this->assertSame( get_current_blog_id(), $roles->get_site_id() ); 1997 } 1998 1999 /** 2000 * @ticket 38645 2001 */ 2002 function test_roles_get_site_id() { 2003 global $wpdb; 2004 2005 // Suppressing errors here allows to get around creating an actual site, 2006 // which is unnecessary for this test. 2007 $suppress = $wpdb->suppress_errors(); 2008 $roles = new WP_Roles( 333 ); 2009 $wpdb->suppress_errors( $suppress ); 2010 2011 $this->assertSame( 333, $roles->get_site_id() ); 2012 } 1942 2013 }
Note: See TracChangeset
for help on using the changeset viewer.