rest = new WPDO_HivePress_REST(); } public function test_namespace_constant(): void { $this->assertSame( 'wpdo/v1', WPDO_HivePress_REST::NAMESPACE ); } public function test_register_routes_does_not_throw(): void { // register_rest_route is stubbed in tests/bootstrap.php → returns true. $this->rest->register_routes(); $this->assertTrue( true ); } public function test_check_permission_returns_true_for_admin(): void { $this->assertTrue( $this->rest->check_permission() ); } public function test_check_permission_returns_error_for_non_admin(): void { $GLOBALS['_wp_current_user_can']['manage_options'] = false; $result = $this->rest->check_permission(); $this->assertInstanceOf( WP_Error::class, $result ); } public function test_get_status_returns_addon_catalog(): void { $response = $this->rest->get_status(); $this->assertInstanceOf( WP_REST_Response::class, $response ); $data = $response->get_data(); $this->assertArrayHasKey( 'addons', $data ); $this->assertArrayHasKey( 'conflicts', $data ); $this->assertArrayHasKey( 'totals', $data ); // Catalog should list all 13 known addons regardless of detection state. $this->assertSame( 13, $data['totals']['catalog'] ); // Without HivePress installed, detected = 0. $this->assertSame( 0, $data['totals']['detected'] ); } public function test_get_score_returns_report_structure(): void { $response = $this->rest->get_score(); $this->assertInstanceOf( WP_REST_Response::class, $response ); $data = $response->get_data(); $this->assertArrayHasKey( 'aggregate', $data ); $this->assertArrayHasKey( 'adapter_count', $data ); $this->assertArrayHasKey( 'per_dimension', $data ); $this->assertArrayHasKey( 'adapters', $data ); } public function test_get_health_returns_ok_when_no_adapters_active(): void { $response = $this->rest->get_health(); $this->assertInstanceOf( WP_REST_Response::class, $response ); $data = $response->get_data(); $this->assertArrayHasKey( 'ok', $data ); $this->assertArrayHasKey( 'probes', $data ); // No active adapters → vacuously ok. $this->assertTrue( $data['ok'] ); $this->assertSame( array(), $data['probes'] ); } }