From b78daed55007fe9dcf8984e8bf75ba565a18d8ee Mon Sep 17 00:00:00 2001 From: Jamie Shiell Date: Sun, 8 Feb 2026 16:47:09 +0000 Subject: [PATCH] Use root element name for root of array rather than "rss" --- .../Plugin/Parsers/XmlResponseParser.php | 2 +- tests/Feature/PluginResponseTest.php | 20 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/Services/Plugin/Parsers/XmlResponseParser.php b/app/Services/Plugin/Parsers/XmlResponseParser.php index 037b3c6..6556de8 100644 --- a/app/Services/Plugin/Parsers/XmlResponseParser.php +++ b/app/Services/Plugin/Parsers/XmlResponseParser.php @@ -23,7 +23,7 @@ class XmlResponseParser implements ResponseParser throw new Exception('Invalid XML content'); } - return ['rss' => $this->xmlToArray($xml)]; + return [$xml->getName() => $this->xmlToArray($xml)]; } catch (Exception $exception) { Log::warning('Failed to parse XML response: '.$exception->getMessage()); diff --git a/tests/Feature/PluginResponseTest.php b/tests/Feature/PluginResponseTest.php index bcc06f8..3d82b6b 100644 --- a/tests/Feature/PluginResponseTest.php +++ b/tests/Feature/PluginResponseTest.php @@ -95,9 +95,9 @@ test('plugin parses namespaces XML responses and wraps under root key', function $plugin->refresh(); - expect($plugin->data_payload)->toHaveKey('rss'); - expect($plugin->data_payload['rss'])->toHaveKey('icing'); - expect($plugin->data_payload['rss']['icing']['ontop'])->toBe('Cherry'); + expect($plugin->data_payload)->toHaveKey('cake'); + expect($plugin->data_payload['cake'])->toHaveKey('icing'); + expect($plugin->data_payload['cake']['icing']['ontop'])->toBe('Cherry'); }); test('plugin parses JSON-parsable response body as JSON', function (): void { @@ -191,8 +191,8 @@ test('plugin handles multiple URLs with mixed content types', function (): void expect($plugin->data_payload['IDX_0'])->toBe($jsonResponse); // Second URL should be XML wrapped under rss - expect($plugin->data_payload['IDX_1'])->toHaveKey('rss'); - expect($plugin->data_payload['IDX_1']['rss']['item'])->toBe('XML Data'); + expect($plugin->data_payload['IDX_1'])->toHaveKey('root'); + expect($plugin->data_payload['IDX_1']['root']['item'])->toBe('XML Data'); }); test('plugin handles POST requests with XML responses', function (): void { @@ -213,11 +213,11 @@ test('plugin handles POST requests with XML responses', function (): void { $plugin->refresh(); - expect($plugin->data_payload)->toHaveKey('rss'); - expect($plugin->data_payload['rss'])->toHaveKey('status'); - expect($plugin->data_payload['rss'])->toHaveKey('data'); - expect($plugin->data_payload['rss']['status'])->toBe('success'); - expect($plugin->data_payload['rss']['data'])->toBe('test'); + expect($plugin->data_payload)->toHaveKey('response'); + expect($plugin->data_payload['response'])->toHaveKey('status'); + expect($plugin->data_payload['response'])->toHaveKey('data'); + expect($plugin->data_payload['response']['status'])->toBe('success'); + expect($plugin->data_payload['response']['data'])->toBe('test'); }); test('plugin parses iCal responses and filters to recent window', function (): void {