infinito/application/tests/Unit/Entity/Source/Complex/UserSourceTest.php

48 lines
1.4 KiB
PHP
Raw Normal View History

<?php
2018-11-04 12:25:53 +01:00
2018-11-21 17:55:48 +01:00
namespace tests\unit\Entity\Source\Complex;
use PHPUnit\Framework\TestCase;
2018-11-21 17:55:48 +01:00
use App\Entity\Source\Complex\UserSourceInterface;
use App\Entity\Source\Complex\UserSource;
use Doctrine\Common\Collections\Collection;
2018-11-21 17:55:48 +01:00
use App\Entity\Source\Complex\PersonIdentitySourceInterface;
class UserSourceTest extends TestCase
{
/**
* @var UserSourceInterface
*/
public $userSource;
2018-11-04 12:25:53 +01:00
public function setUp(): void
{
$this->userSource = new UserSource();
}
2018-11-04 12:25:53 +01:00
public function testConstructor(): void
{
$this->assertInstanceOf(Collection::class, $this->userSource->getMemberships());
2018-11-22 21:54:57 +01:00
}
public function testHasPersonIdentitySource(): void
{
$this->assertFalse($this->userSource->hasPersonIdentitySource());
$this->userSource->setPersonIdentitySource($this->createMock(PersonIdentitySourceInterface::class));
$this->assertTrue($this->userSource->hasPersonIdentitySource());
2018-11-15 20:30:34 +01:00
$this->assertInstanceOf(PersonIdentitySourceInterface::class, $this->userSource->getPersonIdentitySource());
2018-11-22 21:54:57 +01:00
}
public function testInitPersonIdentitySource(): void
{
$this->expectException(\TypeError::class);
$this->userSource->getPersonIdentitySource();
}
public function testInitUser(): void
{
2018-11-04 12:40:57 +01:00
$this->expectException(\TypeError::class);
$this->userSource->getUser();
}
}