Skip to content

Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.

test(automations): extract inline feed XML into shared fixtures

Paulo Castellano3acaafb81e41
diff --git a/tests/Feature/Automation/FeedInspectionTest.php b/tests/Feature/Automation/FeedInspectionTest.php
index 7d31baedb..c5ab6d003 100644
--- a/tests/Feature/Automation/FeedInspectionTest.php
+++ b/tests/Feature/Automation/FeedInspectionTest.php
@@ -16,7 +16,7 @@ beforeEach(function () {
});
it('returns the discovered fields for a feed', function () {
- Http::fake(['1.1.1.1/*' => Http::response(file_get_contents(base_path('tests/fixtures/feeds/youtube_atom.xml')), 200)]);
+ Http::fake(['1.1.1.1/*' => Http::response(feedFixture('youtube_atom'), 200)]);
$automation = Automation::factory()->for($this->workspace)->create();
@@ -35,7 +35,7 @@ it('returns the discovered fields for a feed', function () {
});
it('resolves workspace variables in the feed url before fetching', function () {
- Http::fake(['1.1.1.1/*' => Http::response(file_get_contents(base_path('tests/fixtures/feeds/youtube_atom.xml')), 200)]);
+ Http::fake(['1.1.1.1/*' => Http::response(feedFixture('youtube_atom'), 200)]);
$automation = Automation::factory()->for($this->workspace)->create([
'variables' => [['key' => 'HOST', 'value' => '1.1.1.1']],
diff --git a/tests/Feature/Automation/Node/FetchRssNodeTest.php b/tests/Feature/Automation/Node/FetchRssNodeTest.php
index f915098e3..dc83b8e30 100644
--- a/tests/Feature/Automation/Node/FetchRssNodeTest.php
+++ b/tests/Feature/Automation/Node/FetchRssNodeTest.php
@@ -15,37 +15,11 @@ use Illuminate\Support\Facades\Http;
afterEach(fn () => Carbon::setTestNow());
-const FETCH_RSS_OLD = <<<'XML'
-<?xml version="1.0" encoding="UTF-8"?>
-<rss version="2.0"><channel>
- <item><title>Ancient</title><link>https://1.1.1.1/1</link><guid>1</guid><pubDate>Mon, 01 Jan 2024 12:00:00 +0000</pubDate></item>
- <item><title>Old</title><link>https://1.1.1.1/2</link><guid>2</guid><pubDate>Sat, 01 Feb 2025 12:00:00 +0000</pubDate></item>
-</channel></rss>
-XML;
-
-const FETCH_RSS_MIXED = <<<'XML'
-<?xml version="1.0" encoding="UTF-8"?>
-<rss version="2.0"><channel>
- <item><title>Older</title><link>https://1.1.1.1/a</link><guid>a</guid><pubDate>Sat, 01 Feb 2025 12:00:00 +0000</pubDate></item>
- <item><title>Newer1</title><link>https://1.1.1.1/b</link><guid>b</guid><pubDate>Sun, 01 Jun 2025 12:00:00 +0000</pubDate></item>
- <item><title>Newer2</title><link>https://1.1.1.1/c</link><guid>c</guid><pubDate>Sun, 15 Jun 2025 12:00:00 +0000</pubDate></item>
-</channel></rss>
-XML;
-
-const FETCH_RSS_THREE_NEW = <<<'XML'
-<?xml version="1.0" encoding="UTF-8"?>
-<rss version="2.0"><channel>
- <item><title>New1</title><link>https://1.1.1.1/x</link><guid>x</guid><pubDate>Sun, 01 Jun 2025 12:00:00 +0000</pubDate></item>
- <item><title>New2</title><link>https://1.1.1.1/y</link><guid>y</guid><pubDate>Mon, 02 Jun 2025 12:00:00 +0000</pubDate></item>
- <item><title>New3</title><link>https://1.1.1.1/z</link><guid>z</guid><pubDate>Tue, 03 Jun 2025 12:00:00 +0000</pubDate></item>
-</channel></rss>
-XML;
-
beforeEach(fn () => Bus::fake());
it('first execution dispatches nothing and stores watermark from newest item', function () {
Carbon::setTestNow('2026-01-15 10:00:00');
- Http::fake(['1.1.1.1/*' => Http::response(FETCH_RSS_OLD, 200)]);
+ Http::fake(['1.1.1.1/*' => Http::response(feedFixture('rss_old'), 200)]);
$automation = Automation::factory()->active()->create([
'nodes' => [
@@ -74,7 +48,7 @@ it('first execution dispatches nothing and stores watermark from newest item', f
it('processes the first new item on the current run and spawns siblings for the rest', function () {
Carbon::setTestNow('2026-01-15 10:00:00');
- Http::fake(['1.1.1.1/*' => Http::response(FETCH_RSS_MIXED, 200)]);
+ Http::fake(['1.1.1.1/*' => Http::response(feedFixture('rss_mixed'), 200)]);
$automation = Automation::factory()->active()->create([
'nodes' => [
@@ -111,7 +85,7 @@ it('processes the first new item on the current run and spawns siblings for the
it('spawns sibling runs down the item edge for each remaining new item', function () {
Carbon::setTestNow('2026-01-15 10:00:00');
- Http::fake(['1.1.1.1/*' => Http::response(FETCH_RSS_THREE_NEW, 200)]);
+ Http::fake(['1.1.1.1/*' => Http::response(feedFixture('rss_three_new'), 200)]);
$automation = Automation::factory()->active()->create([
'nodes' => [
@@ -151,7 +125,7 @@ it('spawns sibling runs down the item edge for each remaining new item', functio
it('fans every spawned item out across all branches wired to the fetch node', function () {
Carbon::setTestNow('2026-01-15 10:00:00');
- Http::fake(['1.1.1.1/*' => Http::response(FETCH_RSS_THREE_NEW, 200)]);
+ Http::fake(['1.1.1.1/*' => Http::response(feedFixture('rss_three_new'), 200)]);
$automation = Automation::factory()->active()->create([
'nodes' => [
@@ -185,7 +159,7 @@ it('fans every spawned item out across all branches wired to the fetch node', fu
it('does not persist the production watermark on a manual real-data test', function () {
Carbon::setTestNow('2026-01-15 10:00:00');
- Http::fake(['1.1.1.1/*' => Http::response(FETCH_RSS_MIXED, 200)]);
+ Http::fake(['1.1.1.1/*' => Http::response(feedFixture('rss_mixed'), 200)]);
$automation = Automation::factory()->active()->create([
'nodes' => [
@@ -226,7 +200,7 @@ it('does not persist the production watermark on a manual real-data test', funct
it('advances the production watermark on a non-manual real-data run', function () {
Carbon::setTestNow('2026-01-15 10:00:00');
- Http::fake(['1.1.1.1/*' => Http::response(FETCH_RSS_MIXED, 200)]);
+ Http::fake(['1.1.1.1/*' => Http::response(feedFixture('rss_mixed'), 200)]);
$automation = Automation::factory()->active()->create([
'nodes' => [
@@ -261,7 +235,7 @@ it('advances the production watermark on a non-manual real-data run', function (
it('processes an Atom feed (YouTube) that the old RSS-only parser dropped', function () {
Carbon::setTestNow('2026-06-16 10:00:00');
- Http::fake(['1.1.1.1/*' => Http::response(file_get_contents(base_path('tests/fixtures/feeds/youtube_atom.xml')), 200)]);
+ Http::fake(['1.1.1.1/*' => Http::response(feedFixture('youtube_atom'), 200)]);
$automation = Automation::factory()->active()->create();
@@ -317,14 +291,7 @@ it('fails on a malformed RSS feed', function () {
it('skips items without a publish date', function () {
Carbon::setTestNow('2026-01-15 10:00:00');
- $feed = <<<'XML'
- <?xml version="1.0" encoding="UTF-8"?>
- <rss version="2.0"><channel>
- <item><title>Dated</title><link>https://1.1.1.1/d</link><guid>d</guid><pubDate>Sun, 01 Jun 2025 12:00:00 +0000</pubDate></item>
- <item><title>NoDate</title><link>https://1.1.1.1/n</link><guid>n</guid></item>
- </channel></rss>
- XML;
- Http::fake(['1.1.1.1/*' => Http::response($feed, 200)]);
+ Http::fake(['1.1.1.1/*' => Http::response(feedFixture('rss_dateless'), 200)]);
$automation = Automation::factory()->active()->create();
AutomationNodeState::create([
@@ -343,13 +310,7 @@ it('skips items without a publish date', function () {
it('falls back to the link as the dedup key when an item has no guid', function () {
Carbon::setTestNow('2026-01-15 10:00:00');
- $feed = <<<'XML'
- <?xml version="1.0" encoding="UTF-8"?>
- <rss version="2.0"><channel>
- <item><title>LinkKey</title><link>https://1.1.1.1/only-link</link><pubDate>Sun, 01 Jun 2025 12:00:00 +0000</pubDate></item>
- </channel></rss>
- XML;
- Http::fake(['1.1.1.1/*' => Http::response($feed, 200)]);
+ Http::fake(['1.1.1.1/*' => Http::response(feedFixture('rss_no_guid'), 200)]);
$automation = Automation::factory()->active()->create();
AutomationNodeState::create([
diff --git a/tests/Pest.php b/tests/Pest.php
index 373a3c944..523a16059 100644
--- a/tests/Pest.php
+++ b/tests/Pest.php
@@ -103,3 +103,8 @@ function createApiTestToken(array $overrides = []): array
'user' => $user,
];
}
+
+function feedFixture(string $name): string
+{
+ return file_get_contents(base_path("tests/fixtures/feeds/{$name}.xml"));
+}
diff --git a/tests/Unit/Automation/FeedParserTest.php b/tests/Unit/Automation/FeedParserTest.php
index d12e948d2..cda1a74b5 100644
--- a/tests/Unit/Automation/FeedParserTest.php
+++ b/tests/Unit/Automation/FeedParserTest.php
@@ -4,11 +4,6 @@ declare(strict_types=1);
use App\Services\Automation\FeedParser;
-function feedFixture(string $name): string
-{
- return file_get_contents(base_path("tests/fixtures/feeds/{$name}.xml"));
-}
-
beforeEach(function () {
$this->parser = new FeedParser;
});
diff --git a/tests/fixtures/feeds/rss_dateless.xml b/tests/fixtures/feeds/rss_dateless.xml
new file mode 100644
index 000000000..354740d33
--- /dev/null
+++ b/tests/fixtures/feeds/rss_dateless.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<rss version="2.0"><channel>
+ <item><title>Dated</title><link>https://1.1.1.1/d</link><guid>d</guid><pubDate>Sun, 01 Jun 2025 12:00:00 +0000</pubDate></item>
+ <item><title>NoDate</title><link>https://1.1.1.1/n</link><guid>n</guid></item>
+</channel></rss>
diff --git a/tests/fixtures/feeds/rss_mixed.xml b/tests/fixtures/feeds/rss_mixed.xml
new file mode 100644
index 000000000..e0ff0f35d
--- /dev/null
+++ b/tests/fixtures/feeds/rss_mixed.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<rss version="2.0"><channel>
+ <item><title>Older</title><link>https://1.1.1.1/a</link><guid>a</guid><pubDate>Sat, 01 Feb 2025 12:00:00 +0000</pubDate></item>
+ <item><title>Newer1</title><link>https://1.1.1.1/b</link><guid>b</guid><pubDate>Sun, 01 Jun 2025 12:00:00 +0000</pubDate></item>
+ <item><title>Newer2</title><link>https://1.1.1.1/c</link><guid>c</guid><pubDate>Sun, 15 Jun 2025 12:00:00 +0000</pubDate></item>
+</channel></rss>
diff --git a/tests/fixtures/feeds/rss_no_guid.xml b/tests/fixtures/feeds/rss_no_guid.xml
new file mode 100644
index 000000000..50da87edf
--- /dev/null
+++ b/tests/fixtures/feeds/rss_no_guid.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<rss version="2.0"><channel>
+ <item><title>LinkKey</title><link>https://1.1.1.1/only-link</link><pubDate>Sun, 01 Jun 2025 12:00:00 +0000</pubDate></item>
+</channel></rss>
diff --git a/tests/fixtures/feeds/rss_old.xml b/tests/fixtures/feeds/rss_old.xml
new file mode 100644
index 000000000..897423854
--- /dev/null
+++ b/tests/fixtures/feeds/rss_old.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<rss version="2.0"><channel>
+ <item><title>Ancient</title><link>https://1.1.1.1/1</link><guid>1</guid><pubDate>Mon, 01 Jan 2024 12:00:00 +0000</pubDate></item>
+ <item><title>Old</title><link>https://1.1.1.1/2</link><guid>2</guid><pubDate>Sat, 01 Feb 2025 12:00:00 +0000</pubDate></item>
+</channel></rss>
diff --git a/tests/fixtures/feeds/rss_three_new.xml b/tests/fixtures/feeds/rss_three_new.xml
new file mode 100644
index 000000000..6d44e06df
--- /dev/null
+++ b/tests/fixtures/feeds/rss_three_new.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<rss version="2.0"><channel>
+ <item><title>New1</title><link>https://1.1.1.1/x</link><guid>x</guid><pubDate>Sun, 01 Jun 2025 12:00:00 +0000</pubDate></item>
+ <item><title>New2</title><link>https://1.1.1.1/y</link><guid>y</guid><pubDate>Mon, 02 Jun 2025 12:00:00 +0000</pubDate></item>
+ <item><title>New3</title><link>https://1.1.1.1/z</link><guid>z</guid><pubDate>Tue, 03 Jun 2025 12:00:00 +0000</pubDate></item>
+</channel></rss>