116 - Pin the premise that a fully-known feed still returns articles
This commit is contained in:
parent
548a55af05
commit
2f86326d5c
1 changed files with 28 additions and 0 deletions
|
|
@ -106,6 +106,34 @@ public function test_get_articles_from_rss_feed_does_not_duplicate_existing(): v
|
||||||
$this->assertEquals(1, Article::where('url', 'https://www.theguardian.com/world/2026/mar/08/first-article')->count());
|
$this->assertEquals(1, Article::where('url', 'https://www.theguardian.com/world/2026/mar/08/first-article')->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_get_articles_from_rss_feed_returns_known_articles_when_none_are_new(): void
|
||||||
|
{
|
||||||
|
Http::fake(['*' => Http::response($this->sampleRss, 200)]);
|
||||||
|
|
||||||
|
$feed = Feed::factory()->create([
|
||||||
|
'type' => 'rss',
|
||||||
|
'provider' => 'guardian',
|
||||||
|
'url' => 'https://www.theguardian.com/international/rss',
|
||||||
|
]);
|
||||||
|
|
||||||
|
Article::factory()->create([
|
||||||
|
'url' => 'https://www.theguardian.com/world/2026/mar/08/first-article',
|
||||||
|
'feed_id' => $feed->id,
|
||||||
|
]);
|
||||||
|
Article::factory()->create([
|
||||||
|
'url' => 'https://www.theguardian.com/world/2026/mar/08/second-article',
|
||||||
|
'feed_id' => $feed->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$countBeforeFetch = Article::count();
|
||||||
|
|
||||||
|
$fetcher = $this->createArticleFetcher();
|
||||||
|
$result = $fetcher->getArticlesFromFeed($feed);
|
||||||
|
|
||||||
|
$this->assertCount(2, $result);
|
||||||
|
$this->assertSame($countBeforeFetch, Article::count());
|
||||||
|
}
|
||||||
|
|
||||||
public function test_get_articles_from_rss_feed_handles_invalid_xml(): void
|
public function test_get_articles_from_rss_feed_handles_invalid_xml(): void
|
||||||
{
|
{
|
||||||
Http::fake(['*' => Http::response('this is not xml', 200)]);
|
Http::fake(['*' => Http::response('this is not xml', 200)]);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue