88class Tests_Abilities_API_WpCoreAbilities extends WP_UnitTestCase {
99
1010 /**
11- * Tests that the `core/get-site-info` ability is registered with the expected schema.
12- */
13- public function test_core_get_bloginfo_ability_is_registered (): void {
14- $ ability = wp_get_ability ( 'core/get-site-info ' );
11+ * Tests that the `core/get-site-info` ability is registered with the expected schema.
12+ */
13+ public function test_core_get_bloginfo_ability_is_registered (): void {
14+ $ ability = wp_get_ability ( 'core/get-site-info ' );
1515
1616 $ this ->assertInstanceOf ( WP_Ability::class, $ ability );
1717 $ this ->assertTrue ( $ ability ->get_meta_item ( 'show_in_rest ' , false ) );
@@ -35,14 +35,14 @@ public function test_core_get_bloginfo_ability_is_registered(): void {
3535 }
3636
3737 /**
38- * Tests executing the `core/get-site-info` ability returns all fields by default.
39- */
40- public function test_core_get_bloginfo_executes (): void {
41- // Requires manage_options.
42- $ admin_id = self ::factory ()->user ->create ( array ( 'role ' => 'administrator ' ) );
43- wp_set_current_user ( $ admin_id );
38+ * Tests executing the `core/get-site-info` ability returns all fields by default.
39+ */
40+ public function test_core_get_bloginfo_executes (): void {
41+ // Requires manage_options.
42+ $ admin_id = self ::factory ()->user ->create ( array ( 'role ' => 'administrator ' ) );
43+ wp_set_current_user ( $ admin_id );
4444
45- $ ability = wp_get_ability ( 'core/get-site-info ' );
45+ $ ability = wp_get_ability ( 'core/get-site-info ' );
4646
4747 // Test without fields parameter - should return all fields.
4848 $ result = $ ability ->execute ();
@@ -69,14 +69,14 @@ public function test_core_get_bloginfo_executes(): void {
6969 $ this ->assertSame ( get_bloginfo ( 'name ' ), $ result ['name ' ] );
7070 $ this ->assertSame ( get_bloginfo ( 'url ' ), $ result ['url ' ] );
7171
72- wp_set_current_user ( 0 );
73- }
72+ wp_set_current_user ( 0 );
73+ }
7474
7575 /**
76- * Tests that executing the current user info ability requires authentication.
77- */
78- public function test_core_get_current_user_info_requires_authentication (): void {
79- $ ability = wp_get_ability ( 'core/get-user-info ' );
76+ * Tests that executing the current user info ability requires authentication.
77+ */
78+ public function test_core_get_current_user_info_requires_authentication (): void {
79+ $ ability = wp_get_ability ( 'core/get-user-info ' );
8080
8181 $ this ->assertFalse ( $ ability ->check_permissions () );
8282
@@ -86,9 +86,9 @@ public function test_core_get_current_user_info_requires_authentication(): void
8686 }
8787
8888 /**
89- * Tests executing the current user info ability as an authenticated user.
90- */
91- public function test_core_get_current_user_info_returns_user_data (): void {
89+ * Tests executing the current user info ability as an authenticated user.
90+ */
91+ public function test_core_get_current_user_info_returns_user_data (): void {
9292 $ user_id = self ::factory ()->user ->create (
9393 array (
9494 'role ' => 'subscriber ' ,
@@ -98,7 +98,7 @@ public function test_core_get_current_user_info_returns_user_data(): void {
9898
9999 wp_set_current_user ( $ user_id );
100100
101- $ ability = wp_get_ability ( 'core/get-user-info ' );
101+ $ ability = wp_get_ability ( 'core/get-user-info ' );
102102
103103 $ this ->assertTrue ( $ ability ->check_permissions () );
104104
@@ -112,25 +112,24 @@ public function test_core_get_current_user_info_returns_user_data(): void {
112112 }
113113
114114 /**
115- * Tests executing the environment info ability.
116- */
117- public function test_core_get_environment_type_executes (): void {
118- // Requires manage_options.
119- $ admin_id = self ::factory ()->user ->create ( array ( 'role ' => 'administrator ' ) );
120- wp_set_current_user ( $ admin_id );
121-
122- $ ability = wp_get_ability ( 'core/get-environment-info ' );
123- $ environment = wp_get_environment_type ();
124- $ ability_data = $ ability ->execute ();
125-
126- $ this ->assertIsArray ( $ ability_data );
127- $ this ->assertArrayHasKey ( 'environment ' , $ ability_data );
128- $ this ->assertArrayHasKey ( 'php_version ' , $ ability_data );
129- $ this ->assertArrayHasKey ( 'db_server_info ' , $ ability_data );
130- $ this ->assertArrayHasKey ( 'wp_version ' , $ ability_data );
131- $ this ->assertSame ( $ environment , $ ability_data ['environment ' ] );
132-
133- wp_set_current_user ( 0 );
134- }
115+ * Tests executing the environment info ability.
116+ */
117+ public function test_core_get_environment_type_executes (): void {
118+ // Requires manage_options.
119+ $ admin_id = self ::factory ()->user ->create ( array ( 'role ' => 'administrator ' ) );
120+ wp_set_current_user ( $ admin_id );
121+
122+ $ ability = wp_get_ability ( 'core/get-environment-info ' );
123+ $ environment = wp_get_environment_type ();
124+ $ ability_data = $ ability ->execute ();
125+
126+ $ this ->assertIsArray ( $ ability_data );
127+ $ this ->assertArrayHasKey ( 'environment ' , $ ability_data );
128+ $ this ->assertArrayHasKey ( 'php_version ' , $ ability_data );
129+ $ this ->assertArrayHasKey ( 'db_server_info ' , $ ability_data );
130+ $ this ->assertArrayHasKey ( 'wp_version ' , $ ability_data );
131+ $ this ->assertSame ( $ environment , $ ability_data ['environment ' ] );
135132
133+ wp_set_current_user ( 0 );
134+ }
136135}
0 commit comments