public function test_it_returns_a_409_on_duplicate_file() { $e = (new SampleExceptionHandler())->render(FileExistsException::fileExists('already/existing.jpg')); $this->assertHttpException($e, 409); }
/** * Decide what to do about duplicated files. * @param \Plank\Mediable\Media $model * @return void * @throws \Plank\Mediable\Exceptions\MediaUpload\FileExistsException If directory is not writable or file already exists at the destination and on_duplicate is set to 'error' */ private function handleDuplicate(Media $model) { switch ($this->config['on_duplicate']) { case static::ON_DUPLICATE_ERROR: throw FileExistsException::fileExists($model->getDiskPath()); break; case static::ON_DUPLICATE_REPLACE: $this->deleteExistingMedia($model); break; case static::ON_DUPLICATE_INCREMENT: default: $model->filename = $this->generateUniqueFilename($model); } }