create($this->faker->word().'.ogg', $this->faker->randomDigitNotNull()); $action = new UploadAudioAction($file, $this->faker->word()); $storageResults = $action->handle(); $result = $storageResults->toActionResult(); static::assertTrue($result->hasFailed()); } /** * The Upload Audio Action shall pass if given a valid file. * * @return void */ public function testPassed(): void { Storage::fake(Config::get(AudioConstants::DEFAULT_DISK_QUALIFIED)); Config::set(AudioConstants::DISKS_QUALIFIED, [Config::get(AudioConstants::DEFAULT_DISK_QUALIFIED)]); $file = File::fake()->create($this->faker->word().'.ogg', $this->faker->randomDigitNotNull()); $action = new UploadAudioAction($file, $this->faker->word()); $storageResults = $action->handle(); $result = $storageResults->toActionResult(); static::assertTrue(ActionStatus::PASSED === $result->getStatus()); } /** * The Upload Audio Action shall upload the file to the configured disk. * * @return void */ public function testUploadedToDisk(): void { Storage::fake(Config::get(AudioConstants::DEFAULT_DISK_QUALIFIED)); Config::set(AudioConstants::DISKS_QUALIFIED, [Config::get(AudioConstants::DEFAULT_DISK_QUALIFIED)]); $file = File::fake()->create($this->faker->word().'.ogg', $this->faker->randomDigitNotNull()); $action = new UploadAudioAction($file, $this->faker->word()); $action->handle(); static::assertCount(1, Storage::disk(Config::get(AudioConstants::DEFAULT_DISK_QUALIFIED))->allFiles()); } /** * The Upload Audio Action shall upload the file to the configured disk. * * @return void */ public function testCreatedAudio(): void { Storage::fake(Config::get(AudioConstants::DEFAULT_DISK_QUALIFIED)); Config::set(AudioConstants::DISKS_QUALIFIED, [Config::get(AudioConstants::DEFAULT_DISK_QUALIFIED)]); $file = File::fake()->create($this->faker->word().'.ogg', $this->faker->randomDigitNotNull()); $action = new UploadAudioAction($file, $this->faker->word()); $result = $action->handle(); $action->then($result); static::assertDatabaseCount(Audio::class, 1); } }