mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 05:47:11 +02:00
Optimized for SPA
This commit is contained in:
47
application/symfony/tests/Unit/Entity/AbstractEntityTest.php
Normal file
47
application/symfony/tests/Unit/Entity/AbstractEntityTest.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace tests\unit\Entity;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\EntityInterface;
|
||||
use App\Entity\AbstractEntity;
|
||||
|
||||
class AbstractEntityTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var EntityInterface
|
||||
*/
|
||||
protected $entity;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->entity = new class() extends AbstractEntity {
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->assertEquals(0, $this->entity->getVersion());
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->entity->getId();
|
||||
}
|
||||
|
||||
public function testVersion(): void
|
||||
{
|
||||
$version = 123;
|
||||
$this->assertNull($this->entity->setVersion($version));
|
||||
$this->assertEquals($version, $this->entity->getVersion());
|
||||
}
|
||||
|
||||
public function testId(): void
|
||||
{
|
||||
$id = 123;
|
||||
$this->assertNull($this->entity->setId($id));
|
||||
$this->assertEquals($id, $this->entity->getId());
|
||||
}
|
||||
|
||||
public function testToString(): void
|
||||
{
|
||||
$this->assertEquals(true, is_string($this->entity->__toString()));
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Attribut\ChildsAttributeInterface;
|
||||
use App\Entity\Attribut\ChildsAttribut;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
class ChildsAttributTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var ChildsAttributeInterface
|
||||
*/
|
||||
protected $childs;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->childs = new class() implements ChildsAttributeInterface {
|
||||
use ChildsAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->childs->getChilds();
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$childs = new ArrayCollection();
|
||||
$this->assertNull($this->childs->setChilds($childs));
|
||||
$this->assertEquals($childs, $this->childs->getChilds());
|
||||
}
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Attribut\CollectionAttributInterface;
|
||||
use App\Entity\Attribut\CollectionAttribut;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
class CollectionAttributTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var CollectionAttributInterface
|
||||
*/
|
||||
protected $collection;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->collection = new class() implements CollectionAttributInterface {
|
||||
use CollectionAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->collection->getCollection();
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$collection = new ArrayCollection();
|
||||
$this->assertNull($this->collection->setCollection($collection));
|
||||
$this->assertEquals($collection, $this->collection->getCollection());
|
||||
}
|
||||
|
||||
public function testAdd(): void
|
||||
{
|
||||
$mock = new class() {
|
||||
};
|
||||
$this->collection->setCollection(new ArrayCollection());
|
||||
$this->assertTrue($this->collection->getCollection()->add($mock));
|
||||
$this->assertEquals($mock, $this->collection->getCollection()->get(0));
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Attribut\ConditionAttributInterface;
|
||||
use App\Entity\Attribut\ConditionAttribut;
|
||||
use App\Logic\Operation\OperationInterface;
|
||||
|
||||
class ConditionAttributTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var ConditionAttributInterface
|
||||
*/
|
||||
protected $condition;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->condition = new class() implements ConditionAttributInterface {
|
||||
use ConditionAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->condition->getCondition();
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$this->assertEquals(false, $this->condition->hasCondition());
|
||||
$condition = $this->createMock(OperationInterface::class);
|
||||
$this->assertNull($this->condition->setCondition($condition));
|
||||
$this->assertEquals(true, $this->condition->hasCondition());
|
||||
$this->assertEquals($condition, $this->condition->getCondition());
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests\Unit\Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Attribut\CreatorRelationAttributInterface;
|
||||
use App\Entity\Attribut\CreatorRelationAttribut;
|
||||
use App\Entity\Meta\Relation\Parent\CreatorRelationInterface;
|
||||
|
||||
class CreatorRelationAttributTest extends TestCase
|
||||
{
|
||||
/***
|
||||
* @var CreatorRelationAttributInterface
|
||||
*/
|
||||
protected $creatorRelationAttribut;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->creatorRelationAttribut = new class() implements CreatorRelationAttributInterface {
|
||||
use CreatorRelationAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$relation = $this->createMock(CreatorRelationInterface::class);
|
||||
$this->assertNull($this->creatorRelationAttribut->setCreatorRelation($relation));
|
||||
$this->assertEquals($relation, $this->creatorRelationAttribut->getCreatorRelation());
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Attribut\FirstNameSourceAttribut;
|
||||
use App\Entity\Attribut\FirstNameSourceAttributInterface;
|
||||
use App\Entity\Source\Primitive\Name\FirstNameSourceInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class FirstNameSourceAttributTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var FirstNameSourceAttributInterface
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->name = new class() implements FirstNameSourceAttributInterface {
|
||||
use FirstNameSourceAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->name->getFirstNameSource();
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$name = $this->createMock(FirstNameSourceInterface::class);
|
||||
$this->assertNull($this->name->setFirstNameSource($name));
|
||||
$this->assertEquals($name, $this->name->getFirstNameSource());
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Source\Complex\FullPersonNameSourceInterface;
|
||||
use App\Entity\Attribut\FullPersonNameSourceAttributInterface;
|
||||
use App\Entity\Attribut\FullPersonNameSourceAttribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class FullPersonNameSourceAttributTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var FullPersonNameSourceAttributInterface
|
||||
*/
|
||||
protected $fullname;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->fullname = new class() implements FullPersonNameSourceAttributInterface {
|
||||
use FullPersonNameSourceAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->fullname->getFullPersonNameSource();
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$fullname = $this->createMock(FullPersonNameSourceInterface::class);
|
||||
$this->assertNull($this->fullname->setFullPersonNameSource($fullname));
|
||||
$this->assertEquals($fullname, $this->fullname->getFullPersonNameSource());
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Attribut\GrantAttribut;
|
||||
use App\Entity\Attribut\GrantAttributInterface;
|
||||
|
||||
class GrantAttributTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var GrantAttributInterface
|
||||
*/
|
||||
protected $grant;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->grant = new class() implements GrantAttributInterface {
|
||||
use GrantAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstruct(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->grant->getGrant();
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$grant = true;
|
||||
$this->assertNull($this->grant->setGrant($grant));
|
||||
$this->assertEquals($grant, $this->grant->getGrant());
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Attribut\IdAttribut;
|
||||
use App\Entity\Attribut\IdAttributInterface;
|
||||
|
||||
class IdAttributTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var IdAttributInterface
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->id = new class() implements IdAttributInterface {
|
||||
use IdAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstruct(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->id->getId();
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$id = 1234;
|
||||
$this->assertNull($this->id->setId($id));
|
||||
$this->assertEquals($id, $this->id->getId());
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Attribut\LayerAttributInterface;
|
||||
use App\Entity\Attribut\LayerAttribut;
|
||||
use App\DBAL\Types\Meta\Right\LayerType;
|
||||
|
||||
class LayerAttributTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var LayerAttributInterface
|
||||
*/
|
||||
protected $layer;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->layer = new class() implements LayerAttributInterface {
|
||||
use LayerAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstruct(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->layer->getLayer();
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
foreach (LayerType::getChoices() as $value) {
|
||||
$this->assertNull($this->layer->setLayer($value));
|
||||
$this->assertEquals($value, $this->layer->getLayer());
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Attribut\MemberRelationAttributInterface;
|
||||
use App\Entity\Attribut\MemberRelationAttribut;
|
||||
use App\Entity\Meta\Relation\Member\MemberRelationInterface;
|
||||
|
||||
class MemberRelationAttributTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var MemberRelationAttributInterface
|
||||
*/
|
||||
protected $memberRelation;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->memberRelation = new class() implements MemberRelationAttributInterface {
|
||||
use MemberRelationAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->memberRelation->getMemberRelation();
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$membership = $this->createMock(MemberRelationInterface::class);
|
||||
$this->assertNull($this->memberRelation->setMemberRelation($membership));
|
||||
$this->assertEquals($this->memberRelation->getMemberRelation(), $membership);
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Entity\Attribut\MembersAttributInterface;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Entity\Attribut\MembersAttribut;
|
||||
|
||||
class MembersAttributTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var MembersAttributInterface
|
||||
*/
|
||||
protected $members;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->members = new class() implements MembersAttributInterface {
|
||||
use MembersAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->members->getMembers();
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$membership = $this->createMock(SourceInterface::class);
|
||||
$this->assertNull($this->members->setMembers(new ArrayCollection([$membership])));
|
||||
$this->assertEquals($this->members->getMembers()->get(0), $membership);
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Attribut\MembershipsAttributInterface;
|
||||
use App\Entity\Attribut\MembershipsAttribut;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Entity\Source\Complex\Collection\TreeCollectionSourceInterface;
|
||||
|
||||
class MembershipsAttributTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var MembershipsAttributInterface
|
||||
*/
|
||||
protected $memberships;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->memberships = new class() implements MembershipsAttributInterface {
|
||||
use MembershipsAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->memberships->getMemberships();
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$membership = $this->createMock(TreeCollectionSourceInterface::class);
|
||||
$this->assertNull($this->memberships->setMemberships(new ArrayCollection([$membership])));
|
||||
$this->assertEquals($this->memberships->getMemberships()->get(0), $membership);
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class NameAttributTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var NameAttributInterface
|
||||
*/
|
||||
public $name;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->name = new class() implements NameAttributInterface {
|
||||
use NameAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->name->getName();
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$name = 'hello world!';
|
||||
$this->assertNull($this->name->setName($name));
|
||||
$this->assertEquals($name, $this->name->getName());
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace tests\unit\Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Attribut\NameSourceAttributInterface;
|
||||
use App\Entity\Attribut\NameSourceAttribut;
|
||||
use App\Entity\Source\Primitive\Name\NameSourceInterface;
|
||||
|
||||
class NameSourceAttributTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var NameSourceAttributInterface
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->name = new class() implements NameSourceAttributInterface {
|
||||
use NameSourceAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->name->getNameSource();
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$nameSource = $this->createMock(NameSourceInterface::class);
|
||||
$this->assertNull($this->name->setNameSource($nameSource));
|
||||
$this->assertEquals($nameSource, $this->name->getNameSource());
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests\Unit\Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Attribut\ParentRelationAttributInterface;
|
||||
use App\Entity\Attribut\ParentRelationAttribut;
|
||||
use App\Entity\Meta\Relation\Parent\ParentRelationInterface;
|
||||
|
||||
class ParentRelationAttributTest extends TestCase
|
||||
{
|
||||
/***
|
||||
* @var ParentRelationAttributInterface
|
||||
*/
|
||||
protected $parentRelationAttribut;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->parentRelationAttribut = new class() implements ParentRelationAttributInterface {
|
||||
use ParentRelationAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$relation = $this->createMock(ParentRelationInterface::class);
|
||||
$this->assertNull($this->parentRelationAttribut->setParentRelation($relation));
|
||||
$this->assertEquals($relation, $this->parentRelationAttribut->getParentRelation());
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Attribut\ParentsAttributInterface;
|
||||
use App\Entity\Attribut\ParentsAttribut;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
class ParentsAttributTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var ParentsAttributInterface
|
||||
*/
|
||||
protected $parents;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->parents = new class() implements ParentsAttributInterface {
|
||||
use ParentsAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->parents->getParents();
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$parents = new ArrayCollection();
|
||||
$this->assertNull($this->parents->setParents($parents));
|
||||
$this->assertEquals($parents, $this->parents->getParents());
|
||||
}
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Attribut\PersonIdentitySourceAttributInterface;
|
||||
use App\Entity\Attribut\PersonIdentitySourceAttribut;
|
||||
use App\Entity\Source\Complex\PersonIdentitySourceInterface;
|
||||
|
||||
/**
|
||||
* @todo Implement abstract test class for entity attributs
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class PersonIdentitySourceAttributTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var PersonIdentitySourceAttributInterface
|
||||
*/
|
||||
protected $identity;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->identity = new class() implements PersonIdentitySourceAttributInterface {
|
||||
use PersonIdentitySourceAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->identity->getPersonIdentitySource();
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$identity = $this->createMock(PersonIdentitySourceInterface::class);
|
||||
$this->assertNull($this->identity->setPersonIdentitySource($identity));
|
||||
$this->assertEquals($identity, $this->identity->getPersonIdentitySource());
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Attribut\PriorityAttributInterface;
|
||||
use App\Entity\Attribut\PriorityAttribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class PriorityAttributTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var PriorityAttributInterface
|
||||
*/
|
||||
protected $priorityAttribut;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->priorityAttribut = new class() implements PriorityAttributInterface {
|
||||
use PriorityAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->priorityAttribut->getPriority();
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$priority = 123;
|
||||
$this->assertNull($this->priorityAttribut->setPriority($priority));
|
||||
$this->assertEquals($priority, $this->priorityAttribut->getPriority());
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Attribut\RecieverAttributInterface;
|
||||
use App\Entity\Attribut\RecieverAttribut;
|
||||
use App\Entity\Source\AbstractSource;
|
||||
|
||||
class RecieverAttributTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var RecieverAttributInterface
|
||||
*/
|
||||
protected $reciever;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->reciever = new class() implements RecieverAttributInterface {
|
||||
use RecieverAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->reciever->getReciever();
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$reciever = $this->createMock(AbstractSource::class);
|
||||
$this->assertNull($this->reciever->setReciever($reciever));
|
||||
$this->assertEquals($reciever, $this->reciever->getReciever());
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests\Unit\Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Meta\Relation\RelationInterface;
|
||||
use App\Entity\Attribut\RelationAttributInterface;
|
||||
use App\Entity\Attribut\RelationAttribut;
|
||||
|
||||
class RelationAttributTest extends TestCase
|
||||
{
|
||||
/***
|
||||
* @var RelationAttributInterface
|
||||
*/
|
||||
protected $relationAttribut;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->relationAttribut = new class() implements RelationAttributInterface {
|
||||
use RelationAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$relation = $this->createMock(RelationInterface::class);
|
||||
$this->assertNull($this->relationAttribut->setRelation($relation));
|
||||
$this->assertEquals($relation, $this->relationAttribut->getRelation());
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests\Unit\Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Attribut\RightAttributInterface;
|
||||
use App\Entity\Attribut\RightAttribut;
|
||||
use App\Entity\Meta\RightInterface;
|
||||
|
||||
class RightAttributTest extends TestCase
|
||||
{
|
||||
/***
|
||||
* @var RightAttributInterface
|
||||
*/
|
||||
private $rightAttribut;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->rightAttribut = new class() implements RightAttributInterface {
|
||||
use RightAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$right = $this->createMock(RightInterface::class);
|
||||
$this->assertNull($this->rightAttribut->setRight($right));
|
||||
$this->assertEquals($right, $this->rightAttribut->getRight());
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Attribut\SlugAttributInterface;
|
||||
use App\Entity\Attribut\SlugAttribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class SlugAttributTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var SlugAttributInterface
|
||||
*/
|
||||
protected $slugAttribut;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->slugAttribut = new class() implements SlugAttributInterface {
|
||||
use SlugAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->slugAttribut->getSlug();
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$slug = 'goodslug';
|
||||
$this->assertNull($this->slugAttribut->setSlug($slug));
|
||||
$this->assertEquals($slug, $this->slugAttribut->getSlug());
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Attribut\TextAttributInterface;
|
||||
use App\Entity\Attribut\TextAttribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class TextAttributTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var TextAttributInterface
|
||||
*/
|
||||
protected $textAttribut;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->textAttribut = new class() implements TextAttributInterface {
|
||||
use TextAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->textAttribut->getText();
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$text = 'Hello World!';
|
||||
$this->assertNull($this->textAttribut->setText($text));
|
||||
$this->assertEquals($text, $this->textAttribut->getText());
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Attribut\TypeAttributInterface;
|
||||
use App\Entity\Attribut\TypeAttribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class TypeAttributTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var TypeAttributInterface
|
||||
*/
|
||||
protected $typeAttribut;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->typeAttribut = new class() implements TypeAttributInterface {
|
||||
use TypeAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->typeAttribut->getType();
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$type = 'Hello World!';
|
||||
$this->assertNull($this->typeAttribut->setType($type));
|
||||
$this->assertEquals($type, $this->typeAttribut->getType());
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Attribut\UserAttributInterface;
|
||||
use App\Entity\Attribut\UserAttribut;
|
||||
use App\Entity\UserInterface;
|
||||
|
||||
class UserAttributTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var UserAttributInterface
|
||||
*/
|
||||
public $user;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->user = new class() implements UserAttributInterface {
|
||||
use UserAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->user->getUser();
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$user = $this->createMock(UserInterface::class);
|
||||
$this->assertNull($this->user->setUser($user));
|
||||
$this->assertEquals($user, $this->user->getUser());
|
||||
}
|
||||
}
|
37
application/symfony/tests/Unit/Entity/Meta/LawTest.php
Normal file
37
application/symfony/tests/Unit/Entity/Meta/LawTest.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
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
|
||||
{
|
||||
/**
|
||||
* @var LawInterface
|
||||
*/
|
||||
protected $law;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->law = new Law();
|
||||
}
|
||||
|
||||
public function testConstruct(): void
|
||||
{
|
||||
$this->assertFalse($this->law->getGrant());
|
||||
$this->assertInstanceOf(Collection::class, $this->law->getRights());
|
||||
}
|
||||
|
||||
public function testRights(): void
|
||||
{
|
||||
$right = new Right();
|
||||
$rights = new ArrayCollection([$right, new Right(), new Right()]);
|
||||
$this->assertNull($this->law->setRights($rights));
|
||||
$this->assertEquals($right, $this->law->getRights()->get(0));
|
||||
}
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Entity\Meta\Relation\Member;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Meta\Relation\Member\MemberRelation;
|
||||
use App\Entity\Meta\Relation\Member\MemberRelationInterface;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
class MemberRelationTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var MemberRelationInterface
|
||||
*/
|
||||
private $memberRelation;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->memberRelation = new MemberRelation();
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->assertInstanceOf(Collection::class, $this->memberRelation->getMembers());
|
||||
$this->assertInstanceOf(Collection::class, $this->memberRelation->getMemberships());
|
||||
}
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace tests\Unit\Entity\Meta;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use App\Entity\Meta\Relation\Parent\AbstractParentRelation;
|
||||
use App\Entity\Meta\Relation\Parent\ParentRelationInterface;
|
||||
|
||||
class AbstractParentRelationTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var ParentRelationInterface
|
||||
*/
|
||||
protected $relation;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->relation = new class() extends AbstractParentRelation {
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->assertInstanceOf(Collection::class, $this->relation->getChilds());
|
||||
$this->assertInstanceOf(Collection::class, $this->relation->getParents());
|
||||
$this->assertEquals(0, $this->relation->getVersion());
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->relation->getSource();
|
||||
}
|
||||
}
|
116
application/symfony/tests/Unit/Entity/Meta/RightTest.php
Normal file
116
application/symfony/tests/Unit/Entity/Meta/RightTest.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
namespace tests\unit\Entity;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\DBAL\Types\Meta\Right\CRUDType;
|
||||
use App\Entity\Meta\RightInterface;
|
||||
use App\Entity\Meta\Right;
|
||||
use App\Entity\Meta\Law;
|
||||
use App\DBAL\Types\Meta\Right\LayerType;
|
||||
use App\Exception\NoValidChoiceException;
|
||||
use App\Entity\Source\AbstractSource;
|
||||
|
||||
/**
|
||||
* @todo Implement reciever test
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class RightTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var RightInterface
|
||||
*/
|
||||
private $right;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->right = new Right();
|
||||
}
|
||||
|
||||
public function testConstructorGeneral(): void
|
||||
{
|
||||
$this->assertTrue($this->right->getGrant());
|
||||
$this->assertEquals(0, $this->right->getPriority());
|
||||
}
|
||||
|
||||
public function testConstructorReciever(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->right->getReciever();
|
||||
}
|
||||
|
||||
public function testConstructorLayer(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->assertNull($this->right->getLayer());
|
||||
}
|
||||
|
||||
public function testConstructorLaw(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->assertNull($this->right->getLaw());
|
||||
}
|
||||
|
||||
public function testConstructorCondition(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->right->getCondition();
|
||||
}
|
||||
|
||||
public function testConstructorType(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->assertNull($this->right->getType());
|
||||
}
|
||||
|
||||
public function testLaw(): void
|
||||
{
|
||||
$law = new Law();
|
||||
$this->assertNull($this->right->setLaw($law));
|
||||
$this->assertEquals($law, $this->right->getLaw());
|
||||
}
|
||||
|
||||
public function testRight(): void
|
||||
{
|
||||
foreach (CRUDType::getChoices() as $key => $value) {
|
||||
$this->assertNull($this->right->setType($key));
|
||||
$this->assertEquals($key, $this->right->getType());
|
||||
}
|
||||
$this->expectException(NoValidChoiceException::class);
|
||||
$this->right->setType('NoneValidType');
|
||||
}
|
||||
|
||||
public function testLayer(): void
|
||||
{
|
||||
foreach (LayerType::getChoices() as $key => $value) {
|
||||
$this->assertNull($this->right->setLayer($key));
|
||||
$this->assertEquals($key, $this->right->getLayer());
|
||||
}
|
||||
$this->expectException(NoValidChoiceException::class);
|
||||
$this->right->setLayer('NoneValidLayer');
|
||||
}
|
||||
|
||||
/**
|
||||
* Just to test if the clone function works like assumed.
|
||||
*/
|
||||
public function testClone(): void
|
||||
{
|
||||
$source = $this->createMock(AbstractSource::class);
|
||||
$reciever = $this->createMock(AbstractSource::class);
|
||||
$grant = false;
|
||||
$type = CRUDType::READ;
|
||||
$layer = LayerType::SOURCE;
|
||||
$this->right->setSource($source);
|
||||
$this->right->setReciever($reciever);
|
||||
$this->right->setGrant($grant);
|
||||
$this->right->setType($type);
|
||||
$this->right->setLayer($layer);
|
||||
$rightClone = clone $this->right;
|
||||
$this->assertEquals($source, $rightClone->getSource());
|
||||
$this->assertEquals($reciever, $rightClone->getReciever());
|
||||
$this->assertEquals($grant, $rightClone->getGrant());
|
||||
$this->assertEquals($type, $rightClone->getType());
|
||||
$this->assertEquals($layer, $rightClone->getLayer());
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace tests\unit\Entity\Source;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Entity\Meta\LawInterface;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use App\Entity\EntityInterface;
|
||||
use App\Entity\Meta\Relation\Parent\CreatorRelationInterface;
|
||||
use App\Entity\Source\PureSource;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class AbstractSourceTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var SourceInterface
|
||||
*/
|
||||
protected $source;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->source = new PureSource();
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->assertInstanceOf(EntityInterface::class, $this->source);
|
||||
$this->assertInstanceOf(CreatorRelationInterface::class, $this->source->getCreatorRelation());
|
||||
$this->assertEquals($this->source, $this->source->getCreatorRelation()->getSource());
|
||||
$this->assertInstanceOf(Collection::class, $this->source->getMemberRelation()->getMemberships());
|
||||
$this->assertInstanceOf(LawInterface::class, $this->source->getLaw());
|
||||
$this->assertEquals($this->source, $this->source->getLaw()->getSource());
|
||||
$this->assertInstanceOf(Collection::class, $this->source->getMemberRelation()->getMembers());
|
||||
}
|
||||
|
||||
public function testSlugInit(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->source->getSlug();
|
||||
}
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Entity\Source\Complex\Collection;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Source\Complex\Collection\CollectionSourceInterface;
|
||||
use App\Entity\Source\Complex\Collection\AbstractCollectionSource;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
class AbstractCollectionSourceTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var CollectionSourceInterface
|
||||
*/
|
||||
public $collectionSource;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->collectionSource = new class() extends AbstractCollectionSource {
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstruct(): void
|
||||
{
|
||||
$this->assertInstanceOf(Collection::class, $this->collectionSource->getCollection());
|
||||
}
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Entity\Source\Complex\Collection;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Entity\Source\Complex\Collection\TreeCollectionSourceInterface;
|
||||
use App\Entity\Source\Complex\Collection\TreeCollectionSource;
|
||||
use App\Entity\Source\PureSource;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class TreeCollectionSourceTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var TreeCollectionSourceInterface
|
||||
*/
|
||||
protected $tree;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->tree = new TreeCollectionSource();
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->assertInstanceOf(Collection::class, $this->tree->getCollection());
|
||||
$this->assertInstanceOf(TreeCollectionSourceInterface::class, $this->tree);
|
||||
}
|
||||
|
||||
public function testAccessors()
|
||||
{
|
||||
$member = new PureSource();
|
||||
$this->tree->setCollection(new ArrayCollection([
|
||||
$member,
|
||||
]));
|
||||
$this->assertEquals($member, $this->tree->getCollection()
|
||||
->get(0));
|
||||
}
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace tests\unit\Entity\Source\Complex;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Source\Complex\FullPersonNameSourceInterface;
|
||||
use App\Entity\Source\Complex\FullPersonNameSource;
|
||||
use App\Entity\Source\Primitive\Name\SurnameSourceInterface;
|
||||
use App\Entity\Source\Primitive\Name\FirstNameSourceInterface;
|
||||
|
||||
class FullPersonNameSourceTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var FullPersonNameSourceInterface
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->name = new FullPersonNameSource();
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->assertInstanceOf(SurnameSourceInterface::class, $this->name->getSurnameSource());
|
||||
$this->assertInstanceOf(FirstNameSourceInterface::class, $this->name->getFirstNameSource());
|
||||
}
|
||||
|
||||
public function testFirstNameAccessor(): void
|
||||
{
|
||||
$name = $this->createMock(FirstNameSourceInterface::class);
|
||||
$this->assertNull($this->name->setFirstNameSource($name));
|
||||
$this->assertEquals($name, $this->name->getFirstNameSource());
|
||||
}
|
||||
|
||||
public function testSurnameAccessor(): void
|
||||
{
|
||||
$name = $this->createMock(SurnameSourceInterface::class);
|
||||
$this->assertNull($this->name->setSurnameSource($name));
|
||||
$this->assertEquals($name, $this->name->getSurnameSource());
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace tests\unit\Entity\Source\Complex;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Source\Complex\PersonIdentitySourceInterface;
|
||||
use App\Entity\Source\Complex\PersonIdentitySource;
|
||||
use App\Entity\Source\Complex\FullPersonNameSourceInterface;
|
||||
|
||||
class PersonIdentitySourceTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var PersonIdentitySourceInterface
|
||||
*/
|
||||
protected $identity;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->identity = new PersonIdentitySource();
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->assertInstanceOf(FullPersonNameSourceInterface::class, $this->identity->getFullPersonNameSource());
|
||||
}
|
||||
|
||||
public function testFullName(): void
|
||||
{
|
||||
$name = $this->createMock(FullPersonNameSourceInterface::class);
|
||||
$this->assertNull($this->identity->setFullPersonNameSource($name));
|
||||
$this->assertEquals($name, $this->identity->getFullPersonNameSource());
|
||||
}
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace tests\unit\Entity\Source\Complex;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Source\Complex\UserSourceInterface;
|
||||
use App\Entity\Source\Complex\UserSource;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use App\Entity\Source\Complex\PersonIdentitySourceInterface;
|
||||
|
||||
class UserSourceTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var UserSourceInterface
|
||||
*/
|
||||
public $userSource;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->userSource = new UserSource();
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->assertInstanceOf(Collection::class, $this->userSource->getMemberRelation()->getMemberships());
|
||||
}
|
||||
|
||||
public function testHasPersonIdentitySource(): void
|
||||
{
|
||||
$this->assertFalse($this->userSource->hasPersonIdentitySource());
|
||||
$this->userSource->setPersonIdentitySource($this->createMock(PersonIdentitySourceInterface::class));
|
||||
$this->assertTrue($this->userSource->hasPersonIdentitySource());
|
||||
$this->assertInstanceOf(PersonIdentitySourceInterface::class, $this->userSource->getPersonIdentitySource());
|
||||
}
|
||||
|
||||
public function testInitPersonIdentitySource(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->userSource->getPersonIdentitySource();
|
||||
}
|
||||
|
||||
public function testInitUser(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->userSource->getUser();
|
||||
}
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace tests\unit\Entity\Source\Operand;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Source\Operation\AbstractOperation;
|
||||
use App\Entity\Source\Operation\OperationInterface;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Logic\Operation\OperandInterface;
|
||||
use App\Logic\Result\ResultInterface;
|
||||
use App\Logic\Result\Result;
|
||||
use App\Exception\NotProcessedException;
|
||||
|
||||
class AbstractOperationTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var OperationInterface
|
||||
*/
|
||||
protected $operation;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->operation = new class() extends AbstractOperation {
|
||||
public function process(): void
|
||||
{
|
||||
$this->result = new Result();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->assertInstanceOf(Collection::class, $this->operation->getOperands());
|
||||
}
|
||||
|
||||
public function testOperands(): void
|
||||
{
|
||||
$operand = new class() implements OperandInterface {
|
||||
public function getResult(): ResultInterface
|
||||
{
|
||||
return new Result();
|
||||
}
|
||||
};
|
||||
$operands = new ArrayCollection();
|
||||
$operands->add($operand);
|
||||
$this->assertNull($this->operation->setOperands($operands));
|
||||
$this->assertEquals($operand, $this->operation->getOperands()
|
||||
->get(0));
|
||||
}
|
||||
|
||||
public function testNotProcessedException(): void
|
||||
{
|
||||
$this->expectException(NotProcessedException::class);
|
||||
$this->operation->getResult();
|
||||
}
|
||||
|
||||
public function testResult(): void
|
||||
{
|
||||
$this->setUp();
|
||||
$this->operation->process();
|
||||
$this->assertInstanceOf(ResultInterface::class, $this->operation->getResult());
|
||||
}
|
||||
|
||||
public function testProcess(): void
|
||||
{
|
||||
$this->assertEquals(null, $this->operation->process());
|
||||
}
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace tests\unit\Entity\Source\Operation;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Exception\NotDefinedException;
|
||||
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
|
||||
{
|
||||
/**
|
||||
* @var OperationInterface
|
||||
*/
|
||||
protected $operation;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->operation = new AndOperation();
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->expectException(NotDefinedException::class);
|
||||
$this->operation->process();
|
||||
}
|
||||
|
||||
public function testProcess(): void
|
||||
{
|
||||
//Test True
|
||||
$operand1 = new class() implements OperandInterface {
|
||||
public function getResult(): ResultInterface
|
||||
{
|
||||
$result = new Result();
|
||||
$result->setAll(true);
|
||||
|
||||
return $result;
|
||||
}
|
||||
};
|
||||
|
||||
$operand2 = new class() implements OperandInterface {
|
||||
public function getResult(): ResultInterface
|
||||
{
|
||||
$result = new Result();
|
||||
$result->setAll(true);
|
||||
|
||||
return $result;
|
||||
}
|
||||
};
|
||||
$operands = new ArrayCollection([$operand1, $operand2]);
|
||||
$this->operation->setOperands($operands);
|
||||
$this->operation->process();
|
||||
$this->assertEquals(true, $this->operation->getResult()->getBool());
|
||||
|
||||
//Test False
|
||||
$operand3 = new class() implements OperandInterface {
|
||||
public function getResult(): ResultInterface
|
||||
{
|
||||
$result = new Result();
|
||||
$result->setAll(false);
|
||||
|
||||
return $result;
|
||||
}
|
||||
};
|
||||
$this->operation->getOperands()->add($operand3);
|
||||
$this->operation->process();
|
||||
$this->assertEquals(false, $this->operation->getResult()->getBool());
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace tests\unit\Entity\Source\Primitive;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Source\Primitive\Name\NameSourceInterface;
|
||||
use App\Entity\Source\Primitive\Name\AbstractNameSource;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class AbstractNameSourceTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var NameSourceInterface
|
||||
*/
|
||||
protected $nameSource;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->nameSource = new class() extends AbstractNameSource {
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->assertInstanceOf(NameSourceInterface::class, $this->nameSource);
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->nameSource->getName();
|
||||
}
|
||||
|
||||
public function testName(): void
|
||||
{
|
||||
$name = 'Hello World!';
|
||||
$this->nameSource->setName($name);
|
||||
$this->assertEquals($name, $this->nameSource->getName());
|
||||
}
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Entity\Source\Primitive\Text;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Source\Primitive\Text\TextSourceInterface;
|
||||
use App\Entity\Source\Primitive\Text\TextSource;
|
||||
|
||||
class TextSourceTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var TextSourceInterface
|
||||
*/
|
||||
protected $textSource;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->textSource = new TextSource();
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->textSource->getText();
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Entity\Source;
|
||||
|
||||
use App\Entity\Source\PureSourceInterface;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Entity\Source\PureSource;
|
||||
use App\Entity\Source\AbstractSource;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class PureSourceTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var PureSourceInterface
|
||||
*/
|
||||
private $pureSource;
|
||||
|
||||
/**
|
||||
* @var SourceInterface
|
||||
*/
|
||||
private $abstractSource;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->pureSource = new PureSource();
|
||||
$this->abstractSource = new class() extends AbstractSource {
|
||||
};
|
||||
}
|
||||
|
||||
public function testMethodSet(): void
|
||||
{
|
||||
$pureSourceMethods = get_class_methods($this->pureSource);
|
||||
$abstractSourceMethods = get_class_methods($this->abstractSource);
|
||||
$this->assertArraySubset($pureSourceMethods, $abstractSourceMethods);
|
||||
}
|
||||
}
|
53
application/symfony/tests/Unit/Entity/UserTest.php
Normal file
53
application/symfony/tests/Unit/Entity/UserTest.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace tests\unit\Entity;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\User;
|
||||
use App\Entity\Source\Complex\UserSource;
|
||||
use App\Entity\UserInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
use App\Entity\Source\UserSource;
|
||||
*/
|
||||
class UserTest extends TestCase
|
||||
{
|
||||
const PASSWORD = '12345678';
|
||||
|
||||
const USERNAME = 'tester';
|
||||
|
||||
/**
|
||||
* @var UserInterface
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->user = new User();
|
||||
$this->user->setUsername(self::USERNAME);
|
||||
$this->user->setPassword(self::PASSWORD);
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->assertInstanceOf(UserInterface::class, new User());
|
||||
$this->assertEquals(0, $this->user->getVersion());
|
||||
}
|
||||
|
||||
public function testUsername(): void
|
||||
{
|
||||
$this->assertEquals(self::USERNAME, $this->user->getUsername());
|
||||
}
|
||||
|
||||
public function testPassword(): void
|
||||
{
|
||||
$this->assertEquals(self::PASSWORD, $this->user->getPassword());
|
||||
}
|
||||
|
||||
public function testSource(): void
|
||||
{
|
||||
$this->assertInstanceOf(UserSource::class, $this->user->getSource());
|
||||
$this->assertEquals($this->user, $this->user->getSource()->getUser());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user