infinito/application/symfony/tests/Unit/Attribut/ClassAttributTest.php

47 lines
1.2 KiB
PHP
Raw Normal View History

2019-02-03 12:34:29 +01:00
<?php
namespace Attribut;
use Infinito\Attribut\ClassAttribut;
2020-04-02 21:13:35 +02:00
use Infinito\Attribut\ClassAttributInterface;
use Infinito\Entity\Source\AbstractSource;
2020-04-02 21:13:35 +02:00
use PHPUnit\Framework\TestCase;
2019-02-03 12:34:29 +01:00
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class ClassAttributTest extends TestCase
{
/**
* @var ClassAttributInterface
*/
protected $classAttribut;
public function setUp(): void
{
$this->classAttribut = new class() implements ClassAttributInterface {
use ClassAttribut;
};
}
public function testConstructor(): void
{
2019-02-03 13:13:11 +01:00
$this->assertFalse($this->classAttribut->hasClass());
2019-02-03 12:34:29 +01:00
$this->expectException(\TypeError::class);
$this->classAttribut->getClass();
}
public function testAccessors(): void
{
$class = AbstractSource::class;
$this->assertNull($this->classAttribut->setClass($class));
2019-02-03 13:13:11 +01:00
$this->assertTrue($this->classAttribut->hasClass());
2019-02-03 12:34:29 +01:00
$this->assertEquals($class, $this->classAttribut->getClass());
}
public function testException(): void
{
$class = 'NOTEXISTINGCLASS';
$this->expectException(NotFoundHttpException::class);
$this->classAttribut->setClass($class);
}
}