/** * @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()); }
/** * @test */ public function photoNameCanBeInstantiated() { $name = 'testing name'; $nameSlug = 'testing-name'; $photoName = new PhotoName($name); $this->assertTrue($photoName->name() === $name); $this->assertTrue($photoName->slug() === $nameSlug); }
/** * @return string */ public function slug() { return $this->name->slug(); }
/** * @param PhotoId $photoId * @param ResourceId $resourceId * @param PhotoName $photoName * @param PhotoThumbSize $photoThumbSize * @param PhotoFormat $photoFormat * @return HttpUrl */ public function getPhotoThumbHttpUrlBy(PhotoId $photoId, ResourceId $resourceId, PhotoName $photoName, PhotoThumbSize $photoThumbSize, PhotoFormat $photoFormat) { return new HttpUrl($this->config->urlBase() . '/' . $this->getThumbUri($photoId->id(), $photoName->slug(), $photoThumbSize->width(), $photoThumbSize->height(), $photoFormat->value())); }
/** * @param PhotoId $photoId * @param ResourceId $resourceId * @param PhotoName $photoName * @param PhotoThumbSize $photoThumbSize * @param PhotoFormat $photoFormat * @return HttpUrl */ public function getPhotoThumbHttpUrlBy(PhotoId $photoId, ResourceId $resourceId, PhotoName $photoName, PhotoThumbSize $photoThumbSize, PhotoFormat $photoFormat) { $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()]) . '_' . $photoThumbSize->width() . 'x' . $photoThumbSize->height() . '.' . $photoFormat->value()); }