2018-11-01 20:42:18 +01:00
|
|
|
<?php
|
2018-11-01 22:34:26 +01:00
|
|
|
|
2019-01-20 10:41:58 +01:00
|
|
|
namespace Tests\Unit\Attribut;
|
2018-11-01 20:42:18 +01:00
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
2019-01-20 10:41:58 +01:00
|
|
|
use App\Attribut\IdAttribut;
|
|
|
|
use App\Attribut\IdAttributInterface;
|
2018-11-01 20:42:18 +01:00
|
|
|
|
2019-01-13 20:18:52 +01:00
|
|
|
/**
|
|
|
|
* @author kevinfrantz
|
|
|
|
*/
|
2018-11-01 20:42:18 +01:00
|
|
|
class IdAttributTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var IdAttributInterface
|
|
|
|
*/
|
|
|
|
protected $id;
|
2018-11-01 22:34:26 +01:00
|
|
|
|
|
|
|
public function setUp(): void
|
|
|
|
{
|
|
|
|
$this->id = new class() implements IdAttributInterface {
|
2018-11-01 20:42:18 +01:00
|
|
|
use IdAttribut;
|
|
|
|
};
|
|
|
|
}
|
2018-11-01 22:34:26 +01:00
|
|
|
|
|
|
|
public function testConstruct(): void
|
|
|
|
{
|
2019-01-13 20:18:52 +01:00
|
|
|
$this->assertFalse($this->id->hasId());
|
2019-02-13 18:03:25 +01:00
|
|
|
$this->assertNull($this->id->getId());
|
2018-11-01 20:42:18 +01:00
|
|
|
}
|
2018-11-01 22:34:26 +01:00
|
|
|
|
|
|
|
public function testAccessors(): void
|
|
|
|
{
|
2018-11-01 20:42:18 +01:00
|
|
|
$id = 1234;
|
|
|
|
$this->assertNull($this->id->setId($id));
|
|
|
|
$this->assertEquals($id, $this->id->getId());
|
2019-01-13 20:18:52 +01:00
|
|
|
$this->assertTrue($this->id->hasId());
|
|
|
|
$this->assertNull($this->id->setId(0));
|
|
|
|
$this->assertTrue($this->id->hasId());
|
2018-11-01 20:42:18 +01:00
|
|
|
}
|
|
|
|
}
|