mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-03-14 12:23:33 +00:00
Use root element name for root of array rather than "rss"
This commit is contained in:
parent
afc29e15d5
commit
9c5b5b33f5
2 changed files with 11 additions and 11 deletions
|
|
@ -23,7 +23,7 @@ class XmlResponseParser implements ResponseParser
|
||||||
throw new Exception('Invalid XML content');
|
throw new Exception('Invalid XML content');
|
||||||
}
|
}
|
||||||
|
|
||||||
return ['rss' => $this->xmlToArray($xml)];
|
return [$xml->getName() => $this->xmlToArray($xml)];
|
||||||
} catch (Exception $exception) {
|
} catch (Exception $exception) {
|
||||||
Log::warning('Failed to parse XML response: '.$exception->getMessage());
|
Log::warning('Failed to parse XML response: '.$exception->getMessage());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -95,9 +95,9 @@ test('plugin parses namespaces XML responses and wraps under root key', function
|
||||||
|
|
||||||
$plugin->refresh();
|
$plugin->refresh();
|
||||||
|
|
||||||
expect($plugin->data_payload)->toHaveKey('rss');
|
expect($plugin->data_payload)->toHaveKey('cake');
|
||||||
expect($plugin->data_payload['rss'])->toHaveKey('icing');
|
expect($plugin->data_payload['cake'])->toHaveKey('icing');
|
||||||
expect($plugin->data_payload['rss']['icing']['ontop'])->toBe('Cherry');
|
expect($plugin->data_payload['cake']['icing']['ontop'])->toBe('Cherry');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('plugin parses JSON-parsable response body as JSON', function (): void {
|
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);
|
expect($plugin->data_payload['IDX_0'])->toBe($jsonResponse);
|
||||||
|
|
||||||
// Second URL should be XML wrapped under rss
|
// Second URL should be XML wrapped under rss
|
||||||
expect($plugin->data_payload['IDX_1'])->toHaveKey('rss');
|
expect($plugin->data_payload['IDX_1'])->toHaveKey('root');
|
||||||
expect($plugin->data_payload['IDX_1']['rss']['item'])->toBe('XML Data');
|
expect($plugin->data_payload['IDX_1']['root']['item'])->toBe('XML Data');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('plugin handles POST requests with XML responses', function (): void {
|
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();
|
$plugin->refresh();
|
||||||
|
|
||||||
expect($plugin->data_payload)->toHaveKey('rss');
|
expect($plugin->data_payload)->toHaveKey('response');
|
||||||
expect($plugin->data_payload['rss'])->toHaveKey('status');
|
expect($plugin->data_payload['response'])->toHaveKey('status');
|
||||||
expect($plugin->data_payload['rss'])->toHaveKey('data');
|
expect($plugin->data_payload['response'])->toHaveKey('data');
|
||||||
expect($plugin->data_payload['rss']['status'])->toBe('success');
|
expect($plugin->data_payload['response']['status'])->toBe('success');
|
||||||
expect($plugin->data_payload['rss']['data'])->toBe('test');
|
expect($plugin->data_payload['response']['data'])->toBe('test');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('plugin parses iCal responses and filters to recent window', function (): void {
|
test('plugin parses iCal responses and filters to recent window', function (): void {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue