mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-08 13:51:34 +01:00
Refactored reciever group and adapted testing namespaces
This commit is contained in:
parent
09cfcebb92
commit
bb01080b34
@ -17,7 +17,6 @@ doctrine:
|
||||
url: '%env(resolve:DATABASE_URL)%'
|
||||
types:
|
||||
RightType: App\DBAL\Types\RightType
|
||||
RecieverType: App\DBAL\Types\RecieverType
|
||||
LayerType: App\DBAL\Types\LayerType
|
||||
orm:
|
||||
auto_generate_proxy_classes: '%kernel.debug%'
|
||||
|
@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DBAL\Types;
|
||||
|
||||
use Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class RecieverType extends AbstractEnumType
|
||||
{
|
||||
public const NODE = 'node';
|
||||
|
||||
public const PARENTS = 'parents';
|
||||
|
||||
public const CHILDREN = 'children';
|
||||
|
||||
public const SIBLINGS = 'siblings';
|
||||
|
||||
protected static $choices = [
|
||||
self::NODE => 'node',
|
||||
self::PARENTS => 'parents',
|
||||
self::CHILDREN => 'children',
|
||||
self::SIBLINGS => 'siblings',
|
||||
];
|
||||
}
|
@ -2,22 +2,24 @@
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Meta\RecieverInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
trait RecieverAttribut
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
* @var RecieverInterface
|
||||
*/
|
||||
protected $reciever;
|
||||
|
||||
public function setReciever(string $type): void
|
||||
public function setReciever(RecieverInterface $recieverGroup): void
|
||||
{
|
||||
$this->reciever = $type;
|
||||
$this->reciever = $recieverGroup;
|
||||
}
|
||||
|
||||
public function getReciever(): string
|
||||
public function getReciever(): RecieverInterface
|
||||
{
|
||||
return $this->reciever;
|
||||
}
|
||||
|
@ -2,12 +2,14 @@
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Meta\RecieverInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RecieverAttributInterface
|
||||
{
|
||||
public function setReciever(string $type): void;
|
||||
public function setReciever(RecieverInterface $recieverGroup): void;
|
||||
|
||||
public function getReciever(): string;
|
||||
public function getReciever(): RecieverInterface;
|
||||
}
|
||||
|
@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Meta\RecieverGroupInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
trait RecieverGroupAttribut
|
||||
{
|
||||
/**
|
||||
* @var RecieverGroupInterface
|
||||
*/
|
||||
protected $recieverGroup;
|
||||
|
||||
public function setRecieverGroup(RecieverGroupInterface $recieverGroup): void
|
||||
{
|
||||
$this->recieverGroup = $recieverGroup;
|
||||
}
|
||||
|
||||
public function getRecieverGroup(): RecieverGroupInterface
|
||||
{
|
||||
return $this->recieverGroup;
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Meta\RecieverGroupInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RecieverGroupAttributInterface
|
||||
{
|
||||
public function setRecieverGroup(RecieverGroupInterface $recieverGroup): void;
|
||||
|
||||
public function getRecieverGroup(): RecieverGroupInterface;
|
||||
}
|
34
application/src/Entity/Meta/Reciever.php
Normal file
34
application/src/Entity/Meta/Reciever.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Meta;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Fresh\DoctrineEnumBundle\Validator\Constraints as DoctrineAssert;
|
||||
use App\Entity\Attribut\RelationAttribut;
|
||||
use App\Entity\Attribut\RelationAttributInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
* @ORM\Table(name="meta_reciever_group")
|
||||
* @ORM\Entity()
|
||||
*/
|
||||
class Reciever extends AbstractMeta implements RecieverInterface
|
||||
{
|
||||
use RelationAttribut;
|
||||
|
||||
/**
|
||||
* The node for which the right exists.
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Relation")
|
||||
* @ORM\JoinColumn(name="relation_id", referencedColumnName="id")
|
||||
*
|
||||
* @var RelationAttributInterface
|
||||
*/
|
||||
protected $relation;
|
||||
|
||||
public function getAllRecievers(): ArrayCollection
|
||||
{
|
||||
}
|
||||
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Meta;
|
||||
|
||||
use App\Entity\Attribut\RecieverAttribut;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\DBAL\Types\RecieverType;
|
||||
use Symfony\Component\Intl\Exception\NotImplementedException;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Fresh\DoctrineEnumBundle\Validator\Constraints as DoctrineAssert;
|
||||
use App\Entity\Attribut\RelationAttribut;
|
||||
use App\Entity\Attribut\RelationAttributInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
* @ORM\Table(name="meta_reciever_group")
|
||||
* @ORM\Entity()
|
||||
*/
|
||||
final class RecieverGroup extends AbstractMeta implements RecieverGroupInterface
|
||||
{
|
||||
use RelationAttribut,RecieverAttribut;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="reciever", type="RecieverType", nullable=false)
|
||||
* @DoctrineAssert\Enum(entity="App\DBAL\Types\RecieverType")
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $reciever;
|
||||
|
||||
/**
|
||||
* The node for which the right exists.
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Relation")
|
||||
* @ORM\JoinColumn(name="relation_id", referencedColumnName="id")
|
||||
*
|
||||
* @var RelationAttributInterface
|
||||
*/
|
||||
protected $relation;
|
||||
|
||||
public function getAllRecievers(): ArrayCollection
|
||||
{
|
||||
switch ($this->reciever) {
|
||||
case RecieverType::PARENTS:
|
||||
return $this->node->getParents();
|
||||
case RecieverType::NODE:
|
||||
return new ArrayCollection([$this->node]);
|
||||
case RecieverType::CHILDREN:
|
||||
return $this->node->getChilds();
|
||||
}
|
||||
throw new NotImplementedException('Reciever '.$this->reciever.' not implemented.');
|
||||
}
|
||||
}
|
@ -2,14 +2,13 @@
|
||||
|
||||
namespace App\Entity\Meta;
|
||||
|
||||
use App\Entity\Attribut\RecieverAttributInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Entity\Attribut\RelationAttributInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RecieverGroupInterface extends RelationAttributInterface, RecieverAttributInterface, MetaInterface
|
||||
interface RecieverInterface extends RelationAttributInterface, MetaInterface
|
||||
{
|
||||
public function getAllRecievers(): ArrayCollection;
|
||||
}
|
@ -11,7 +11,7 @@ use App\DBAL\Types\RightType;
|
||||
use App\Entity\Attribut\GrantAttribut;
|
||||
use App\Logic\Operation\OperationInterface;
|
||||
use App\Entity\Attribut\ConditionAttribut;
|
||||
use App\Entity\Attribut\RecieverGroupAttribut;
|
||||
use App\Entity\Attribut\RecieverAttribut;
|
||||
use App\Entity\Attribut\LayerAttribut;
|
||||
use App\Entity\Attribut\RelationAttribut;
|
||||
|
||||
@ -22,7 +22,7 @@ use App\Entity\Attribut\RelationAttribut;
|
||||
*/
|
||||
final class Right extends AbstractMeta implements RightInterface
|
||||
{
|
||||
use TypeAttribut,LawAttribut, RelationAttribut, GrantAttribut,ConditionAttribut,RecieverGroupAttribut,LayerAttribut;
|
||||
use TypeAttribut,LawAttribut, RelationAttribut, GrantAttribut,ConditionAttribut,RecieverAttribut,LayerAttribut;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Law", inversedBy="rights")
|
||||
@ -44,9 +44,9 @@ final class Right extends AbstractMeta implements RightInterface
|
||||
* @ORM\OneToOne(targetEntity="RecieverGroup",cascade={"persist", "remove"})
|
||||
* @ORM\JoinColumn(name="reciever_id", referencedColumnName="id")
|
||||
*
|
||||
* @var RecieverGroupInterface
|
||||
* @var RecieverInterface
|
||||
*/
|
||||
protected $recieverGroup;
|
||||
protected $reciever;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean",name="`grant`")
|
||||
|
@ -4,7 +4,7 @@ namespace App\Entity\Meta;
|
||||
|
||||
use App\Entity\Attribut\TypeAttributInterface;
|
||||
use App\Entity\Attribut\LawAttributInterface;
|
||||
use App\Entity\Attribut\RecieverGroupAttributInterface;
|
||||
use App\Entity\Attribut\RecieverAttributInterface;
|
||||
use App\Entity\Attribut\GrantAttributInterface;
|
||||
use App\Entity\Attribut\ConditionAttributInterface;
|
||||
use App\Entity\Attribut\LayerAttributInterface;
|
||||
@ -14,6 +14,6 @@ use App\Entity\Attribut\RelationAttributInterface;
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RightInterface extends TypeAttributInterface, LawAttributInterface, RelationGrantedInterface, GrantAttributInterface, RecieverGroupAttributInterface, RelationAttributInterface, ConditionAttributInterface, LayerAttributInterface, MetaInterface
|
||||
interface RightInterface extends TypeAttributInterface, LawAttributInterface, RelationGrantedInterface, GrantAttributInterface, RecieverAttributInterface, RelationAttributInterface, ConditionAttributInterface, LayerAttributInterface, MetaInterface
|
||||
{
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
namespace tests\unit\Entity;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\EntityInterface;
|
||||
use App\Entity\AbstractEntity;
|
||||
|
||||
class AbstractEntityTest extends TestCase
|
||||
{
|
||||
|
@ -1,10 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Meta;
|
||||
namespace tests\unit\Entity\Meta;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Entity\Meta\LawInterface;
|
||||
use App\Entity\Meta\Law;
|
||||
use App\Entity\Meta\Right;
|
||||
|
||||
class LawTest extends TestCase
|
||||
{
|
||||
|
24
application/tests/unit/Entity/Meta/RecieverTest.php
Normal file
24
application/tests/unit/Entity/Meta/RecieverTest.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace App\tests\unit\Entity\Meta;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use App\Entity\Meta\Reciever;
|
||||
use App\Entity\Meta\RecieverInterface;
|
||||
|
||||
class RecieverTest extends TestCase
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var RecieverInterface
|
||||
*/
|
||||
public $reciever;
|
||||
|
||||
public function setUp():void{
|
||||
$this->reciever = new Reciever();
|
||||
}
|
||||
|
||||
public function testConstructor():void {
|
||||
$this->assertEquals(Collection::class, $this->reciever->getAllRecievers());
|
||||
}
|
||||
}
|
@ -1,9 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Meta;
|
||||
namespace tests\unit\Entity;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\DBAL\Types\RightType;
|
||||
use App\Entity\Meta\RightInterface;
|
||||
use App\Entity\Meta\Right;
|
||||
use App\Entity\Meta\Law;
|
||||
|
||||
/**
|
||||
* @todo Implement reciever test
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Source\Operand;
|
||||
namespace tests\unit\Entity\Source\Operand;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Source\Operation\AbstractOperation;
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Source\Operation;
|
||||
namespace tests\unit\Entity\Source\Operation;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Exception\NotDefinedException;
|
||||
@ -8,6 +8,8 @@ use App\Logic\Result\Result;
|
||||
use App\Logic\Operation\OperandInterface;
|
||||
use App\Logic\Result\ResultInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Entity\Source\Operation\OperationInterface;
|
||||
use App\Entity\Source\Operation\AndOperation;
|
||||
|
||||
class AndOperationTest extends TestCase
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user