- Introduced a new Site Metadata endpoint (`GET /wp-json/igny8/v1/site-metadata/`) for retrieving available post types and taxonomies, including counts. - Added API key input in the admin settings for authentication, with secure storage and revocation functionality. - Implemented a toggle for enabling/disabling two-way sync operations. - Updated documentation to reflect new features and usage examples. - Enhanced permission checks for REST API calls to ensure secure access.
37 lines
1.2 KiB
PHP
37 lines
1.2 KiB
PHP
<?php
|
|
/**
|
|
* Basic unit test for site-metadata endpoint
|
|
*
|
|
* @package Igny8Bridge
|
|
*/
|
|
|
|
class Test_Site_Metadata_Endpoint extends WP_UnitTestCase {
|
|
|
|
public function test_site_metadata_endpoint_returns_success() {
|
|
// Ensure connection enabled
|
|
update_option('igny8_connection_enabled', 1);
|
|
|
|
// Create a fake API key so permission checks pass via Igny8API
|
|
update_option('igny8_api_key', 'test-api-key-123');
|
|
update_option('igny8_access_token', 'test-api-key-123');
|
|
|
|
// Build request
|
|
$request = new WP_REST_Request('GET', '/igny8/v1/site-metadata/');
|
|
$request->set_header('Authorization', 'Bearer test-api-key-123');
|
|
|
|
$server = rest_get_server();
|
|
$response = $server->dispatch($request);
|
|
|
|
$this->assertEquals(200, $response->get_status());
|
|
$data = $response->get_data();
|
|
$this->assertNotEmpty($data);
|
|
$this->assertArrayHasKey('success', $data);
|
|
$this->assertTrue($data['success']);
|
|
$this->assertArrayHasKey('data', $data);
|
|
$this->assertArrayHasKey('post_types', $data['data']);
|
|
$this->assertArrayHasKey('taxonomies', $data['data']);
|
|
}
|
|
}
|
|
|
|
|