mirror of
https://github.com/kevinveenbirkenbach/coding-challenge-online-shop.git
synced 2024-11-01 00:53:10 +01:00
Implemented UniqueInterface, User and tests
This commit is contained in:
parent
400e64a822
commit
14fff41c96
22
src/entity/UniqueInterface.php
Normal file
22
src/entity/UniqueInterface.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace entity;
|
||||
|
||||
/**
|
||||
* This interface is needed for handling unique entities.
|
||||
* Unique entities are defined by an id
|
||||
* @author kevinfrantz
|
||||
*
|
||||
*/
|
||||
interface UniqueInterface
|
||||
{
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId():int;
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*/
|
||||
public function setId(int $id):void;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ namespace entity\order;
|
||||
use entity\product\ProductInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use entity\user\UserInterface;
|
||||
use entity\UniqueInterface;
|
||||
|
||||
/**
|
||||
* Status in this class is bool
|
||||
@ -18,7 +19,7 @@ use entity\user\UserInterface;
|
||||
* @author kevinfrantz
|
||||
*
|
||||
*/
|
||||
interface OrderInterface
|
||||
interface OrderInterface extends UniqueInterface
|
||||
{
|
||||
/**
|
||||
* @param ProductInterface $product
|
||||
@ -35,13 +36,6 @@ interface OrderInterface
|
||||
*/
|
||||
public function getProducts():ArrayCollection;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId():int;
|
||||
|
||||
public function setId(int $id):void;
|
||||
|
||||
/**
|
||||
* @return UserInterface
|
||||
*/
|
||||
|
@ -3,6 +3,7 @@ namespace entity\product;
|
||||
|
||||
use entity\price\PriceInterface;
|
||||
use entity\image\ImageInterface;
|
||||
use entity\UniqueInterface;
|
||||
|
||||
/**
|
||||
* Attention:
|
||||
@ -12,7 +13,7 @@ use entity\image\ImageInterface;
|
||||
* @author kevinfrantz
|
||||
*
|
||||
*/
|
||||
interface ProductInterface
|
||||
interface ProductInterface extends UniqueInterface
|
||||
{
|
||||
/**
|
||||
* @return PriceInterface
|
||||
@ -53,12 +54,5 @@ interface ProductInterface
|
||||
* @param string $color
|
||||
*/
|
||||
public function setColor(string $color):void;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId():int;
|
||||
|
||||
public function setId(int $id):void;
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,12 @@ final class User implements UserInterface
|
||||
* @var string
|
||||
*/
|
||||
private $passwordHash;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $id;
|
||||
|
||||
public function setName(string $name): void
|
||||
{
|
||||
@ -53,5 +59,15 @@ final class User implements UserInterface
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
public function setId(int $id): void
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
namespace entity\user;
|
||||
|
||||
use entity\UniqueInterface;
|
||||
|
||||
/**
|
||||
* Theoreticly you could make an own entity for name
|
||||
* (Depends on the use case.)
|
||||
@ -9,7 +11,7 @@ namespace entity\user;
|
||||
* @author kevinfrantz
|
||||
*
|
||||
*/
|
||||
interface UserInterface
|
||||
interface UserInterface extends UniqueInterface
|
||||
{
|
||||
/**
|
||||
* @param string $hash
|
||||
|
@ -16,6 +16,8 @@ class UserTest extends TestCase
|
||||
|
||||
const HASH = '1235';
|
||||
|
||||
const ID = 5678;
|
||||
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
@ -26,6 +28,7 @@ class UserTest extends TestCase
|
||||
$this->user->setName(self::NAME);
|
||||
$this->user->setEmail(self::EMAIL);
|
||||
$this->user->setPasswordHash(self::HASH);
|
||||
$this->user->setId(self::ID);
|
||||
}
|
||||
|
||||
public function testName():void{
|
||||
@ -40,5 +43,8 @@ class UserTest extends TestCase
|
||||
$this->assertEquals(self::HASH, $this->user->getPasswordHash());
|
||||
}
|
||||
|
||||
public function testId():void{
|
||||
$this->assertEquals(self::ID, $this->user->getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user