mirror of
https://github.com/kevinveenbirkenbach/coding-challenge-online-shop.git
synced 2024-11-01 09:03:10 +01:00
Implemented image and test
This commit is contained in:
parent
ac7d0aae21
commit
782c0e511e
@ -2,20 +2,34 @@
|
|||||||
namespace entity\image;
|
namespace entity\image;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* This class represents an image which is just accessible via url
|
||||||
|
* In a real application you would upload the images to the server
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class UrlImage implements ImageInterface
|
final class UrlImage implements ImageInterface
|
||||||
{
|
{
|
||||||
|
private $path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is just a dummy function.
|
||||||
|
* In a real application you would return here a smaller scaled image
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @see \entity\image\ImageInterface::getImageThumbnail()
|
||||||
|
*/
|
||||||
public function getImageThumbnail(): string
|
public function getImageThumbnail(): string
|
||||||
{}
|
{
|
||||||
|
return $this->path;
|
||||||
|
}
|
||||||
|
|
||||||
public function getImage(): string
|
public function getImage(): string
|
||||||
{}
|
{
|
||||||
|
return $this->path;
|
||||||
|
}
|
||||||
|
|
||||||
public function setImage(string $path): void
|
public function setImage(string $path): void
|
||||||
{}
|
{
|
||||||
|
$this->path = $path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
33
src/entity/image/UrlImageTest.php
Normal file
33
src/entity/image/UrlImageTest.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
namespace entity\image;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author kevinfrantz
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class UrlImageTest extends TestCase
|
||||||
|
{
|
||||||
|
const IMAGE_URL = 'http://dummy.image/test.jpg';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var UrlImage
|
||||||
|
*/
|
||||||
|
protected $urlImage;
|
||||||
|
|
||||||
|
protected function setUp():void{
|
||||||
|
$this->urlImage = new UrlImage();
|
||||||
|
$this->urlImage->setImage(self::IMAGE_URL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testImage():void{
|
||||||
|
$this->assertEquals(self::IMAGE_URL, $this->urlImage->getImage());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testThumbnail():void{
|
||||||
|
$this->assertEquals(self::IMAGE_URL, $this->urlImage->getImageThumbnail());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user