mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 22:17:26 +01:00
Implemented tests for condition
This commit is contained in:
parent
f89d20d365
commit
a3d10ac9af
@ -26,6 +26,6 @@ trait ConditionAttribut
|
||||
|
||||
public function hasCondition(): bool
|
||||
{
|
||||
return $this->condition;
|
||||
return $this->condition instanceof OperationInterface;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Attribut\ConditionAttributInterface;
|
||||
use App\Entity\Attribut\ConditionAttribut;
|
||||
use App\Logic\Operation\OperationInterface;
|
||||
|
||||
class ConditionAttributTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var ConditionAttributInterface
|
||||
*/
|
||||
protected $condition;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->condition = new class() implements ConditionAttributInterface {
|
||||
use ConditionAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->condition->getCondition();
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$this->assertEquals(false, $this->condition->hasCondition());
|
||||
$condition = $this->createMock(OperationInterface::class);
|
||||
$this->assertNull($this->condition->setCondition($condition));
|
||||
$this->assertEquals(true, $this->condition->hasCondition());
|
||||
$this->assertEquals($condition, $this->condition->getCondition());
|
||||
}
|
||||
}
|
@ -25,11 +25,21 @@ class RightTest extends TestCase
|
||||
$this->right = new Right();
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
public function testConstructorGeneral(): void
|
||||
{
|
||||
$this->assertEquals($this->right, $this->right->getReciever()->getRight());
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->assertNull($this->right->getLaw());
|
||||
}
|
||||
|
||||
public function testConstructorCondition()
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->right->getCondition();
|
||||
}
|
||||
|
||||
public function testConstructorType(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->assertNull($this->right->getType());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user