<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[61069] trunk: Abilities API: Rename files with registration for core abilities</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/61069">61069</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/61069","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>gziolo</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2025-10-27 09:17:14 +0000 (Mon, 27 Oct 2025)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Abilities API: Rename files with registration for core abilities

It looks like `npm run grunt patch:` didn't pick up renaming part ...

Follow-up <a href="https://core.trac.wordpress.org/changeset/61068">[61068]</a>.
See <a href="https://core.trac.wordpress.org/ticket/64146">#64146</a>.</pre>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesabilitiesphp">trunk/src/wp-includes/abilities.php</a></li>
<li><a href="#trunktestsphpunittestsabilitiesapiwpRegisterCoreAbilitiesphp">trunk/tests/phpunit/tests/abilities-api/wpRegisterCoreAbilities.php</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li>trunk/src/wp-includes/abilities/</li>
<li><a href="#trunktestsphpunittestsabilitiesapiwpCoreAbilitiesphp">trunk/tests/phpunit/tests/abilities-api/wpCoreAbilities.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesabilitiesphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/wp-includes/abilities.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/abilities.php                               (rev 0)
+++ trunk/src/wp-includes/abilities.php 2025-10-27 09:17:14 UTC (rev 61069)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,263 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Core Abilities registration.
+ *
+ * @package WordPress
+ * @subpackage Abilities_API
+ * @since 6.9.0
+ */
+
+declare( strict_types = 1 );
+
+/**
+ * Registers the core ability categories.
+ *
+ * @since 6.9.0
+ *
+ * @return void
+ */
+function wp_register_core_ability_categories(): void {
+       wp_register_ability_category(
+               'site',
+               array(
+                       'label'       => __( 'Site' ),
+                       'description' => __( 'Abilities that retrieve or modify site information and settings.' ),
+               )
+       );
+
+       wp_register_ability_category(
+               'user',
+               array(
+                       'label'       => __( 'User' ),
+                       'description' => __( 'Abilities that retrieve or modify user information and settings.' ),
+               )
+       );
+}
+
+/**
+ * Registers the default core abilities.
+ *
+ * @since 6.9.0
+ *
+ * @return void
+ */
+function wp_register_core_abilities(): void {
+       $category_site = 'site';
+       $category_user = 'user';
+
+       $site_info_properties = array(
+               'name'        => array(
+                       'type'        => 'string',
+                       'description' => __( 'The site title.' ),
+               ),
+               'description' => array(
+                       'type'        => 'string',
+                       'description' => __( 'The site tagline.' ),
+               ),
+               'url'         => array(
+                       'type'        => 'string',
+                       'description' => __( 'The site home URL.' ),
+               ),
+               'wpurl'       => array(
+                       'type'        => 'string',
+                       'description' => __( 'The WordPress installation URL.' ),
+               ),
+               'admin_email' => array(
+                       'type'        => 'string',
+                       'description' => __( 'The site administrator email address.' ),
+               ),
+               'charset'     => array(
+                       'type'        => 'string',
+                       'description' => __( 'The site character encoding.' ),
+               ),
+               'language'    => array(
+                       'type'        => 'string',
+                       'description' => __( 'The site language locale code.' ),
+               ),
+               'version'     => array(
+                       'type'        => 'string',
+                       'description' => __( 'The WordPress version.' ),
+               ),
+       );
+       $site_info_fields = array_keys( $site_info_properties );
+
+       wp_register_ability(
+               'core/get-site-info',
+               array(
+                       'label'               => __( 'Get Site Information' ),
+                       'description'         => __( 'Returns site information configured in WordPress. By default returns all fields, or optionally a filtered subset.' ),
+                       'category'            => $category_site,
+                       'input_schema'        => array(
+                               'type'                 => 'object',
+                               'properties'           => array(
+                                       'fields' => array(
+                                               'type'        => 'array',
+                                               'items'       => array(
+                                                       'type' => 'string',
+                                                       'enum' => $site_info_fields,
+                                               ),
+                                               'description' => __( 'Optional: Limit response to specific fields. If omitted, all fields are returned.' ),
+                                       ),
+                               ),
+                               'additionalProperties' => false,
+                               'default'              => array(),
+                       ),
+                       'output_schema'       => array(
+                               'type'                 => 'object',
+                               'properties'           => $site_info_properties,
+                               'additionalProperties' => false,
+                       ),
+                       'execute_callback'    => static function ( $input = array() ) use ( $site_info_fields ): array {
+                               $input = is_array( $input ) ? $input : array();
+                               $requested_fields = ! empty( $input['fields'] ) ? $input['fields'] : $site_info_fields;
+
+                               $result = array();
+                               foreach ( $requested_fields as $field ) {
+                                       $result[ $field ] = get_bloginfo( $field );
+                               }
+
+                               return $result;
+                       },
+                       'permission_callback' => static function (): bool {
+                               return current_user_can( 'manage_options' );
+                       },
+                       'meta'                => array(
+                               'annotations'  => array(
+                                       'readonly'    => true,
+                                       'destructive' => false,
+                                       'idempotent'  => true,
+                               ),
+                               'show_in_rest' => true,
+                       ),
+               )
+       );
+
+       wp_register_ability(
+               'core/get-user-info',
+               array(
+                       'label'               => __( 'Get User Information' ),
+                       'description'         => __( 'Returns basic profile details for the current authenticated user to support personalization, auditing, and access-aware behavior.' ),
+                       'category'            => $category_user,
+                       'output_schema'       => array(
+                               'type'                 => 'object',
+                               'required'             => array( 'id', 'display_name', 'user_nicename', 'user_login', 'roles', 'locale' ),
+                               'properties'           => array(
+                                       'id'            => array(
+                                               'type'        => 'integer',
+                                               'description' => __( 'The user ID.' ),
+                                       ),
+                                       'display_name'  => array(
+                                               'type'        => 'string',
+                                               'description' => __( 'The display name of the user.' ),
+                                       ),
+                                       'user_nicename' => array(
+                                               'type'        => 'string',
+                                               'description' => __( 'The URL-friendly name for the user.' ),
+                                       ),
+                                       'user_login'    => array(
+                                               'type'        => 'string',
+                                               'description' => __( 'The login username for the user.' ),
+                                       ),
+                                       'roles'         => array(
+                                               'type'        => 'array',
+                                               'description' => __( 'The roles assigned to the user.' ),
+                                               'items'       => array(
+                                                       'type' => 'string',
+                                               ),
+                                       ),
+                                       'locale'        => array(
+                                               'type'        => 'string',
+                                               'description' => __( 'The locale string for the user, such as en_US.' ),
+                                       ),
+                               ),
+                               'additionalProperties' => false,
+                       ),
+                       'execute_callback'    => static function (): array {
+                               $current_user = wp_get_current_user();
+
+                               return array(
+                                       'id'            => $current_user->ID,
+                                       'display_name'  => $current_user->display_name,
+                                       'user_nicename' => $current_user->user_nicename,
+                                       'user_login'    => $current_user->user_login,
+                                       'roles'         => $current_user->roles,
+                                       'locale'        => get_user_locale( $current_user ),
+                               );
+                       },
+                       'permission_callback' => static function (): bool {
+                               return is_user_logged_in();
+                       },
+                       'meta'                => array(
+                               'annotations'  => array(
+                                       'readonly'    => true,
+                                       'destructive' => false,
+                                       'idempotent'  => true,
+                               ),
+                               'show_in_rest' => false,
+                       ),
+               )
+       );
+
+       wp_register_ability(
+               'core/get-environment-info',
+               array(
+                       'label'               => __( 'Get Environment Info' ),
+                       'description'         => __( 'Returns core details about the site\'s runtime context for diagnostics and compatibility (environment, PHP runtime, database server info, WordPress version).' ),
+                       'category'            => $category_site,
+                       'output_schema'       => array(
+                               'type'                 => 'object',
+                               'required'             => array( 'environment', 'php_version', 'db_server_info', 'wp_version' ),
+                               'properties'           => array(
+                                       'environment'    => array(
+                                               'type'        => 'string',
+                                               'description' => __( 'The site\'s runtime environment classification (can be one of these: production, staging, development, local).' ),
+                                               'enum'        => array( 'production', 'staging', 'development', 'local' ),
+                                       ),
+                                       'php_version'    => array(
+                                               'type'        => 'string',
+                                               'description' => __( 'The PHP runtime version executing WordPress.' ),
+                                       ),
+                                       'db_server_info' => array(
+                                               'type'        => 'string',
+                                               'description' => __( 'The database server vendor and version string reported by the driver.' ),
+                                               'examples'    => array( '8.0.34', '10.11.6-MariaDB' ),
+                                       ),
+                                       'wp_version'     => array(
+                                               'type'        => 'string',
+                                               'description' => __( 'The WordPress core version running on this site.' ),
+                                       ),
+                               ),
+                               'additionalProperties' => false,
+                       ),
+                       'execute_callback'    => static function (): array {
+                               global $wpdb;
+
+                               $env          = wp_get_environment_type();
+                               $php_version  = phpversion();
+                               $db_server_info  = '';
+                               if ( method_exists( $wpdb, 'db_server_info' ) ) {
+                                       $db_server_info = $wpdb->db_server_info() ?? '';
+                               }
+                               $wp_version   = get_bloginfo( 'version' );
+
+                               return array(
+                                       'environment'    => $env,
+                                       'php_version'    => $php_version,
+                                       'db_server_info' => $db_server_info,
+                                       'wp_version'     => $wp_version,
+                               );
+                       },
+                       'permission_callback' => static function (): bool {
+                               return current_user_can( 'manage_options' );
+                       },
+                       'meta'                => array(
+                               'annotations'  => array(
+                                       'readonly'    => true,
+                                       'destructive' => false,
+                                       'idempotent'  => true,
+                               ),
+                               'show_in_rest' => true,
+                       ),
+               )
+       );
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/src/wp-includes/abilities.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="trunktestsphpunittestsabilitiesapiwpCoreAbilitiesphp"></a>
<div class="delfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Deleted: trunk/tests/phpunit/tests/abilities-api/wpCoreAbilities.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/abilities-api/wpCoreAbilities.php       2025-10-27 09:06:15 UTC (rev 61068)
+++ trunk/tests/phpunit/tests/abilities-api/wpCoreAbilities.php 2025-10-27 09:17:14 UTC (rev 61069)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,177 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-
-declare( strict_types=1 );
-
-/**
- * Tests for the core abilities shipped with the Abilities API.
- *
- * @covers wp_register_core_ability_categories
- * @covers wp_register_core_abilities
- *
- * @group abilities-api
- */
-class Tests_Abilities_API_WpRegisterCoreAbilities extends WP_UnitTestCase {
-
-       /**
-        * Set up before the class.
-        *
-        * @since 6.9.0
-        */
-       public static function set_up_before_class(): void {
-               parent::set_up_before_class();
-
-               // Ensure core abilities are registered for these tests.
-               // Temporarily remove the unhook functions so we can register core abilities.
-               remove_action( 'wp_abilities_api_categories_init', '_unhook_core_ability_categories_registration', 1 );
-               remove_action( 'wp_abilities_api_init', '_unhook_core_abilities_registration', 1 );
-
-               // Add the core registration hooks and fire the actions.
-               add_action( 'wp_abilities_api_categories_init', 'wp_register_core_ability_categories' );
-               add_action( 'wp_abilities_api_init', 'wp_register_core_abilities' );
-               do_action( 'wp_abilities_api_categories_init' );
-               do_action( 'wp_abilities_api_init' );
-       }
-
-       /**
-        * Tear down after the class.
-        *
-        * @since 6.9.0
-        */
-       public static function tear_down_after_class(): void {
-               // Re-add the unhook functions for subsequent tests.
-               add_action( 'wp_abilities_api_categories_init', '_unhook_core_ability_categories_registration', 1 );
-               add_action( 'wp_abilities_api_init', '_unhook_core_abilities_registration', 1 );
-
-               // Remove the core abilities and their categories.
-               foreach ( wp_get_abilities() as $ability ) {
-                       wp_unregister_ability( $ability->get_name() );
-               }
-               foreach ( wp_get_ability_categories() as $ability_category ) {
-                       wp_unregister_ability_category( $ability_category->get_slug() );
-               }
-
-               parent::tear_down_after_class();
-       }
-
-       /**
-        * Tests that the `core/get-site-info` ability is registered with the expected schema.
-        * @ticket 64146
-        */
-       public function test_core_get_site_info_ability_is_registered(): void {
-               $ability = wp_get_ability( 'core/get-site-info' );
-
-               $this->assertInstanceOf( WP_Ability::class, $ability );
-               $this->assertTrue( $ability->get_meta_item( 'show_in_rest', false ) );
-
-               $input_schema  = $ability->get_input_schema();
-               $output_schema = $ability->get_output_schema();
-
-               $this->assertSame( 'object', $input_schema['type'] );
-               $this->assertArrayHasKey( 'default', $input_schema );
-               $this->assertSame( array(), $input_schema['default'] );
-
-               // Input schema should have optional fields array.
-               $this->assertArrayHasKey( 'fields', $input_schema['properties'] );
-               $this->assertSame( 'array', $input_schema['properties']['fields']['type'] );
-               $this->assertContains( 'name', $input_schema['properties']['fields']['items']['enum'] );
-
-               // Output schema should have all fields documented.
-               $this->assertArrayHasKey( 'name', $output_schema['properties'] );
-               $this->assertArrayHasKey( 'url', $output_schema['properties'] );
-               $this->assertArrayHasKey( 'version', $output_schema['properties'] );
-       }
-
-       /**
-        * Tests executing the `core/get-site-info` ability returns all fields by default.
-        * @ticket 64146
-        */
-       public function test_core_get_site_info_executes(): void {
-               // Requires manage_options.
-               $admin_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
-               wp_set_current_user( $admin_id );
-
-               $ability = wp_get_ability( 'core/get-site-info' );
-
-               // Test without fields parameter - should return all fields.
-               $result = $ability->execute();
-
-               $this->assertIsArray( $result );
-               $this->assertArrayHasKey( 'name', $result );
-               $this->assertArrayHasKey( 'description', $result );
-               $this->assertArrayHasKey( 'url', $result );
-               $this->assertArrayHasKey( 'version', $result );
-               $this->assertSame( get_bloginfo( 'name' ), $result['name'] );
-
-               // Test with fields parameter - should return only requested fields.
-               $result = $ability->execute(
-                       array(
-                               'fields' => array( 'name', 'url' ),
-                       )
-               );
-
-               $this->assertIsArray( $result );
-               $this->assertCount( 2, $result );
-               $this->assertSame( get_bloginfo( 'name' ), $result['name'] );
-               $this->assertSame( get_bloginfo( 'url' ), $result['url'] );
-       }
-
-       /**
-        * Tests that executing the current user info ability requires authentication.
-        * @ticket 64146
-        */
-       public function test_core_get_current_user_info_requires_authentication(): void {
-               $ability = wp_get_ability( 'core/get-user-info' );
-
-               $this->assertFalse( $ability->check_permissions() );
-
-               $result = $ability->execute();
-               $this->assertWPError( $result );
-               $this->assertSame( 'ability_invalid_permissions', $result->get_error_code() );
-       }
-
-       /**
-        * Tests executing the current user info ability as an authenticated user.
-        * @ticket 64146
-        */
-       public function test_core_get_current_user_info_returns_user_data(): void {
-               $user_id = self::factory()->user->create(
-                       array(
-                               'role'   => 'subscriber',
-                               'locale' => 'fr_FR',
-                       )
-               );
-
-               wp_set_current_user( $user_id );
-
-               $ability = wp_get_ability( 'core/get-user-info' );
-
-               $this->assertTrue( $ability->check_permissions() );
-
-               $result = $ability->execute();
-               $this->assertSame( $user_id, $result['id'] );
-               $this->assertSame( 'fr_FR', $result['locale'] );
-               $this->assertSame( 'subscriber', $result['roles'][0] );
-               $this->assertSame( get_userdata( $user_id )->display_name, $result['display_name'] );
-       }
-
-       /**
-        * Tests executing the environment info ability.
-        * @ticket 64146
-        */
-       public function test_core_get_environment_info_executes(): void {
-               // Requires manage_options.
-               $admin_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
-               wp_set_current_user( $admin_id );
-
-               $ability      = wp_get_ability( 'core/get-environment-info' );
-               $environment  = wp_get_environment_type();
-               $ability_data = $ability->execute();
-
-               $this->assertIsArray( $ability_data );
-               $this->assertArrayHasKey( 'environment', $ability_data );
-               $this->assertArrayHasKey( 'php_version', $ability_data );
-               $this->assertArrayHasKey( 'db_server_info', $ability_data );
-               $this->assertArrayHasKey( 'wp_version', $ability_data );
-               $this->assertSame( $environment, $ability_data['environment'] );
-       }
-}
</del></span></pre></div>
<a id="trunktestsphpunittestsabilitiesapiwpRegisterCoreAbilitiesphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/tests/abilities-api/wpRegisterCoreAbilities.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/abilities-api/wpRegisterCoreAbilities.php                               (rev 0)
+++ trunk/tests/phpunit/tests/abilities-api/wpRegisterCoreAbilities.php 2025-10-27 09:17:14 UTC (rev 61069)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,177 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+declare( strict_types=1 );
+
+/**
+ * Tests for the core abilities shipped with the Abilities API.
+ *
+ * @covers wp_register_core_ability_categories
+ * @covers wp_register_core_abilities
+ *
+ * @group abilities-api
+ */
+class Tests_Abilities_API_WpRegisterCoreAbilities extends WP_UnitTestCase {
+
+       /**
+        * Set up before the class.
+        *
+        * @since 6.9.0
+        */
+       public static function set_up_before_class(): void {
+               parent::set_up_before_class();
+
+               // Ensure core abilities are registered for these tests.
+               // Temporarily remove the unhook functions so we can register core abilities.
+               remove_action( 'wp_abilities_api_categories_init', '_unhook_core_ability_categories_registration', 1 );
+               remove_action( 'wp_abilities_api_init', '_unhook_core_abilities_registration', 1 );
+
+               // Add the core registration hooks and fire the actions.
+               add_action( 'wp_abilities_api_categories_init', 'wp_register_core_ability_categories' );
+               add_action( 'wp_abilities_api_init', 'wp_register_core_abilities' );
+               do_action( 'wp_abilities_api_categories_init' );
+               do_action( 'wp_abilities_api_init' );
+       }
+
+       /**
+        * Tear down after the class.
+        *
+        * @since 6.9.0
+        */
+       public static function tear_down_after_class(): void {
+               // Re-add the unhook functions for subsequent tests.
+               add_action( 'wp_abilities_api_categories_init', '_unhook_core_ability_categories_registration', 1 );
+               add_action( 'wp_abilities_api_init', '_unhook_core_abilities_registration', 1 );
+
+               // Remove the core abilities and their categories.
+               foreach ( wp_get_abilities() as $ability ) {
+                       wp_unregister_ability( $ability->get_name() );
+               }
+               foreach ( wp_get_ability_categories() as $ability_category ) {
+                       wp_unregister_ability_category( $ability_category->get_slug() );
+               }
+
+               parent::tear_down_after_class();
+       }
+
+       /**
+        * Tests that the `core/get-site-info` ability is registered with the expected schema.
+        * @ticket 64146
+        */
+       public function test_core_get_site_info_ability_is_registered(): void {
+               $ability = wp_get_ability( 'core/get-site-info' );
+
+               $this->assertInstanceOf( WP_Ability::class, $ability );
+               $this->assertTrue( $ability->get_meta_item( 'show_in_rest', false ) );
+
+               $input_schema  = $ability->get_input_schema();
+               $output_schema = $ability->get_output_schema();
+
+               $this->assertSame( 'object', $input_schema['type'] );
+               $this->assertArrayHasKey( 'default', $input_schema );
+               $this->assertSame( array(), $input_schema['default'] );
+
+               // Input schema should have optional fields array.
+               $this->assertArrayHasKey( 'fields', $input_schema['properties'] );
+               $this->assertSame( 'array', $input_schema['properties']['fields']['type'] );
+               $this->assertContains( 'name', $input_schema['properties']['fields']['items']['enum'] );
+
+               // Output schema should have all fields documented.
+               $this->assertArrayHasKey( 'name', $output_schema['properties'] );
+               $this->assertArrayHasKey( 'url', $output_schema['properties'] );
+               $this->assertArrayHasKey( 'version', $output_schema['properties'] );
+       }
+
+       /**
+        * Tests executing the `core/get-site-info` ability returns all fields by default.
+        * @ticket 64146
+        */
+       public function test_core_get_site_info_executes(): void {
+               // Requires manage_options.
+               $admin_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
+               wp_set_current_user( $admin_id );
+
+               $ability = wp_get_ability( 'core/get-site-info' );
+
+               // Test without fields parameter - should return all fields.
+               $result = $ability->execute();
+
+               $this->assertIsArray( $result );
+               $this->assertArrayHasKey( 'name', $result );
+               $this->assertArrayHasKey( 'description', $result );
+               $this->assertArrayHasKey( 'url', $result );
+               $this->assertArrayHasKey( 'version', $result );
+               $this->assertSame( get_bloginfo( 'name' ), $result['name'] );
+
+               // Test with fields parameter - should return only requested fields.
+               $result = $ability->execute(
+                       array(
+                               'fields' => array( 'name', 'url' ),
+                       )
+               );
+
+               $this->assertIsArray( $result );
+               $this->assertCount( 2, $result );
+               $this->assertSame( get_bloginfo( 'name' ), $result['name'] );
+               $this->assertSame( get_bloginfo( 'url' ), $result['url'] );
+       }
+
+       /**
+        * Tests that executing the current user info ability requires authentication.
+        * @ticket 64146
+        */
+       public function test_core_get_current_user_info_requires_authentication(): void {
+               $ability = wp_get_ability( 'core/get-user-info' );
+
+               $this->assertFalse( $ability->check_permissions() );
+
+               $result = $ability->execute();
+               $this->assertWPError( $result );
+               $this->assertSame( 'ability_invalid_permissions', $result->get_error_code() );
+       }
+
+       /**
+        * Tests executing the current user info ability as an authenticated user.
+        * @ticket 64146
+        */
+       public function test_core_get_current_user_info_returns_user_data(): void {
+               $user_id = self::factory()->user->create(
+                       array(
+                               'role'   => 'subscriber',
+                               'locale' => 'fr_FR',
+                       )
+               );
+
+               wp_set_current_user( $user_id );
+
+               $ability = wp_get_ability( 'core/get-user-info' );
+
+               $this->assertTrue( $ability->check_permissions() );
+
+               $result = $ability->execute();
+               $this->assertSame( $user_id, $result['id'] );
+               $this->assertSame( 'fr_FR', $result['locale'] );
+               $this->assertSame( 'subscriber', $result['roles'][0] );
+               $this->assertSame( get_userdata( $user_id )->display_name, $result['display_name'] );
+       }
+
+       /**
+        * Tests executing the environment info ability.
+        * @ticket 64146
+        */
+       public function test_core_get_environment_info_executes(): void {
+               // Requires manage_options.
+               $admin_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
+               wp_set_current_user( $admin_id );
+
+               $ability      = wp_get_ability( 'core/get-environment-info' );
+               $environment  = wp_get_environment_type();
+               $ability_data = $ability->execute();
+
+               $this->assertIsArray( $ability_data );
+               $this->assertArrayHasKey( 'environment', $ability_data );
+               $this->assertArrayHasKey( 'php_version', $ability_data );
+               $this->assertArrayHasKey( 'db_server_info', $ability_data );
+               $this->assertArrayHasKey( 'wp_version', $ability_data );
+               $this->assertSame( $environment, $ability_data['environment'] );
+       }
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/tests/phpunit/tests/abilities-api/wpRegisterCoreAbilities.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span></div>

</body>
</html>