File tree Expand file tree Collapse file tree 2 files changed +42
-1
lines changed
tests/Integration/Commands Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ final class Article extends Model implements Feedable
45
45
'original_url ' ,
46
46
'slug ' ,
47
47
'hero_image ' ,
48
+ 'hero_image_url ' ,
48
49
'is_pinned ' ,
49
50
'view_count ' ,
50
51
'tweet_id ' ,
@@ -105,7 +106,7 @@ public function hasHeroImage(): bool
105
106
106
107
public function heroImage ($ width = 400 , $ height = 300 ): string
107
108
{
108
- if ($ this ->hero_image ) {
109
+ if ($ this ->hero_image_url ) {
109
110
return "{$ this ->hero_image_url }&fit=clip&w= {$ width }&h= {$ height }" ;
110
111
}
111
112
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use App \Console \Commands \SyncArticleImages ;
4
+ use App \Models \Article ;
5
+ use Illuminate \Foundation \Testing \DatabaseMigrations ;
6
+ use Tests \TestCase ;
7
+
8
+ uses (TestCase::class);
9
+ uses (DatabaseMigrations::class);
10
+
11
+
12
+ test ('hero image url is updated for published articles with hero image ' , function () {
13
+
14
+ $ article = Article::factory ()->create ([
15
+ 'hero_image ' => 'sxiSod0tyYQ ' ,
16
+ 'submitted_at ' => now (),
17
+ 'approved_at ' => now (),
18
+ ]);
19
+
20
+ (new SyncArticleImages )->handle ();
21
+
22
+ $ article ->refresh ();
23
+
24
+ expect ($ article ->heroImage ())->toBeUrl ();
25
+ expect ($ article ->heroImage ())->toContain ('https://images.unsplash.com/photo-1584824486509-112e4181ff6b ' );
26
+ });
27
+
28
+ test ('hero image url is not updated for published articles with no hero image ' , function () {
29
+
30
+ $ article = Article::factory ()->create ([
31
+ 'submitted_at ' => now (),
32
+ 'approved_at ' => now (),
33
+ ]);
34
+
35
+ (new SyncArticleImages )->handle ();
36
+
37
+ $ article ->refresh ();
38
+
39
+ expect ($ article ->hero_image_url )->toBe (null );
40
+ })->only ();
You can’t perform that action at this time.
0 commit comments