public function getUploadPath($filename) : string { if (null === $filename) { return $this->configurationFetcher->fetchConfigurationValue('avatar.default_avatar'); } $path = $this->configurationFetcher->fetchConfigurationValue('avatar.upload_path'); $filePath = $path . '/' . $filename; $filePath = $this->sanitizeMultipleSlashes($filePath); return $filePath; }
public function testGetUploadPathSanitizeMultipleSlashes() { $this->configurationFetcher->shouldReceive('fetchConfigurationValue')->andReturn('/upload/avatars/'); $uploadPath = $this->avatarUploadPathResolver->getUploadPath('test.jpg'); $this->assertEquals('/upload/avatars/test.jpg', $uploadPath); }