test: fix addItem assertion and add xml parseability check

This commit is contained in:
Joel Male
2026-04-11 08:19:20 +10:00
parent cb067ccb77
commit f618408877
+9 -1
View File
@@ -39,7 +39,7 @@ function validProduct(array $overrides = []): array
$feed = LaravelGoogleShoppingFeed::init('', '', '');
$feed->addItem(validProduct());
expect($feed)->toBeInstanceOf(LaravelGoogleShoppingFeed::class);
expect($feed->toXml())->toContain('prod-1');
});
it('throws for missing required field', function (string $field) {
@@ -145,6 +145,14 @@ function validProduct(array $overrides = []): array
$feed = LaravelGoogleShoppingFeed::init('', '', '');
expect($feed->toXml())->toStartWith('<?xml');
});
it('generates parseable xml', function () {
$feed = LaravelGoogleShoppingFeed::init('Store', 'Desc', 'https://example.com');
$feed->addItem(validProduct());
$result = simplexml_load_string($feed->toXml());
expect($result)->not->toBeFalse();
});
});
describe('generate', function () {