mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 13:57:10 +02:00
Optimized for SPA
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user