infinito/application/symfony/tests/Unit/Attribut/SlugAttributTest.php
2019-01-20 10:41:58 +01:00

43 lines
1.0 KiB
PHP

<?php
namespace Tests\Attribut;
use PHPUnit\Framework\TestCase;
use App\Attribut\SlugAttributInterface;
use App\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->assertFalse($this->slugAttribut->hasSlug());
$this->expectException(\TypeError::class);
$this->slugAttribut->getSlug();
}
public function testAccessors(): void
{
$slug = 'goodslug';
$this->assertNull($this->slugAttribut->setSlug($slug));
$this->assertTrue($this->slugAttribut->hasSlug());
$this->assertEquals($slug, $this->slugAttribut->getSlug());
$this->assertNull($this->slugAttribut->setSlug(''));
$this->assertTrue($this->slugAttribut->hasSlug());
}
}