27 lines
691 B
PHP
27 lines
691 B
PHP
<?php
|
|
|
|
namespace NoccyLabs\StateMachine;
|
|
|
|
use NoccyLabs\StateMachine\StateMachineTrait;
|
|
use NoccyLabs\StateMachine\StateTrait;
|
|
use NoccyLabs\StateMachine\Attributes\ValidTransitions;
|
|
|
|
require_once __DIR__."/OrderState.php";
|
|
|
|
#[\PHPUnit\Framework\Attributes\CoversClass(StateMachineTrait::class)]
|
|
class StateMachineTraitTest extends \PHPUnit\Framework\TestCase
|
|
{
|
|
use StateMachineTrait;
|
|
|
|
private OrderState $state = OrderState::PENDING;
|
|
|
|
public function testValidTransitions()
|
|
{
|
|
|
|
$this->tryTransition($this->state, OrderState::PROCESSING);
|
|
$this->expectException(\Exception::class);
|
|
$this->tryTransition($this->state, OrderState::SHIPPED);
|
|
|
|
}
|
|
}
|