createOne(); $action = new DeleteScriptAction($script); $storageResults = $action->handle(); $result = $storageResults->toActionResult(); static::assertTrue($result->hasFailed()); } /** * The Delete Script Action shall pass if there are deletions. * * @return void */ public function testPassed(): void { Storage::fake(Config::get(VideoConstants::SCRIPT_DISK_QUALIFIED)); $file = File::fake()->create($this->faker->word().'.txt', $this->faker->randomDigitNotNull()); $script = VideoScript::factory()->createOne([ VideoScript::ATTRIBUTE_PATH => $file->path(), ]); $action = new DeleteScriptAction($script); $storageResults = $action->handle(); $result = $storageResults->toActionResult(); static::assertTrue(ActionStatus::PASSED === $result->getStatus()); } /** * The Delete Script Action shall delete the file from the configured disks. * * @return void */ public function testDeletedFromDisk(): void { $fs = Storage::fake(Config::get(VideoConstants::SCRIPT_DISK_QUALIFIED)); $file = File::fake()->create($this->faker->word().'.txt', $this->faker->randomDigitNotNull()); $script = VideoScript::factory()->createOne([ VideoScript::ATTRIBUTE_PATH => $file->path(), ]); $action = new DeleteScriptAction($script); $action->handle(); static::assertEmpty($fs->allFiles()); } /** * The Delete Video Action shall delete the script. * * @return void * * @throws Exception */ public function testVideoDeleted(): void { Storage::fake(Config::get(VideoConstants::SCRIPT_DISK_QUALIFIED)); $file = File::fake()->create($this->faker->word().'.txt', $this->faker->randomDigitNotNull()); $script = VideoScript::factory()->createOne([ VideoScript::ATTRIBUTE_PATH => $file->path(), ]); $action = new DeleteScriptAction($script); $result = $action->handle(); $action->then($result); static::assertSoftDeleted($script); } }