2018-11-23 18:17:00 +01:00
|
|
|
<?php
|
|
|
|
|
2019-01-20 10:41:58 +01:00
|
|
|
namespace Tests\Attribut;
|
2018-11-23 18:17:00 +01:00
|
|
|
|
2019-02-17 14:33:19 +01:00
|
|
|
use Infinito\Attribut\SlugAttribut;
|
2020-04-02 21:13:35 +02:00
|
|
|
use Infinito\Attribut\SlugAttributInterface;
|
2019-04-15 01:37:17 +02:00
|
|
|
use Infinito\Exception\Validation\ValueInvalidException;
|
2020-04-02 21:13:35 +02:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2018-11-23 18:17:00 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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
|
|
|
|
{
|
2019-01-13 20:18:52 +01:00
|
|
|
$this->assertFalse($this->slugAttribut->hasSlug());
|
2019-02-13 18:03:25 +01:00
|
|
|
$this->assertNull($this->slugAttribut->getSlug());
|
2018-11-23 18:17:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testAccessors(): void
|
|
|
|
{
|
|
|
|
$slug = 'goodslug';
|
|
|
|
$this->assertNull($this->slugAttribut->setSlug($slug));
|
2019-01-13 20:18:52 +01:00
|
|
|
$this->assertTrue($this->slugAttribut->hasSlug());
|
2018-11-23 18:17:00 +01:00
|
|
|
$this->assertEquals($slug, $this->slugAttribut->getSlug());
|
2019-01-13 20:18:52 +01:00
|
|
|
$this->assertNull($this->slugAttribut->setSlug(''));
|
|
|
|
$this->assertTrue($this->slugAttribut->hasSlug());
|
2018-11-23 18:17:00 +01:00
|
|
|
}
|
2019-01-20 11:03:21 +01:00
|
|
|
|
|
|
|
public function testNumericSetException(): void
|
|
|
|
{
|
2019-04-15 01:37:17 +02:00
|
|
|
$this->expectException(ValueInvalidException::class);
|
2019-01-20 11:03:21 +01:00
|
|
|
$this->slugAttribut->setSlug('1234');
|
|
|
|
}
|
2018-11-23 18:17:00 +01:00
|
|
|
}
|