Skip to content

Commit 89532b0

Browse files
committed
WIP
1 parent 2752e04 commit 89532b0

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

app/Console/Commands/SyncArticleImages.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ public function handle(): void
4747

4848
protected function shouldBeSynced(Article $article): bool
4949
{
50-
if ($article->hero_image && ! $article->hasHeroImage()) {
50+
if (!$article->hero_image) {
51+
return false;
52+
}
53+
54+
if ($article->hero_image && $article->hasHeroImage()) {
5155
return false;
5256
}
5357

tests/Integration/Commands/SyncArticleImagesTest.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@
1010
uses(DatabaseMigrations::class);
1111

1212

13-
test('hero image url is updated for published articles with hero image', function () {
13+
test('hero image url and author information is updated for published articles with hero image', function () {
1414
Http::fake(function () {
1515
return [
1616
'urls' => [
1717
'raw' => 'https://images.unsplash.com/photo-1584824486509-112e4181ff6b?ixid=M3w2NTgwOTl8MHwxfGFsbHx8fHx8fHx8fDE3Mjc2ODMzMzZ8&ixlib=rb-4.0.3'
18-
]
18+
],
19+
'user' => [
20+
'name' => 'Erik Mclean',
21+
'links' => [
22+
'html' => 'https://unsplash.com/@introspectivedsgn',
23+
]
24+
],
1925
];
2026
});
2127

@@ -29,11 +35,12 @@
2935

3036
$article->refresh();
3137

32-
expect($article->heroImage())->toBeUrl();
3338
expect($article->heroImage())->toContain('https://images.unsplash.com/photo-1584824486509-112e4181ff6b');
39+
expect($article->hero_image_author_name)->toBe('Erik Mclean');
40+
expect($article->hero_image_author_url)->toBe('https://unsplash.com/@introspectivedsgn');
3441
});
3542

36-
test('hero image url is not updated for published articles with no hero image', function () {
43+
test('hero image url and author information is not updated for published articles with no hero image', function () {
3744
$article = Article::factory()->create([
3845
'submitted_at' => now(),
3946
'approved_at' => now(),
@@ -44,4 +51,6 @@
4451
$article->refresh();
4552

4653
expect($article->hero_image_url)->toBe(null);
47-
});
54+
expect($article->hero_image_author_name)->toBe(null);
55+
expect($article->hero_image_author_url)->toBe(null);
56+
})->only();

0 commit comments

Comments
 (0)