- Timestamp:
- 03/12/2026 07:54:50 AM (7 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/connectors/wpConnectorsGetConnectorSettings.php
r61943 r61983 4 4 5 5 /** 6 * Tests for _wp_connectors_get_connector_settings().6 * Tests for wp_get_connectors(). 7 7 * 8 8 * @group connectors 9 * @covers :: _wp_connectors_get_connector_settings9 * @covers ::wp_get_connectors 10 10 */ 11 class Tests_Connectors_Wp ConnectorsGetConnectorSettings extends WP_UnitTestCase {11 class Tests_Connectors_WpGetConnectors extends WP_UnitTestCase { 12 12 13 13 use WP_AI_Client_Mock_Provider_Trait; … … 16 16 * Registers the mock provider once before any tests in this class run. 17 17 */ 18 public static function set_up_before_class() {18 public static function set_up_before_class(): void { 19 19 parent::set_up_before_class(); 20 20 self::register_mock_connectors_provider(); … … 24 24 * Unregisters the mock provider setting added by `init`. 25 25 */ 26 public static function tear_down_after_class() {26 public static function tear_down_after_class(): void { 27 27 self::unregister_mock_connector_setting(); 28 28 parent::tear_down_after_class(); … … 32 32 * @ticket 64730 33 33 */ 34 public function test_returns_expected_connector_keys() {35 $connectors = _wp_connectors_get_connector_settings();34 public function test_returns_expected_connector_keys(): void { 35 $connectors = wp_get_connectors(); 36 36 37 37 $this->assertArrayHasKey( 'google', $connectors ); … … 45 45 * @ticket 64730 46 46 */ 47 public function test_each_connector_has_required_fields() {48 $connectors = _wp_connectors_get_connector_settings();47 public function test_each_connector_has_required_fields(): void { 48 $connectors = wp_get_connectors(); 49 49 50 50 $this->assertNotEmpty( $connectors, 'Connector settings should not be empty.' ); … … 68 68 * @ticket 64730 69 69 */ 70 public function test_api_key_connectors_have_setting_name_and_credentials_url() {71 $connectors = _wp_connectors_get_connector_settings();70 public function test_api_key_connectors_have_setting_name_and_credentials_url(): void { 71 $connectors = wp_get_connectors(); 72 72 $api_key_count = 0; 73 73 … … 82 82 $this->assertSame( 83 83 "connectors_ai_{$connector_id}_api_key", 84 $connector_data['authentication']['setting_name'] ,84 $connector_data['authentication']['setting_name'] ?? null, 85 85 "Connector '{$connector_id}' setting_name does not match expected format." 86 86 ); 87 $this->assertArrayHasKey( 'credentials_url', $connector_data['authentication'], "Connector '{$connector_id}' authentication is missing 'credentials_url'." );88 87 } 89 88 … … 94 93 * @ticket 64730 95 94 */ 96 public function test_featured_provider_names_match_expected() {97 $connectors = _wp_connectors_get_connector_settings();95 public function test_featured_provider_names_match_expected(): void { 96 $connectors = wp_get_connectors(); 98 97 99 98 $this->assertSame( 'Google', $connectors['google']['name'] ); … … 105 104 * @ticket 64730 106 105 */ 107 public function test_includes_registered_provider_from_registry() {108 $connectors = _wp_connectors_get_connector_settings();106 public function test_includes_registered_provider_from_registry(): void { 107 $connectors = wp_get_connectors(); 109 108 $mock = $connectors['mock_connectors_test']; 110 109 … … 113 112 $this->assertSame( 'ai_provider', $mock['type'] ); 114 113 $this->assertSame( 'api_key', $mock['authentication']['method'] ); 115 $this->assertNull( $mock['authentication']['credentials_url'] ); 116 $this->assertSame( 'connectors_ai_mock_connectors_test_api_key', $mock['authentication']['setting_name'] ); 117 } 118 119 /** 120 * @ticket 64730 121 */ 122 public function test_connectors_are_sorted_alphabetically() { 123 $connectors = _wp_connectors_get_connector_settings(); 124 $keys = array_keys( $connectors ); 125 $sorted = $keys; 126 sort( $sorted ); 127 128 $this->assertSame( $sorted, $keys, 'Connectors should be sorted alphabetically by ID.' ); 114 $this->assertNull( $mock['authentication']['credentials_url'] ?? null ); 115 $this->assertSame( 'connectors_ai_mock_connectors_test_api_key', $mock['authentication']['setting_name'] ?? null ); 129 116 } 130 117 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)