/** * @test */ public function getBaseHttpUrlByResourceIdReturnsExpected() { $photoId = new PhotoId(); $resourceId = new ResourceId('test'); $name = new PhotoName('test'); $file = new PhotoFile(__DIR__ . '/photo_to_upload.png'); $this->assertEquals(implode('/', [$this->urlBase, $this->getMd5Path($resourceId->id()), $photoId->id(), $name->slug()]) . '.' . $file->format(), $this->storage->getPhotoHttpUrlBy($photoId, $resourceId, $name, $file)->value()); }
/** * @param PhotoId $photoId * @param ResourceId $resourceId * @param PhotoName $photoName * @param PhotoFile $photoFile * @return HttpUrl */ public function getPhotoHttpUrlBy(PhotoId $photoId, ResourceId $resourceId, PhotoName $photoName, PhotoFile $photoFile) { return new HttpUrl($this->config->urlBase() . '/' . $this->getPhotoUri($photoId->id(), $photoName->slug(), $photoFile->format())); }
/** * @test */ public function photoFileInstanceWorks() { $photoFile = new PhotoFile(__DIR__ . '/pixel.png'); $this->assertEquals('png', $photoFile->format()); $this->assertEquals(__DIR__ . '/pixel.png', $photoFile->filePath()); }
/** * @param PhotoId $photoId * @param ResourceId $resourceId * @param PhotoName $photoName * @param PhotoFile $photoFile * @return HttpUrl */ public function getPhotoHttpUrlBy(PhotoId $photoId, ResourceId $resourceId, PhotoName $photoName, PhotoFile $photoFile) { $urlBase = $this->localStorageConfig->urlBase(); $urlBase = $urlBase[strlen($urlBase) - 1] === '/' ? substr($urlBase, 0, -1) : $urlBase; return new HttpUrl(implode('/', [$urlBase, $this->getMd5Path($resourceId->id()), $photoId->id(), $photoName->slug()]) . '.' . $photoFile->format()); }