Implemented test and logic for AbstractOperation

This commit is contained in:
Kevin Frantz
2018-10-31 12:15:49 +01:00
parent f576587f32
commit 6540e1dd95
6 changed files with 132 additions and 3 deletions

View File

@@ -3,11 +3,11 @@
namespace App\Entity\Source\Operation;
use App\Logic\Result\ResultInterface;
use App\Logic\Operation\OperationInterface;
use App\Logic\Operation\OperandInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Source\AbstractSource;
use App\Entity\Source\Operation\Attribut\OperandsAttribut;
/**
* @author kevinfrantz
@@ -17,8 +17,10 @@ use App\Entity\Source\AbstractSource;
* @ORM\DiscriminatorColumn(name="discr", type="string")
* @ORM\DiscriminatorMap({"and" = "AndOperation"})
*/
abstract class AbstractOperation extends AbstractSource implements OperationInterface
abstract class AbstractOperation extends AbstractSource implements OperandInterface
{
use OperandsAttribut;
/**
* The result MUST NOT be saved via Doctrine!
*
@@ -31,6 +33,12 @@ abstract class AbstractOperation extends AbstractSource implements OperationInte
*/
protected $operands;
public function __construct()
{
parent::__construct();
$this->operands = new ArrayCollection();
}
public function getResult(): ResultInterface
{
return $this->result;

View File

@@ -11,7 +11,7 @@ use Doctrine\ORM\Mapping as ORM;
* @ORM\Table(name="source_operation_and")
* @ORM\Entity()
*/
class AndOperation extends AbstractOperation
final class AndOperation extends AbstractOperation
{
public function process(): void
{

View File

@@ -0,0 +1,29 @@
<?php
namespace App\Entity\Source\Operation\Attribut;
use Doctrine\Common\Collections\Collection;
trait OperandsAttribut
{
/**
* @var Collection
*/
protected $operands;
/**
* @param Collection $collection
*/
public function setOperands(Collection $operands): void
{
$this->operands = $operands;
}
/**
* @return Collection
*/
public function getOperands(): Collection
{
return $this->operands;
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace App\Entity\Source\Operation\Attribut;
use Doctrine\Common\Collections\Collection;
interface OperandsAttributInterface
{
/**
* @param Collection $collection
*/
public function setOperands(Collection $operands): void;
/**
* @return Collection
*/
public function getOperands(): Collection;
}

View File

@@ -0,0 +1,10 @@
<?php
namespace App\Entity\Source\Operation;
use App\Entity\Source\Operation\Attribut\OperandsAttributInterface;
use App\Logic\Operation\OperationInterface as OperationInterfaceOrigine;
interface OperationInterface extends OperandsAttributInterface, OperationInterfaceOrigine
{
}