Changeset 53942 for trunk/tests/phpunit/tests/user/capabilities.php
- Timestamp:
- 08/25/2022 03:34:24 PM (3 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/user/capabilities.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/user/capabilities.php
r53408 r53942 31 31 protected static $block_id; 32 32 33 /** 34 * Temporary storage for roles for tests using filter callbacks. 35 * 36 * Used in the `test_wp_roles_init_action()` method. 37 * 38 * @var array 39 */ 40 private $role_test_wp_roles_init; 41 33 42 public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { 34 43 self::$users = array( … … 59 68 $this->flush_roles(); 60 69 70 } 71 72 /** 73 * Clean up after each test. 74 */ 75 public function tear_down() { 76 unset( $this->role_test_wp_roles_init ); 77 78 parent::tear_down(); 61 79 } 62 80 … … 1997 2015 } 1998 2016 1999 2000 protected $_role_test_wp_roles_role;2001 2017 /** 2002 2018 * @ticket 23016 2003 2019 */ 2004 2020 public function test_wp_roles_init_action() { 2005 $this-> _role_test_wp_roles_init = array(2021 $this->role_test_wp_roles_init = array( 2006 2022 'role' => 'test_wp_roles_init', 2007 2023 'info' => array( … … 2016 2032 remove_action( 'wp_roles_init', array( $this, '_hook_wp_roles_init' ) ); 2017 2033 2018 $expected = new WP_Role( $this-> _role_test_wp_roles_init['role'], $this->_role_test_wp_roles_init['info']['capabilities'] );2019 2020 $role = $wp_roles->get_role( $this-> _role_test_wp_roles_init['role'] );2034 $expected = new WP_Role( $this->role_test_wp_roles_init['role'], $this->role_test_wp_roles_init['info']['capabilities'] ); 2035 2036 $role = $wp_roles->get_role( $this->role_test_wp_roles_init['role'] ); 2021 2037 2022 2038 $this->assertEquals( $expected, $role ); 2023 $this->assertContains( $this-> _role_test_wp_roles_init['info']['name'], $wp_roles->role_names );2039 $this->assertContains( $this->role_test_wp_roles_init['info']['name'], $wp_roles->role_names ); 2024 2040 } 2025 2041 2026 2042 public function _hook_wp_roles_init( $wp_roles ) { 2027 $wp_roles->add_role( $this-> _role_test_wp_roles_init['role'], $this->_role_test_wp_roles_init['info']['name'], $this->_role_test_wp_roles_init['info']['capabilities'] );2043 $wp_roles->add_role( $this->role_test_wp_roles_init['role'], $this->role_test_wp_roles_init['info']['name'], $this->role_test_wp_roles_init['info']['capabilities'] ); 2028 2044 } 2029 2045
Note: See TracChangeset
for help on using the changeset viewer.