mirror of
				https://github.com/kevinveenbirkenbach/coding-challenge-online-shop.git
				synced 2025-11-04 02:57:57 +00:00 
			
		
		
		
	Implemented image and test
This commit is contained in:
		@@ -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());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Reference in New Issue
	
	Block a user