Hello community something is not working with my testing procedure in laravel.
I am trying to test video uploading.
The functionality works flawlessly but I still want to write a test for it (but it will not pass)
MY TEST:
public function can_upload_video()
{
$sizeInKilobytes = 100000;
$file = UploadedFile::fake()->create(
'video.mp4', $sizeInKilobytes, 'mp4'
);
Storage::fake('videos_disk');
$this->actingAs(User::factory()->create());
Livewire::test(Create::class)
->set('title', 'foo')
->set('video', $file)
->call('upload');
dd(Storage::disk('videos_disk')->allFiles());
}
MY LIVEWIRE CONTROLLER:
<?php
class Create extends Component
{
use WithFileUploads;
use DispatchesJobs;
public $video;
public $title,
public function upload()
{
$this->validate([
'title' => 'required',
'video' => 'max:1000000|required|file|mimetypes:video/mp4,video/mpeg,video/x-matroska',
]);
$video = Video::create([
'disk' => 'videos_disk',
'original_name' => $this->video->getClientOriginalName(),
'path' => $this->video->store('/', 'videos_disk'),
'streaming_path'=> null,
'title' => $this->title,
]);
$this->dispatch(new ConvertVideoForStreaming($video));
}
}
When I run the test it gives me an empty array.
Normally I expect that the test would give me an array containing the video stored in the upload method under the videos_disk.
related to: