This repository was archived by the owner on Jun 29, 2021. It is now read-only.
File tree 3 files changed +10
-4
lines changed
3 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ public function __invoke(LinkStoreRequest $request): Response
23
23
'description ' => $ request ->input ('description ' ),
24
24
'author_name ' => $ request ->input ('author_name ' ),
25
25
'author_email ' => $ request ->input ('author_email ' ),
26
- 'cover_image ' => $ request ->file ('cover_image ' )->getClientOriginalName ( ),
26
+ 'cover_image ' => $ request ->file ('cover_image ' )->store ( ' cover_images ' ),
27
27
]);
28
28
29
29
$ link ->tags ()->attach ($ request ->input ('tags.*.id ' ));
Original file line number Diff line number Diff line change 2
2
3
3
use Domains \Links \Models \Link ;
4
4
use Illuminate \Database \Eloquent \Factory ;
5
+ use Illuminate \Http \UploadedFile ;
5
6
use Illuminate \Support \Carbon ;
6
7
7
- /** @var $factory Factory */
8
+ /** @var Factory $factory */
8
9
$ factory ->define (Link::class, static fn (\Faker \Generator $ faker ) => [
9
10
'link ' => $ faker ->url ,
10
11
'description ' => $ faker ->paragraph ,
11
- 'cover_image ' => $ faker ->image (),
12
+ 'cover_image ' => ' cover_images/ ' . UploadedFile:: fake () ->image ( ' cover_image ' )-> getFilename (),
12
13
'author_name ' => $ faker ->name ,
13
14
'author_email ' => $ faker ->safeEmail ,
14
15
'created_at ' => Carbon::now (),
Original file line number Diff line number Diff line change 6
6
use Illuminate \Foundation \Testing \RefreshDatabase ;
7
7
use Illuminate \Foundation \Testing \WithFaker ;
8
8
use Illuminate \Http \UploadedFile ;
9
+ use Illuminate \Support \Facades \Storage ;
9
10
use Tests \TestCase ;
10
11
11
12
class LinksStoreTest extends TestCase
@@ -25,6 +26,8 @@ protected function setUp(): void
25
26
/** @test */
26
27
public function it_stores_resources (): void
27
28
{
29
+ Storage::fake ();
30
+
28
31
$ payload = [
29
32
'link ' => $ this ->faker ->url ,
30
33
'description ' => $ this ->faker ->paragraph ,
@@ -44,7 +47,7 @@ public function it_stores_resources(): void
44
47
'description ' => $ payload ['description ' ],
45
48
'author_name ' => $ payload ['author_name ' ],
46
49
'author_email ' => $ payload ['author_email ' ],
47
- 'cover_image ' => 'cover_image.jpg ' ,
50
+ 'cover_image ' => 'cover_images/ ' . $ payload [ ' cover_image ' ]-> hashName () ,
48
51
'approved_at ' => null ,
49
52
]);
50
53
@@ -54,6 +57,8 @@ public function it_stores_resources(): void
54
57
'tag_id ' => $ this ->tag ->id ,
55
58
]
56
59
);
60
+
61
+ Storage::assertExists ('cover_images/ ' . $ payload ['cover_image ' ]->hashName ());
57
62
}
58
63
59
64
/** @test */
You can’t perform that action at this time.
0 commit comments