Skip to content

Commit b2df385

Browse files
committed
FIX - Test to fake api reponse for unsplash
1 parent c4957ca commit b2df385

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

phpunit.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@
3232
<env name="TELEGRAM_CHANNEL" value="null"/>
3333
<env name="FATHOM_SITE_ID" value="1234"/>
3434
<env name="FATHOM_TOKEN" value="5678"/>
35+
<env name="UNSPLASH_ACCESS_KEY" value="abcde"/>
3536
</php>
3637
</phpunit>

tests/Integration/Commands/SyncArticleImagesTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,22 @@
33
use App\Console\Commands\SyncArticleImages;
44
use App\Models\Article;
55
use Illuminate\Foundation\Testing\DatabaseMigrations;
6+
use Illuminate\Support\Facades\Http;
67
use Tests\TestCase;
78

89
uses(TestCase::class);
910
uses(DatabaseMigrations::class);
1011

1112

1213
test('hero image url is updated for published articles with hero image', function () {
14+
Http::fake(function () {
15+
return [
16+
'urls' => [
17+
'raw' => 'https://images.unsplash.com/photo-1584824486509-112e4181ff6b?ixid=M3w2NTgwOTl8MHwxfGFsbHx8fHx8fHx8fDE3Mjc2ODMzMzZ8&ixlib=rb-4.0.3'
18+
]
19+
];
20+
});
21+
1322
$article = Article::factory()->create([
1423
'hero_image' => 'sxiSod0tyYQ',
1524
'submitted_at' => now(),

0 commit comments

Comments
 (0)